swing

Listen to JFrame resize events as the user drags their mouse?

When a user clicks on the corner of a JFrame to resize and drags the mouse around, the JFrame redraws based on the current position of the mouse as the user drags. How can you listen to these events? Below is the what I have currently tried: public final class TestFrame extends JFrame { public TestFrame() { this.addComponen...

JTree with left and right-aligned text in cells?

What I'm trying to do is create a JTree with each cell containing normal text but also containing a right-aligned text for each cell (right-aligned to the edge of the tree, regardless of the hierarchy level). I've tried creating my own TreeCellRenderer, but the cells' sizes are not being updated. I also tried this idea with a custom tre...

how to access jtextarea from one jframe to other jframe.

i m having 2 jframes.in 1 jframes,i am giving input in jtextarea,that should be displayed in another jframe jtextarea.how can i get that. i m using netbeans,i have designed jframes using swing. can anyone help me. ...

Swings to EJB communication without RMI port

I have swing based web application. Currently, the Swing clients communicates to EJB which is running in remote server through third party 'HTTP Tunneling' tool (JProxy). This is commercial tool. my question is: Is there any other open source / free 'HTTP Tunneling' tools equivalent to JProxy using which the Swing clients can communic...

Display Table Titles with a Table Model in Java Swing

I would like to create a table with the constructor method JTable(TableModel). What exact methods in the TableModel do I need to display the titles of each column? ...

How to add objects to a already instantiated JList in Java?

I want to add objects to a JList which has already been instantiated by the Netbeans genrated code. I can't pass my own list model in the JList constructor as I can't modify the Netbeans generated code. How can I add object to that JList. ...

How to set the ListModel of a JList in Netbeans?

I have designed a Swing GUI with the help of Netbeans IDE and this GUI contains a JList. Bydefault, it uses AbstractListModel to pass it as an argument in the JList contructor to create that JList. I want to specify somewhere in the Netbeans to pass DefaultListModel as the model to be passed in that JList so that later I can retrieve i...

How to transfer the elements from one JList to other JList in Java?

I have two JList on a swing GUI. Now I want that when a user clicks on a button (say TransferButton) the selected elements from one JList is added from the first JList to the second JList and remove those selected elements from the first JList. ...

Java Swing query

hi, I have a Swing Panel where I search for a text and highlight it using yellow color.Its size is 1/4th of the screen(not sure of exact dimensions).When I search soemthing the first active search is highlighted and shown and whenever I maxmize the screen to full size the highlighted text is not visible.Now is there a way to keep the h...

JButton with HTML named action and a mnemonic

Hi all, I have a JButton that is constructed using an Action and this action has a name that is contains html. I then go about setting the mnemonic on the JButton by first parsing out html to get the first character in the name. For example, the JButton name might be "<html>Test<br>Button</html>", so after parsing the html the mnemoni...

Java Swing Font Chooser

In my Java Swing application I want to allow the user to pick their font. To my surprise there is no core swing library to pick fonts. I expected to find a JFileChooser but there is no such utility. This seems like a simple dialog that I'm sure exists out there. I do not really want to write it myself. I looked around on the internet an...

Controlling Color in Java Tabbed Pane.

I have been going nuts trying to figure this out. I am trying to elimenate a light blue background that appears in a JTabbedPane. I've tried everything and nothing seems to work. Below is my code. If you run it, it will show the tab, when selected with a light blue background and a thing blue border at the top. I want to control ...

How to transfer Netbeans Project into Eclipse?

I have been using Netbeans for my java desktop application since few months. Now in the middle of the project, I want to switch over to Eclipse as the Netbeans once corrupted my GUI and I had to re-create several parts of the GUI and now it is displaying a compiler error as code too large private void initComponents() { 1 error "code...

How to refactor Netbeans generated GUI code?

I had created a GUI in Netbeans through Netbeans Swing GUI creator. So I just dragged and dropped the Swing Components from the "palette" window and all the code was generated by netbeans. Now the code is too long to maintain (approx. 10,000 lines). So some experts on SO suggested me to refactor my code. I can refactor the code that wa...

Confusion between whether a code should be executed by EDT (Event Dispatch Thread) or not?

I had developed a Swing GUI which contains 12 JPanels. Initially, all the JPanels code was written in the main JFrame class code. As a result, the code became too long (10,000+ lines). Now I want to refactor the code to break the code into 13 classes (12 classes each for one JPanel and 1 class for the main JFrame)instead of 1 class carr...

Java Swing JTable cell in "edit" mode uses different set of settings?

I have set some parameters for my JTable, but it seems they are in effect only in what I call "view" mode. When editing cell content, nothing works. In the screenshot below you can see how the font size reverted back to default. (Large one is what I set and what I want to see). Also, I have default Locale set to Germany so that my de...

Javax.swing timer repeats fine, but ActionListener doesn't do anything.

I am trying to flash the background colour in a textfield. My timer setup is as follows: Flash flash = new Flash(); //set up timer tmr = new javax.swing.Timer(1000, new Flash()); tmr.addActionListener(flash); tmr.setInitialDelay(0); tmr.setRepeats(true); tmr.start(); My actionListener is as...

Small problem while using JOptionPane.

I'm using JOptionPane.showMessageDialog(null,e,"Invalid Name",JOptionPane.ERROR_MESSAGE) method to display the exception extended from Exception class. But the Pop window is not getting displayed unless and until I press Alt+tab. What can be the reason? Below is the snippet. Suggest me something. import java.awt.event.*; import java.awt...

Populating Empty Tables in Java Swing

I would like to have a JFrame window with an initial empty table of say, 10 columns. An action event generated by a mouse click should then populate the table with a list of 10 or less items, the leaving the used rows of the table empty. How should this be done? ...

Java Swing architecture problem?

Till now, I have developed simple swing applications so there was no need to break the GUI code into diff. classes but as this application is going to be very large, I decided to break the code into diff. classes so as to make the code more manageable. But before proceeding, I have some doubts in my mind which are as follows: Brief des...