swing

JDialog cancel button

How can I set a cancel button in a Swing JDialog, i.e. a button whose action is performed automatically if the user presses the “Cancel” key on the keyboard? The counterpart is offered for a default action via the setDefaultButton method of the dialog's root pane. If that's helping, I'm searching for an analogue to the WinForms Form.Ca...

Help with Mud Programming in java

Well i decided to make something like a mud and the practices i may use in other places too, but i have one problem.. i don't know how to make it to where a user can type in the actual box instead of a Textfield i'd like to explain better but i can't really think how ...

Swing on Ubuntu font height

Running a Java Swing program on Ubuntu Linux, I'm getting an odd bug where the font height is too large for the actual font size, that is, every piece of text (in menus, buttons, text areas etc.) has excess blank space underneath the text itself. This does not depend on which font I select. It also does not depend on the font size chose...

SwingBuilder: scrollPane

Hi, What's the proper way to set up a scroll pane using groovy's SwingBuilder? I'm using griffon and I'm having a hard time adding and removing components dynamically... Here's a snippet I've tried within SwingPad. It works ok, but the remove only take immediate effect if my scroll pane has scrollbars. If not, it takes 4-5 secs. Here'...

Is JSR 296 (Swing Application Framework) stable enough to use? If not, what are the other options for small Swing apps?

Eclipse RCP and Netbeans Platform are too big for the smaller apps that I work on, but I would still like to use a framework to make my apps more maintainable and consistent. Are there any other small frameworks that would be useful here? ...

disable scrolling to cell in focus

I have a jtable inside of a scrollpane. how can i stop the scrollpane from scrolling up or down when a cell that is partly out of view gains focus? the problem is i am setting the cells to editable when the user mouses over them, so when you mouse over a cell that's partly out of view, the view changes suddenly. I don't like this behavi...

Painting a custom JScrollBar

I want to completely change the look of a scollbar but overriding JScrollBar and the paintComponent method doesn't work, the track and thumb are painted but the left and right arrows stay the same. I am also using them inside a JScrollPane and using setHorizontalScrollBar( new CustomScrollBar() ) to set the scroll bars to my custom scrol...

Adding an Icon to JTable by overriding DefaultTableCellRenderer

I'm trying to add an icon to a particular JTable column by specifying my own table cell renderer as below (based on parts of this tutorial): public class MyTableCellRenderer extends DefaultTableCellRenderer { public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int r...

Java 1.5 Filter JTable

I would like to filter some rows in a JTable but all the stuff google found me is for java 1.6. I would like to do this using java 1.5 since i can not upgrade? ...

How to get a correct visible rect during a validateTree?

First to describe the problem: During a re-layout due to a change in width or height, Java's ScrollPaneLayout requests the preferredSize of it's children BEFORE setting the bounds of it's viewport. On Text-Components calling getPreferredSpan can change the layout since this getPreferredSpan calls setSize internally. The effect is, that n...

Drawing on Java heavyweight swing components

I'm working with an application in which I add a heavyweight (Canvas) to a JFrame. The Canvas is a 3rd party component, so I am required to keep it heavyweight. I'd like to add capabilities for the user to draw on the canvas and paint a selection rectangle. I don't think I can do this with the glass pane since the heavyweight canvas wil...

Passing data from GUI to event dispatch thread in Swing

Hi, I am developing a Swing/Java app but having difficulties passing data from the initiliaser threads to one of the GUIs. The GUI is initialised by invoking an 'initComponents()' method on the event dispatch thread in its run() method: javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { C...

Compare SWT with SWING

Is swt faster than swing? Where can i get good tutorials about swt? it easy to migrate from swing to swt? ...

Programatically closing currently displayed Java Swing JDialog box

Hi there I am working on an Java Swing application that performs a search on a database. It has 2 JDialog boxes that popup during the search. The first tells the user that the search has started and has an OK button to close. The second tells the user that the search has returned and is also closed by hitting the OK button. I there a w...

How do I get a reference to the currently displayed Java Swing JDialog box?

Hi there. I am using a Java Swing based framework that shows popup messages using Java Swing JDialog boxes. I need to get a reference the them so I cam close them programatically. The framework creates dialog boxes but doesn't keep a reference to them. Can I get a reference to the currently displayed box? Thanks. ...

GoogleEarth inside Java Swing

Is it possible to embed a GoogleEarth view inside a Java Swing app? If so, could you please point me to a tutorial explaining how to do it? ...

Can I set a timer on a Java Swing JDialog box to close after a number of milliseconds

Hi is it possible to create a Java Swing JDialog box (or an alternative Swing object type), that I can use to alert the user of a certain event and then automatically close the dialog after a delay; without the user having to close the dialog? ...

Can I modify a Java Swing JTextArea so that it looks like a JPasswordField?

Can I modify a Java Swing JTextArea so that is doesn't display charaters typed? Can I make it display only '*' chars in the same way that a JPasswordField class does? ...

JScrollPane with scroll bar to left

I need to place a scroll bar to the left of the contents in my JScrollPane. Can it be done without a separate JScrollBar component? Perhaps simply by setting some alignment? ...

How to select text in JtextField while tabbing

I have a JDialog with a series of JTextFields on it I would like the text each to be selected when I tab to it. ...