swing

What component should I use to draw a dendrogram in Java?

Dendrogram is not a regular diagram. Should I use any component from javax.swing.* library, or just draw it with java.awt.Graphics? ...

Modifying graphics context in Java

I have a form that tries to modify a JComponent's graphics context. I use, for example, ((Graphics2D) target.getGraphics()).setStroke(new BasicStroke(5)); Now, immediately after I set the value and close the form, the change is not visible. Am I not allowed to modify a JComponent's graphics context? How else would I modify the stroke,...

How to disable (or hide) the close (x) button on a JFrame?

I have a window (derived from JFrame) and I want to disable the close button during certain operations which are not interruptible. I know I can make the button not do anything (or call a handler in a WindowListener) by calling setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); but I would like to make it clear visually that it is...

How to use JProgressBar?

I need to load a bunch of words (about 70,000) from a text file, add it to a hashtable (using soundex as a key) and sort the values. While doing all these I want to show a progress bar using JProgressBar. Articles such as this and this, only gives a non-real example (a while loop). Can anyone suggest me how should I proceed. How can I ge...

Problems using Graphics with Panels in the Java Swing Library

Hey everyone, I am trying to run the following program, but am getting a NullPointerException. I am new to the Java swing library so I could be doing something very dumb. Either way here are my two classes I am just playing around for now and all i want to do is draw a damn circle (ill want to draw a gallow, with a hangman on it in the e...

Jlabel HTML formatting

I have a JLabel which has an e-mail address in it. I used HTML formatting on the JLabel, so it appears as a link. However, you are not able to click the link. In fact, you cannot select any of the text in the label. Is there a property that I can set on the JLabel to allow the user to at least select the text of the e-mail, and preferabl...

What is the rationale of SwingWorker?

For what I can read, it is used to dispatch a new thread in a swing app to perform some "background" work, but what's the benefit from using this rather than a "normal" thread? Is not the same using a new Thread and when it finish invoke some GUI method using SwingUtilities.invokeLater?... What am I missing here? http://en.wikipedia....

Java actionListener for a nameless JButton?

Hey everyone, I was wondering if there is a way to implement an action listener for a Jbutton without a name. For example, I have the following for loop that creates a button for each letter of the alphabet. for (int i = 65; i < 91; i++){ alphabetPanel.add(new JButton("<html><center>" + (char)i)); } Is there a way that I can add...

How to browse for a file in java swing library?

Hey everyone, I was wondering if there was some kind of J tool in the java swing library that opens up a file browser window and allows a user to choose a file. then the ouput of the file would be the absolute path of the chosen file. Thanks in advance, Tomek ...

How do I control the display of a JComponent's Tooltip?

I have a JComponent that's painting various shapes on itself. I'm detecting whenever the mouse enters one of these shapes and changing the tooltip accordingly. The problems I'm having are: The tooltip doesn't follow the mouse as the user tracks the mouse across the shape. It stays where it was first set and then only jumps whenever ...

How do you add an ActionListener onto a JButton in Java

private JButton jBtnDrawCircle = new JButton("Circle"); private JButton jBtnDrawSquare = new JButton("Square"); private JButton jBtnDrawTriangle = new JButton("Triangle"); private JButton jBtnSelection = new JButton("Selection"); I would like to add action listeners to these buttons, so from a main method I can call actionperformed on ...

Accessing a "nameless" Jbutton in an anonymous class from another anonymous class?

Hey all, alright I know this sounds a little far-fetched, but let me explain. I created 26 JButtons in an anonymous actionListener labeled as each letter of the alphabet. for (int i = 65; i < 91; i++){ final char c = (char)i; final JButton button = new JButton("" + c); alphabetPanel.add(button); butt...

Remoting from a Swing app to GWT server

To put it simple, I've written a JSE Swing app that needs to talk to a GWT server I've written earlier. I absolutely love the way GWT does remoting between it's javascript and server sides and wish I could utilize this mechanism. Has anyone managed to use GWT-RPC this way? Should I just go Restlet instead? ...

Java KeyListener for JFrame is being unresponsive?

Hey all, I am trying to implement a KeyListener into my JFrame. I have used the following code (at the moment im just trying to get this to work with my JFrame). System.out.println("test"); addKeyListener(new KeyListener() { public void keyPressed(KeyEvent e) { System.out.println( "tester"); } ...

Sliding Notification bar in java (a la Firefox)

I would like to implement a sliding notification bar as the one in Firefox or IE for my java application. But I don't want to reinvent the wheel and I'm sure someone out there has already done it and is willing to share. Do you know any open-source implementation of this in java/swing? ...

Java Swing - Using JScrollPane and Having it scroll back to top

I'm using JScrollPane to allow scrolling in a JFrame that has a text component that's serving as a text editor. What I want to do, after setting the text in this editor, is have it scroll back up to the top, so you can see what's at the beginning of the file. Does anyone know how to do this? ...

Populate JTable from a Hashtable in Java

I have a function which gets a key from the user and generates a Hashtable (on a pattern specified by the key). After creating a Hashtable, I would like to populate a JTable so that each each column represents a key and every rows represents the values associated with the key. I tried everything but couldn't get this work. I'm not creati...

Embedding web browser window in Java

Does anyone know a way to open up an instance of the platform's (Windows/Linux/Mac) browser within a Swing window that is integrated into a Java application. No other actions would be preformed other than opening a given URL. Currently, we open a new browser window because the Java embedded browsers have been insufficient. However, from ...

Where is groovy.swing.factory.BindProxyFactory?

When trying to use GraphicsBuilder, I get a java.lang.NoClassDefFoundError for groovy.swing.factory.BindProxyFactory. This is my environment: % java -version java version "1.6.0_10" Java(TM) SE Runtime Environment (build 1.6.0_10-b33) Java HotSpot(TM) Server VM (build 11.0-b15, mixed mode) % groovy --version Groovy Version: 1.5.7 JVM: ...

Adding rows to a JTable

We have a simple project where we read data from a socket and we want to populate a table with the coming data, but we can't find a way to add rows to a yet created JTable object, we can only find how to add rows at creation time of the table. Is it possible to add rows dynamically to a JTable, or there is a better alternative object to...