swing

Swing application - resource clean up should be done in windowClosing or windowClosed

In Swing application, I was wondering all the resource cleanup jobs, like : network resource shutdown, stopping thread, closing file handles... Should it be done in windowClosed or windowClosing ? Thanks. ...

JComboBoxes - Using setModel to access Objects (in Swing)

Hi, Quick background, I am using Netbeans to develop this (I don't have much experience with Swing and have lost points on experience at the chance to gain development speed). In Netbeans it is obviously restrictive as to what code you can modify to stop novice users breaking the code (which I have already amusingly done once) Anyway, I...

Pop SWT/JFace-based dialogs in front of Swing-based JFrame

I have an application that starts out as an Eclipse RCP application and then fires up a JFace ApplicationWindow, complete with a simple menu, toolbar, display widgets, etc. This second application window includes some model dialogs (extended from JFace Dialog and TitleAreaDialog) from the action classes. This second application window ...

Composite pattern in Swing

This is basically a architectural question. I want to implement composite pattern in handling Swing components; that is, I want to combine several components with their listeners and logic behind a single component for easier handling. Consider for example a simple directory browser; say, a JTree in JScrollPane with some logic which ha...

Java Swing: component that resizes itself but doesn't influence the layout

I'll try to explain my problem as simply as possible but it's a tricky topic and people who haven't encountered the issue probably won't know what I'm talking about. I want to use a BorderLayout using west, east, north, south, etc. components that are my "normal" components (JLabels, JButtons, etc.) then I want the center component to b...

How does Java dispatch KeyEvents?

I've read the definite tutorial on key bindings a few times, but my brain cache doesn't seem large enough to hold the complicated processes. I was debugging a key binding problem (turned out I was using the wrong JComponent.WHEN_* condition), and I stumbled upon a concise and hilarious javadoc for the package private javax.swing.Keyboar...

expand collapse JeditorPane

I am creating a XMl editor. I want the JeditorPane to have expand collapse feature accoring to nodes.. If anybody is having any idea how to do it please tell... ...

jsplitpane in netbeans

Hi, I am trying to use a JSplitPane in Netbeans 6.9.1, but I can not configure it properly for some reason. E.g. I add a jtree and a jtable in a jframe. Then I use "enclose in splitpane". Then I set the orientation to vertical (from horizontal). Problem, when I try to adjust the divider location, I can not place it where I want. Either ...

JTree view under High Contrast Mode

Hi, I have one issue related to JTree swing component, I want to use JTree under Windows high contrast Mode, but it never shows tree nodes according to windows High contrast theme. Jtree view Under Normal Mode Jtree view Under High Contrast Mode Eclipse Package Explorer view Under Normal Mode Eclipse Package Explorer view Un...

Making Grids for a Java Battleship game

I'm having a little trouble building the grids for a Battleship game for my Java class. So far, I can easily make a for loop to add JPanel or JButton objects to the JFrame. However, my issue is that I'll need to use those Panels or Buttons again when playing the game (such as clicking on a button to see if your opponent put a ship on tha...

Help regarding java swing/GridBagLaytout

Hi all, I'm currently trying to implement a Swing/GUI that could be regarded as a RDF editor. For each property , I can add/remove one ore more widgets storing the values (JTextField, JScrollPane+JTextArea, JCombo, etc.... ). I've been trying to use the GridBagLayout to put the Components in place but I can get any good result. Any ...

java: is the default document of a JTextField always a PlainDocument?

Is this always true? new JTextField().getDocument() instanceof PlainDocument Because I have read many examples of PlainDocument where they always create a new PlainDocument and then assign it to a JTextField, e.g. here. ...

JSpinner Value change Events

How to make the update immediately when the jSpinner value was changed. ChangeListener listener = new ChangeListener() { public void stateChanged(ChangeEvent e) { jLabel.setText(e.getSource()); } }; spinner1.addChangeListener(listener); The code above doesnt change the label text automatically, it required you to click again ...

CubicCurve2D connecting two JInternalFrame instances

I have been trying to find a way (in Swing) to connect two JInternalFrames with a CubicCurve2D (otherwise known as a cubic bezier curve). The overall effect I'm trying to achive is an interface similar to Yahoo! Pipes (the curve should go from the bottom of one internal frame to the top of the other). Has anybody here done this before? ...

Override JTextArea.getDocument.remove()?

Okay, I want to override JTextArea's Document's remove method, I can't figure out what class to extend. I can't extend Document cause it's a interface, and that also means it must not be the document that JTextArea creates. So how exactly can I easily override my JTextArea's document's remove method? ...

Is there a framework for dynamically generating a Swing GUI from a Pojo in Runtime?

My problem is, that I have simple Pojos or simply objects that contain data. These can vary and new types of these can be added during runtime. So I need a Swing GUI to input text to them. Is there a framework that dynamically creates a Swing GUI from a POJO during runtime? Technically, it should be possible using reflection and/or ann...

Develop java desktop app for learning purpose?

Hi I been learning java swing programming lately and I am thinking of building a java swing app myself. But however I can't really think of any app that is worth building as a desktop app rather than a web app. Anyone have any suggestion on desktop app that I can develop for learning purpose? ...

Swing modal dialog refuses to close - sometimes!

// This is supposed to show a modal dialog and then hide it again. In practice, // this works about 75% of the time, and the other 25% of the time, the dialog // stays visible. // This is on Ubuntu 10.10, running: // OpenJDK Runtime Environment (IcedTea6 1.9) (6b20-1.9-0ubuntu1) // This always prints // setVisible(true) about to happen ...

Look and feel in java

I am developing an desktop application for my personal use. I use Java as programming language and I use Swing to develop GUI. I need some beautiful look and feel. How can I do it in Java or with any 3rd party API? ...

Problem with updating the jTextArea

I am writing a RMI chat program. In my program I am able to receive and send messages, but i am not able to display it in the TextArea. I am not sure what is the error. I tried using Event Dispatch method also. It doesn't help. public class client extends javax.swing.JFrame implements inter { public client() { initComponents(); } ...