swing

Troubleshooting: JDialog which is modal and yet not modal?

Stumped by this, but maybe, just maybe, someone has had this problem before and can point me in the right direction... I have a JDialog for displaying the progress of a long-running task, which I have expressly created as modal with a defined owner: progressDialog = new JDialog( ((Dialog)windowParent), true ); ... progressDialog....

How to convert a Swing Application to an Applet?

I created a desktop application with Swing Application Framework, now how can I convert it to an applet? The main class extends SingleFrameApplication. EDITED: This is the starting class, used NetBeans GUI builder: public class PhotoApp extends SingleFrameApplication { /** * At startup create and show the main frame of the ap...

Clojure GUI calculator problem. "-" always returns 0 and "/" always returns 1.

I'm well aware this code is horrible. I just made it so I could try out different Swing stuff. This is an interesting problem. This creates 4 buttons one for adding, subtracting, dividing and multiplying. Multiplying and adding works perfectly, no problems at all, but when the user tries to subtract it always returns 0. When the user tri...

Java Swing Combobox with Autocomplet and Context Menu

Hi, I have auto complete for a JCombobox working by following this article: http://today.java.net/pub/a/today/2007/07/19/adding-auto-completion-to-swing-comboboxes.html I am using the SwingX library. Now I like to add persistence support to the items in the combo box. Basically when you right click an item a context menu comes up and...

Is there any good and free Date AND Time Picker available for Java Swing?

Is there any good and free Date AND Time Picker available for Java Swing? There are a lot date pickers available but no date AND time picker. This is the closest I came across so far: Looking for a date AND time picker Anybody? ...

Ensuring that a JButton can fit a String of a given length

Let's say I have a JButton, and I want it to be big enough to fit a string of 8 "M" characters, regardless of the string that is actually assigned to it and the font size, without using elipsis. The JButton has to have precisely this size, no more, no less. Layout manager in use is GridBagLayout. I tried overwriting the getPreferredSi...

How can I have a download file option in JAVA Swing?

Hi, I am new to Swing and wish to implement the download file feature in my Swing code, that would allow the user to either save or open the specific file. I did have a look at JFileChooser.showOpenDialog and showSaveDialog, but I don't wish to use it, as it gives me the option to choose any file from the file system. Hope my problem ...

Java Swing ActionMap keys

I'm coming up the learning curve for Swing and am reading about InputMap and ActionMap. The O'Reilly book on Swing says the keys for ActionMap can be any Object, but by convention are Strings. Is there any reason to use an object other than a String? (e.g. an enum) I would think it's bad practice to use String literals, as they can be ...

JFrame title repaint

In my JFrame it loops to do some task, I want to see the status in the JFrame title, so I have something like this : frame.setTitle("Current status [ "+Auto_Count_Id+"/"+Auto_Count_Total+" ]"); But it's not repainting as I need it to. So I tried the following : <1> SwingUtilities.invokeLater(new Runnable() { public v...

Can there be more than one AWT event queue?

I've got a thread dump of an applet running on JVM 1.6.0_12 in Opera 9.64 Build 10487 - and it shows three event queues! As far as I know the Java Swing event handling is single threaded - did this change in any recent update? My problem is, that multiple event queues will tend to cause deadlocks since I've got some more locks than only...

Display CMD output in my GUI (java)

How might I get the output from a CMD process to display in my GUI? This is the code I'm using to run the process: try { String line; Process p = Runtime.getRuntime().exec("cmd /c \"e:\\folder\\someCommands.cmd\""); BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream())); while (...

Java Event Binding

Hello, I'm new in windows application development using java. The question is this "How to i bind events to custom class methods? As fas i have seen i can register listener classes to swing components to handle events. That is OK but i have to implement a class that implements e.g. the ActionListener interface to handle an event and t...

Image comes up as just a grey square when added to JPanel

Hi I'm working on a project for university which is essentially a re-working of the Space Invaders game with the rules changed a bit. So far I've got a main JFrame, containing a subclass of JPanel (for the background image) which contains another subclass of JPanel which I'm using for the sprites. However, when I run it the JFrame and t...

Swing component flickering when updated a lot

Hi, I've got a couple thousand lines of code somewhere and I've noticed that my JTextPane flickers when I update it too much.. I wrote a simplified version here: import java.awt.*; import javax.swing.*; public class Test { static JFrame f; static JTextPane a; static final String NL = "\n"; public static void main(Strin...

Refresh JPanel

I need to display different drawings on a JPanel. I have put the drawing files into an array, but when I changed it using a button, the JPanel only displays first drawing and doesn't change to the next drawing... I have called panel.revalidate(), but it doesnt work. This is the segment of the code that I used but not working. The JPan...

Of Swing and AWT, why is one considered light-weight and the other heavy-weight?

Why is it said that Swings is heavy-weight and AWT is light-weight in JAVA? ...

I need to represent allocation of 100% of some resource between 3 owners in GUI - any recommendations?

For 2 owners the answer is easy - use a slider with one owner on the left, the other on the right, and slide to control the percentage of each. How do I do it with 3 or more owners? Specifically I'm talking about JAVA Swing-based GUI, but am mainly looking for the design idea. Thanks! ...

All keys to a list, for example VK_A..Z for user to select

Hello All, I am making a program that allows user to custom keyboard shortcuts, for this i need the available keys to be displayed, what is the best way to achieve this in java swing? KeyEvent.class.getDeclaredFields() I am intrested in dynamic example of below, keysLST.setModel(new javax.swing.DefaultComboBoxModel(new String[]...

ActionListener problem

I have a problem with my actionListener. It seems that the actionListener runs automatically before I click the button? The "This should not appear in the console before button click" appear in the console before I click the button".... This is strange. .... button1.addActionListener(this); button2.addActionListener(this); .... public...

Is Component.getGraphicsConfiguration thread safe?

There are many methods you shouldn't call if you are not on the AWT event thread. These are generally methods that manipulate the UI in some way. Is this the case with Component's getGraphicsConfiguration(...)? It is only a getter but it appears to cause a deadlock if the event thread is waiting on the thread calling this method. Whi...