swing

Java this.dispose not closing window when called.

Hello. I am writing a program from class, and I am attempting to have it set up so a window is created which shows search results in the form of buttons. I would like it if there are no search results, that the window would call a pop-up warning stating such and then just close the window. I have it setup that whenever I want to mak...

Best way to build Java Swing GUI?

Till now, I had been using Netbeans Swing GUI generation feature to build GUI for my java applications. Now I have started using Eclipse for my projects and have dropped Netbeans. So apart from coding manually all the code for GUI, what are the other ways with which I can build GUI quickly and in a much better way. ...

JDialog window controls component orientation (right-to-left)

Hi I have a question about mirroring the JDialog window controls (ie the close sign 'X', the title and so on) When I apply the right-to-left component orientation for a JDialog, it flips everything within apart from the window controls. I initially thought this is to do with the JRE I was using and the operating system regional languag...

How to add popup component in JTextField

Hi,I want to add component into JTextField as a popup like this. i want to add my component for example JPanel... ...

Java Swing GoogleMaps geoposition from zip code

Hi folks, I found the JXMapKit from SwingLabs and think I am going to use it. My problem now is that I have data referencing the point via the zip code (I don't need more accurat). I know that with the JavaScript API from Google it is possible to find out the geoposition from an address... My question now is: does this work with Java Sw...

Changing JRadioButton Icon on Windows 7

Hi I created a method which changes the icon of all jradiobuttons from a buttongroup: public void setRadioButtonIcons(final ButtonGroup gruppe){ Enumeration<AbstractButton> gruppeEnum = gruppe.getElements(); while (gruppeEnum.hasMoreElements()){ AbstractButton radio = gruppeEnum.nextElement(); Icon unselI...

Custom Java splash screen "freezes" until the whole application has loaded

I have a program that takes a long time to load. Because of this I wanted to develop a splash screen that can provide feedback to the user on what is being loaded. A simple JFrame with an image, label and JProgressBar. I have been experimenting and the best results I've had are doing this in my main(): SwingUtilities.invokeAndWait(new ...

How to set style of the text about to be typed in a JTextPane

I have a JTextPane and I am able to modify the style of a portion of text within it. Assuming that nothing in the JTextPane is selected, I would like to be able to modify the style of a portion that is not yet in it, that is to say, to set the style that the user is going to type next. Using setCharacterAttributes(start, length, style,...

Does a swing filterable JList component exist ?

For a specific screen, I'm looking for a JList that I could filter (the same way you can filter a JTable using a RowFilter) Is there a good implementation of this kind of component anywhere here in the wild (and do you have an experience with it) or do I have to code it myself ? (it is not that long to do, but if there is any valid imp...

Perform action in background at program start

How can I perform action in background at program start? I would expect some kind of onLoad event for this purpose. Just to be clear: Load ui. Do some stuff and load some more UI based on result of my event. ...

Java Swing: Can I set a button mnemonic that doesn't require pressing alt?

For example, say I have a series of toolbar-style buttons across the top of my application's main window. I want to attach a mnemonic to one of these that's just a single keypress, like F3. When you set the mnemonic to KeyEvent.VK_F3, the user has to press Alt+F3. If you have a menu item, you can set an accelerator, rather than a mnem...

How to set the background color of target cells in a jtable?

I don't want to set the background color for all the cells in the jtable, just the ones I choose. How do i go about doing this? ...

JFrame Update problem

Please, help! How can I update my JFrame content(add new JPanel, add button, etc) after some action take place, like press button? Thanks! ...

Setting an icon for a frame

I have used this statement for setting an icon for a frame but still it shows the "java" instead of my image,would you please help me? frame.setIconImage(Toolkit.getDefaultToolkit().getImage("tictactoe.gif")); ...

Getting an explicitly set foreground color for a JButton

I have a custom ButtonUI class that paints the button. Before drawing the text, the paint method checks whether the button has been set a custom color in order to use that instead of UIDefaults#get("Button.foreground"). if ((b.getForeground() != null)) { colText = b.getForeground(); } Having a look into the java.awt.Component clas...

Java Applet flickers on focusLost and focusGained

I have a Java JApplet embedded in a web page. The JApplet window contains a single instance of a class that extends JPanel - same size as the JApplet. The applet can spawn pop-up windows (JFrames) when the user clicks a button that's in the panel. Every time I click on a button to pop-up a window, my applet flickers as it repaints. It ...

Setting Upper Bound for a Number in JFormatterTextfield in Java

Hi All, I want to set upper bound for a number in formatter textfield. Let's say that there is a string which has following format: 036 12' 23.67" The first number must be less than 180, so when the user tries to type a number greater than 180, it must be masked. I used MaskFormatter to format string as above, but I couldn't set an up...

How to indicate that a column in a table is sortable (UI design question)?

In the application that I am working on, there is tabular data (for the record, it is a Java Swing app using JTables). In some cases the data is sortable by clicking on the column headers. What I want to know is what is a good way to indicate to the user if a given column is sortable or not? I have come up with the following possibiliti...

Best performance option for drawing from a sprite sheet using Java Swing

I'm creating a graphical roguelike game using Java. In the game, I'm painting a 2d array of Tile objects onto a JPanel. These Tile objects represent the ground. I have a .bmp sprite sheet that contains all of the textures I want to use to paint with. Every time the player moves, the tiles that are visible to the player need to be redrawn...

JCheckBox tree cell renderer

I've implemented a TreeCellRenderer that returns a JCheckBox (simple code that the renderer extends a JCheckBox and sets its selection status based on a flag in the item) and it works well. However, when there are more than a few items in the list, it renders VERY slowly. Scrolling in the list and expanding nodes takes over 1 second, whi...