swing

JDK-7 SwingWorker deadlocks?

I have a small image processing application which does multiple things at once using SwingWorker. However, if I run the following code (oversimplified excerpt), it just hangs on JDK 7 b70 (windows) but works in 6u16. It starts a new worker within another worker and waits for its result (the real app runs multiple sub-workers and waits fo...

How to wait until JComponent is fully painted?

I need a way to wait until a (Swing) JComponent is fully painted. This actual problem arises from an openmap application: The task is to draw a map (mapBean) with a couple of layers and create an image from that map. Unfortunatly, and it's clearly documented, the image formatter takes the current state from the map to create the picture...

Programmatically close a JDialog

Is there a way to close a JDialog through code such that the Window event listeners will still be notified? I've tried just setting visible to false and disposing, but neither seem to do it. thanks, Jeff ...

JMenuItem setMinimumSize doesn't work

I try to set a minimum width for my menu items, but it doesn't seem to work. Here is my function, which creates the items: private JMenuItem newItem(String text, String iconPath) { JMenuItem myMenuItem; if (iconPath == null || iconPath.isEmpty()) { myMenuItem = new JMenuItem(text); } else { ImageIcon icon = new ImageIcon(...

Java Swing Free Memory component needed

I need Java Swing Free Memory component (similar to that in Eclipse IDE). Preferably free (and open source). Thank you in advance. ...

Override JComboBox Default Colors

I'm trying to override the defaults colors used by JComboBox when the L & F is Metal. I have overridden the following in UIManager to custom colors; ComboBox.font ComboBox.selectionBackground ComboBox.buttonShadow ComboBox.buttonHighlight ComboBox.disabledBackground and control controlDkShadow controlHighlight controlLtHighlight c...

Can I use ObjectChangeListener to listen for changes on any object?

I've got an Integer called x; if it changes then i would like to update my table in a GUI. To listen to "x" I have tried ChangeEvent y = new javax.swing.event.ChangeEvent(x); and I implement javax.naming.event.ObjectChangeListener: class HDIManagementView extends FrameView implements ObjectChangeListener, ActionListener, T...

Netbeans JTree Linestyle

I'm having difficulties removing the "lineStyle" lines in JTrees using Netbeans. In a standalone program, I'm able to do this: JTree myJTree = new JTree(); myJTree.putClientProperty("JTree.lineStyle", "None"); JScrollPanel myScrollPanel = new JScrollPanel(); myScrollPanel.setViewportView(myJTree); But when I try addi...

Convert JPanel to image

Is there a way to convert a JPanel (that has not yet been displayed) to a BufferedImage? thanks, Jeff ...

How to create a horizontal scrollbar which will scrolls automatically after some time interval

Hi I want horizontal scrollbar which will scroll from left to right automatically after each 1 second. Thanks Sunil Kumar Sahoo ...

jtextfield default cursor position

I'm working with JTextField and the code for the text field. I'm trying to make a textfield as big as the notepad but the cursor always appears in the middle. I want to put in the starting of the textfield. tf=new JTextField(50); tf.setCaretPosition(0); f.setLayout(new BorderLayout()); f.add(tf,BorderLayout.CENTER); ...

Global context menu for Cut/Copy/Paste with JTextField in Swing App?

What is the best way to implement a global default context menu for a Swing app that has the Windows-standard cut/copy/paste/etc. popup menu for things like JTextField? Tim Boudreau suggested installing a custom UI delegate in this javalobby thread but that was written with Java 5 in mind, so I'm wondering if there's a better way today. ...

JMenuItem.getRootPane() workaround ?

It seems to be well-known there is a bug when using JMenuItem.getRootPane(). I read the bug description but i cannot figure out a workaround. Do you know work-around code for this in an Action.actionPerformed() method ? Thank you. Update: I get this now but that don't work with sub-menus :-( public void actionPerformed(ActionEvent e)...

jbutton.doClick() clicks the buttons but does not perform the function

I have a jbutton which performs a function when clicked on by mouse. For doing this programatically I have this other function void clickButton(){ backButton.doClick(); } When I run the clickButton() function I can see the backButton being pressed on the jFrame but the function associated with backButton does not happen. When I...

How to create a horizontal slider

How would I create a horizontal slider which will slide from left to right automatically after each 1 second. ...

JFrame Menu get hidden

When adding my canvas in JFrame Menu, why my menu always hide behind my canvas? canvas = new MyCanvas(); canvas.setBackground(Color.lightGray); contain.add(canvas, BorderLayout.CENTER); ...

Matisse or Jigloo ?

We have a dilema; developing desktop application using matisse or jigloo.. Matisse has this XML form files which we are affraid of maintaining later, we don't even know should MyEclipse further support Matisse, even Netbeans - do you think they will give up os support of Matisse? Moreless Jigloo and Matisse have similar behaviour, alt...

How can I change the text that is actually displayed by a JTextArea?

Hi. Does anyone know if there is a JTextArea method that I can override to change what is displayed on screen? I want to keep the contents of the field the same. Ie. If I set the text to "hello" and I call getText(), I wan't it to return "hello". However, I wan't to be able to override what is displayed on screen (Eg. to replace with '...

Log4J Swing Appender

I need to append log4j content to a Swing component (JTextArea or similar). Is there a common way to do this? ...

JTree selection

I have a JTree which is 5 level deep, 0, 1, 2, 3, 4 levels. I am interested in level 1's informaton, value or index. is it possible to immediately get level 1' information whenever the selection is below level 1? ...