swing

Why does GC not clear the Dialog references?

I have a dialog. Every time I create it and then dispose, it stays in memory. It seems to be a memory leak somewhere, but I can't figure it out. Do you have any ideas? See the screenshot of heap dump for more information. Thanks in advance. http://img441.imageshack.us/img441/5764/leak.png ...

How to center elements in the BoxLayout using center of the element?

I use outputPanel.setLayout(new BoxLayout(outputPanel, BoxLayout.Y_AXIS)); and then I add elements (for example JLabels, JButtons) to the outputPanel. For example: outputPanel.add(submitButton);. I see that all added elements are "centered". It is good, because I do want my elements to be in the center. When I write "center" I mean "equ...

Error in loading component property (Swing GUI Forms)

For no apparent reason all my Swing GUI forms using components linked to org.jdesktop.beansbinding.Converter started generating errors when trying to open the Design View: Error Error in loading component property: [JPanel]->filterTextField->converter. Cannot load property type class org.jdesktop.beansbinding.Converter. The property can...

How can I set distance between elements ordered vertically?

I have code like that: JPanel myPanel = new JPanel(); myPanel.setLayout(new BoxLayout(myPanel, BoxLayout.Y_AXIS)); JButton button = new JButton("My Button"); JLabel label = new JLabel("My label!!!!!!!!!!!"); myPanel.add(button); myPanel.add(label); In this way I get elements with no distance between them. I m...

Use case of Glass Pane vs. Layered Pane

I've always been a little fuzzy on the difference between the glass pane and a layered pane. Is the glass pane essentially just "the very top layer of the root pane," or does it behave differently? When would you use a layered pane instead of the glass pane? ...

Netbeans GUI editor generating its own incomprehensible code.

When creating a new project in netbeans, if i select JAVA Desktop application, it creates some code which I DO NOT RECOGNISE AT ALL as what i had learnt in swing. It imports packages such as : org.jdesktop.application.SingleFrameApplication; also, the declaration for main() looks like this : public static void main(String[] args) { ...

Placing component on Glass Pane

I have a subclass of JLabel that forms a component of my GUI. I have implemented the ability to drag and drop the component from one container to another, but without any visual effects. I want to have this JLabel follow the cursor during the drag of the item from one container to another. I figured that I could just create a glass pa...

how to reuse the area in a container when any component is removed from it?

hi! i hav a panel and i m trying to remove labels from it which were added to it during run-time. but when labels are removed succesfully i m not able to use the space,left by that label,again to add any label to it. thanks in anticipation of the solution. here is the relevant code snippet: to add label to the panel: JLabel jl = new...

what's the difference between DEFAULT_SIZE and PREFERRED_SIZE?

hi, I'm using Swing GroupLayout and I'm confused about the values GroupLayout.DEFAULT_SIZE and GroupLayout.PREFERRED_SIZE. I never know when to use each one of them in methods like GroupLayout.addComponent(Component, int, int, int). suppose I have this code: GroupLayout l = ...; l.setHorizontalGroup(l.createSequentialGroup() .add...

Need better Java application deployment strategy

I have various Java Swing applications that are used by multiple users. My deployment strategy is to locate the .jar file on a network share, and users create shortcuts to that file. When the user launches an application, the file is copied to their machine and executed locally. This method allows for a single copy of the code and easy u...

Java's Swing Threading

My understanding is that if I start up another thread to perform some actions, I would need to SwingUtilities.invokeAndWait or SwingUtilities.invokeLater to update the GUI while I'm in said thread. Please correct me if I'm wrong. What I'm trying to accomplish is relatively straightforward: when the user clicks submit, I want to (before ...

Java JPanel not showing up....

I'm not sure what I am doing wrong, but the text for my JPanels is not showing up. I just get the question number text, but the question is not showing up. Any ideas what I am doing wrong? import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; class NewFrame extends JFrame { JPanel centerpanel...

Regular Expression, JEditorPane, Self-closing tags

I'm am using JEditorPane to render basic HTML. But it renders self-closing tags incorrectly, specifically br tags, e.g. <br /> is bad but <br> is good. I would like to use String.replaceAll(regex, "<br>") to fix the HTML, where regex is a regular expression matching any self-closing br tag with case-insensitivity and zero to infinity n...

How can I put a horizontal line between vertically ordered elements?

I have a set of vertically ordered elements. They are displayed with the following code: JPanel myPanel = new JPanel(); myPanel.setLayout(new BoxLayout(myPanel, BoxLayout.Y_AXIS)); JButton button = new JButton("My Button"); JLabel label = new JLabel("My label!!!!!!!!!!!"); myPanel.add(button); myPanel.add(label); I would like to put a...

With the introduction of the HTML5 <canvas> element, could Swing be implemented in GWT?

With the introduction of the HTML5 <canvas> element, could Swing theoretically be implemented in Google Web Toolkit (GWT) by using the <canvas> tag for drawing? I'm aware of efforts to port source code from using Swing calls to GWT calls, but what I'm after is a pure behind the scenes port where a Swing application would compile under G...

With Java Swing App, how to get values from a dialog panel into the main app ?

In my Swing app, users can click a button to open a dialog panel and enter some values, then they can click "Ok" on that panel to close it and return to the main program, but how can I pass the values they enter to the main program without saving them to a file first ? ...

Which containers / graphics components to use in a simple Java Swing game?

I'm creating a simple labyrinth game with Java + Swing. The game draws a randomized labyrinth on the screen, places a figure in the middle, and the player is then supposed to find the way out by moving the figure with arrow-keys. As for now, I'm using a plain background and drawing the walls of the labyrinth with Graphics.drawLine(). I h...

Swing- focus problem

Hi, In my application I have a frame, with toolbar (the toolbar contains some actions). I want the toolbar to be visible only when the window is focused. So, I registered a windowFocusListener on the window. The problem is- when the window is not focused and I click on the place where a tool bar action should be- the action is performed...

Java Swing: how do I define how a JTree displays the "user object"?

Hello, everyone! When using a JTree, a "user object" of a DefaultMutableTreeNode can be set. This can be of any kind, but to display it, its toString() value is used. This is not what I need. How can I change the way a user object is displayed? NOTE: My user object has to be something different than a String to be able to maintain map...

Unit testing framework for a Swing UI

Testing UI is difficult. What do you think is the best unit testing framework for Swing? ...