- Upvotes Received
- 3
- Posts with Upvotes
- 3
- Upvoting Members
- 3
- Downvotes Received
- 0
- Posts with Downvotes
- 0
- Downvoting Members
- 0
82 Posted Topics
Hi! I'm trying to improve a code shown below. My idea is to add multiple images to JPanel. It sounds like an easy task, but all my attempts failed so far. I tried to create [ICODE]Image image2 = getToolkit().getImage(Drag1.class.getResource("cross_cursor.gif"));[/ICODE] and then [ICODE]bi2 = new BufferedImage(image2.getWidth(this), image2.getHeight(this)...);[/ICODE]. But I can see … | |
Hi! I'd like to check if a string contains spaces: [CODE]System.out.println(text2.getText().matches("\\s+"));[/CODE] This code returns 'false' for both "My string" and "MyString". But I need 'true' for "MySpace". How could I do this? Thanks! | |
Hi! I'm trying to create a method for simultaneous dragging a group of JLabel components. First, I select the components to be dragged ([ICODE]getSelectedStatus() -> true[/ICODE]), and then I want to be able to drag the selected components. I have a working method for a single JLabel component, but there … | |
Hi! I'm a newbie in JSP and, therefore, my question could be totally incorrect. Sorry for this. So, I've developed a Java SWING application that is actually the image processing tool. Is it possible to update this software to a web-application? For example, could I place Java classes in WEB-INF/classes/, … | |
Hi! Please, tell me how to make the JDialog close button working in a proper way. Now it does not work. [ICODE]System.out.println(value);[/ICODE] produces 0. But if I write [ICODE]if (value == 0)[/ICODE], then nothing happens. Any ideas? Thanks! [CODE] public static void about() { final JOptionPane optionPane = new JOptionPane( … | |
Hi! I would like to read XML file from my SWING application, however [ICODE]list.size()[/ICODE] returns 0. Why does it happen? Thanks! [CODE] private void open() { SAXBuilder builder = new SAXBuilder(); File xmlFile = new File(openedFileName()); try{ Document document = (Document) builder.build(xmlFile); Element rootNode = document.getRootElement(); List list = rootNode.getChildren("Panel"); … | |
Hi! I would like to select images by using a rectangular area. All images that are inside this area, must be selected. I want this area to appear while mouse clicking and dragging. So, the size of a rectangular area should change dynamically according to a position of the mouse … | |
Hi! I need my own file extension for SWING desktop application (image processing tool). In fact, I want a user to be able to save locations of JLabel components on a screen. Please, give me a hint on how to implement this task. Thanks! | |
Hi! I'm trying to create borders around JLabel components. However, the line [ICODE]c[i].setBorder(border)[/ICODE] cannot be compiled. Please, help me to improve this code. Thanks! [CODE] public void mouseReleased(MouseEvent e) { if (Menu.getgroup()) { Component[] c = getComponents(); Border border = LineBorder.createGrayLineBorder(); for(int i = 0; i < c.length; i++) { … | |
Hi! I would like to create a button for deleting all JLabel components on JDesktopPane. My code is shown below. The error message is shown below the code. For instance, let's say there are 3 JLabel components (the 4th is not JLabel). In this case, only 2 of 3 JLabel … | |
Hi! I would like to make transparent my two JScrollPane components. Could please someone explain me why the code [ICODE] scrollPane1.setOpaque(false); scrollPane2.setOpaque(false); imagePanel.setOpaque(false); beads.setOpaque(false);[/ICODE] does not work? Thanks! [CODE] public SelectablePanel() { beads = new BeadsCollection(NR_OF_BEADS); imagePanel = new ImageSelectionPanel(0, NR_OF_BEADS_SIZE); p = new Point(); JInternalFrame jif = new JInternalFrame("Title", … | |
Hi! Could someone please give me any idea on how to add a background image to JInternalFrame without subclassing. Below I provide a code snippet, but the line [ICODE]jif.setBackgroundImage(backImage);[/ICODE] is incorrect. Please, help me to fix this error. But I don't want to create a subclass, e.g. MyJInternalFrame. Thanks! [CODE] … | |
Hi! I am working on scaling the image that is placed in JLabel. The scaling method itself works more or less fine, however a black border appears around the image after scaling. I tried to make the transparent/white JLabel background, but my attempts failed. Please explain me how could I … | |
Hi! I'm trying to zoom in/out ImageIcon in JLabel. The problem is that after 2-3 zooming actions, the image quality becomes horrible. How could I solve this problem? Thanks! [CODE] private void doZoom(int scaleFactor) { Component[] c = SelectablePanel.getMainPanel().getComponents(); for(int i = 0; i < c.length; i++) { if(c[i] instanceof … | |
Hi! How could I change custom cursor size? I was playing with Point(a,b), however the cursor is always 32x32 and it looks horribly. Below you can see my code snippet. Thanks! [CODE] Toolkit toolkit = Toolkit.getDefaultToolkit(); Image imageCrossCursor = toolkit.getImage(BeadToolbarColor.class.getResource("/icons/cross_cursor.png")); cross_cursor = toolkit.createCustomCursor(imageCrossCursor, new Point(0,0), "Cross cursor"); panel.setCursor(cross_cursor); [/CODE] | |
Hi! I created JToolBar, but it is always attached to JPanel. If I run my api, then I can drag and drop JToolBar in order to separate it from JPanel. I want to programmatically make JToolBar to look as a separate window (e.g. as a toolbar in Photoshop). Does anybody … | |
Hi! There is JPanel with multiple JLabel components. I would like to change the border color of JLabel component that is clicked on. I tried [ICODE]this.getComponentAt(e.getX(), e.getY()).setBorder(solidBorder)[/ICODE], but it did not work... How could I solve this task? | |
Hi! I'm trying to add dragging and dropping behaviour to JLabel. It works only when I press the mouse for the first time. If I continue pressing the mouse, the error message shown below is generated. Please, help me to find an error. [CODE] JLabel bkg = new JLabel(icon); jLayeredPane.add(bkg, … | |
Hi! I would like to zoom in & zoom out an image in JLayeredPane. Now I have a snippet for loading a background image into JLayeredPane. How could I now access ALL content images of JLayeredPane (it could contain multiple images) and zoom them in/out? Perhaps, somebody could send me … | |
Hi! I would like to make a JFrame that will play a role of a toolbar. It can be dragged and dropped within a specified area. So, I don't know how to specify the area for dragging and dropping. Could anybody help me? Thanks! | |
Hi! I'm new to Android OS and all this stuff. So, I tried to develop a HelloAndroid api as it is described [URL="http://developer.android.com/resources/tutorials/hello-world.html"]here[/URL]. However, when I try to Run the HelloAndroid, the error message occurs. It is also strange that by selecting Run->Run, the "Android Application" option does not appear … | |
Hi! My JAVA+MySQL api worked fine yesterday, but today (when I try to connect to MySQL DB from remote machine) the fllowing erro is produced: [ICODE]Java Result: -805306369[/ICODE]. Although there is e.prinstachtrace() in my code, I received only this message. It happens here: [CODE] db = (Connection) DriverManager.getConnection("jdbc:mysql://" + url … | |
Hi! My JTable is populated from remote DB. I would like to set column names from the DB table column "of_shortTitle". However, if I run query "select * from OrgFolders" then column names are taken from "of_title" by default. The table model is given below. How could I set column … | |
Hi! I would like to change the string: [ICODE]"reg_num, reg_date, attached_file, Description"[/ICODE] to the new string: [ICODE]"reg_num, reg_date, Description, attached_file"[/ICODE]. So, what I need is to search the substring "attached_file" and put in at the end of the main string. How could I do that? Thanks! | |
Hi! Could someone tell me please how to configure MySQL DB for storing both latin and cyrillic data sets in the same table? Thanks! | |
Hi! I have a Java application that works with MySQL DB. Until today I used latin alphabet, but now I would like to extend my application to working with cyrillic alphabet. As far as I know, it is possible to use UTF-8. But I don't know the way, in which … | |
Hi! I would like to create textfields that will serve for sorting data in JTable, and the width of these textfields will correspond to a column width. So, below you may see the code that worked until I did not use an array of textfields. Now, the size of [ICODE]txtRegNum[/ICODE] … | |
Hi! When I try to run the code [ICODE]tableModel.setQuery("select l_code, l_title, l_description from Lists");[/ICODE], then I receive the following error: [CODE] java.lang.ArrayIndexOutOfBoundsException: 0 >= 0 at java.util.Vector.elementAt(Vector.java:427) at SystClasses.QueryTableModel.getValueAt(QueryTableModel.java:72) at SystClasses.QueryTableModel.getColumnClass(QueryTableModel.java:53) at javax.swing.table.TableRowSorter.useToString(TableRowSorter.java:224) at javax.swing.DefaultRowSorter.updateUseToString(DefaultRowSorter.java:607) at javax.swing.DefaultRowSorter.sort(DefaultRowSorter.java:556) at javax.swing.DefaultRowSorter.allChanged(DefaultRowSorter.java:816) at javax.swing.DefaultRowSorter.modelStructureChanged(DefaultRowSorter.java:826) at javax.swing.JTable.tableChanged(JTable.java:4364) at javax.swing.table.AbstractTableModel.fireTableChanged(AbstractTableModel.java:280) at SystClasses.QueryTableModel.setQuery(QueryTableModel.java:110) at SystClasses.Form.createAdminTable(Form.java:747) at … | |
Hello! My JTree is filled from DB. If I add a new node, and then try to delete it, then the code shown below provides an error. As I see, selectedFolder is sometimes null. Why does it happen? Why [ICODE]getLastSelectedPathComponent()[/ICODE] doesn't return a node selected, but returns null in some … | |
Hi! I want to delete an empty directory from FTP Server, however my code works only for files. Let's say the root directory in my FTP Server is called as [ICODE]Documents[/ICODE]. I want to delete a directory [ICODE]Director[/ICODE]. Then I execute [ICODE]client.deleteFile("\\" + selectedPath);[/ICODE], where [ICODE]selectedPath[/ICODE] is equal to [ICODE]Documents\Correspondence\Finance\Director[/ICODE]. … | |
Hi! How should I change the TableModel that extends AbstractTableModel to allow displaying empty data sets? Should the getValueAt method be chaged as follows? [CODE] public Object getValueAt(int row, int col) { Object str = ((Object[]) cache.elementAt(row))[col]; if (str != null) return str; else return ""; }[/CODE] ...or something else … | |
Hi! how could I delete all spaces in the string: [ICODE]String str = "AAA BBB CCC";[/ICODE] in order to get "AAABBBCCC" as a result? The following doesn't work: [ICODE]str.replaceAll(" ", "");[/ICODE] Thanks! | |
Hi! Could someone please explain me the difference between the following three approaches to inserting nodes in JTree? I cannot understand why the insertNodeInto method doesn't work in the recursive procedure (Approach Nr1), but it works if it is executed from JButton (Approach Nr2). So, Recursion itself (Approach Nr1) works … | |
Hi! There is JTree component that I want to fill from the database. New nodes can be dynamically added to this tree. I need a procedure that will recursively traverse a tree. My problem is that [B]all nodes are added to the root node[/B], and sub-trees are not created. I've … | |
Hi! I have two classes: 1) Class A extends JPanel 2) Class B extends JFrame I would like to use some methods from Class A in Class B. How could I implement it? Thanks! | |
Hello! I have the problem with my program visualization at different computers (but the same OS). Below you may see some code pieces related to creating the user interface. Everything is ok with this code at my computer. But I cannot understand why it produces different layouts at some other … | |
Hello! I run SQL queries from JAVA program (an example is shown below). My question is: Is it possible to run SQL query, if column names are defined in an array and the array size is not known apriori? Thanks! [CODE] public void setQuery(String query) { try { int rs … | |
How could I empty my JTable (AbstractTableModel)? If I run [ICODE]tableModel.deleteData();[/ICODE], then the message "0 >= 0" appears. Thanks! [CODE]class QueryTableModel extends AbstractTableModel { Vector cache; // will hold String[] objects int colCount; String[] headers; String url; String databasename; String login; String pass; Connection db; static Statement statement; public QueryTableModel(String … | |
Hi! How could I open a file saved on FTP Server? I'm using org.apache.commons.net.ftp.FTPClient to save/delete files. There are only 5 types of files: doc, docx, xls, xlsx, pdf. If I select a pdf file, then it must be opened in Adobe Acrobat, etc. So, what is the best approach … | |
Hi! My code worked correctly, but now it produces the error message. It seems that the command [ICODE]treeModel.reload();[/ICODE] doesn't work anymore. Please explain me what happens? [CODE] private void addOrgFolder() { String[] data = new String[2]; data[0] = text2.getText(); data[1] = text1.getText(); DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode)SystClasses.TreeEditTest.tree1.getLastSelectedPathComponent(); tableModel.setQueryDontChangeTable("insert ..."); DefaultMutableTreeNode nNode … | |
Hi! If I run the code shown below from my local machine, where the FTP server is installed, then everything works correctly. However, if I try to run it from some other machine, then the message "Cannot connect to the FTP server!" appears. Settings of my FTP Server are shown … | |
Hi! How could I create/delete a directory on the remote machine using FTPClient of org.apache.commons.net.ftp.*; ? The code used to save a file on the remote machine is shown below. But I would like to update it for creating/deleting directories. Thanks! [CODE] private void saveAttachedFileToRemoteMachine(String pathToFile, DefaultMutableTreeNode selectedNode) { FTPClient … | |
Hi! I would like to get an advise about the following question. There is a set of text fields. The task is to generate a new JFrame and align text fields based on the information given, i.e. a row and column of each text field. Let's say there is a … | |
Hi! Does anybody know how to group JLabel and JTextField in order to get a single component? Thanks! | |
Hello! I have a JScrollPane with JTable that is filled from MySQL. I'm using SwingWorker to display JScrollPane while reading data from MySQL database. There is no problem with it. My question is how to add a text "Loading..." to JScrollPanel? I just want to display some message in this … | |
Hi! My GUI consists of one main window and it takes 5 seconds before the this window is displayed (after pressing on the "Run" button in Eclipse). I want the window to be displayed at once even though it’s fetching tasks from the service. How could I do that and … | |
How could I synchronise the timer with some process that runs during X seconds. I need the timer to count seconds only if the process is running. If the process is terminated, then the timer must stop. [COLOR="Red"]Most important is that the process execution time is not known apriori.[/COLOR] Otherwise, … | |
Hi! I want to create a stopwatch that will counter seconds starting from 0. This code worked in case of a real time counter (using Calendar). However, now the counter is fixed on 0. Does anybody know what could cause an error? Thanks! [CODE] timer = new javax.swing.Timer(1000, new ActionListener() … | |
Hi! I would like to add a timer to JTextField. However, my timer does not run. Could you, please, tell me what is wrong in my code. Thanks! [CODE] timerTask = new MyTimerTask(); timer.schedule(timerTask, new Date(0), 5000); // 5 seconds delay ... private class MyTimerTask extends TimerTask { @Override public … | |
Hi! Is it possible to dynamically update a text of items in JList? Let's say there is JList defined as follows: [CODE] list1.setModel(new AbstractListModel() { Object[] values = listOfTasks.toArray(); public int getSize() { return values.length; } public Object getElementAt(int i) { return "Task " + i; } }); [/CODE] As … |
The End.