swing

How to enable GUI behaviors for sorting a JTable when SQL does the sorting?

How do I enable JTable icons and behaviors for sorting table rows by a column, without letting it use a comparison predicate to do the sorting? That is to say, how do I tell the table headers to show the arrow for ascending/descending sort order in the column being used, and get it to call appropriate methods when sort order/column chan...

Can findComponentAt() work before a JComponent is painted?

I am working on a GUI where the JComponents are "stamped" on the screen. In other words, the actual components aren't displayed, but images of the components. This is a graph, where the nodes of the graph are custom Swing components - or rather stamped images of Swing components. Now I want to display tooltips for specific components ...

Adding additional JPanels to a JPanel

Rather basic question here guys. Basically I have code like this: public SuperPanel() { setLayout(new BorderLayout()); add(panel1(), BorderLayout.NORTH); add(panel2(), BorderLayout.CENTER); add(panel3(), BorderLayout.SOUTH); } And that all works well and good. The problem is that I have another part I wish to add to t...

NetBeans gui design tool (matisse) seems to use Java 5 instead of Java 6

When trying to open a custom JPanel class in the NetBeans GUI design tool, I get the following error: Warning - Form loaded with errors Error in loading component property: [JPanel]->someScrollPane->somePlainJTable->autoCreateRowSorter No such property exists in the component. The offending code: somePlainJTable.setAutoCreateRowSorte...

Is XML or XUL the future of Java GUI building?

After spending a lot of time and code on programming in Swing, I thought this can't be state-of-the-art Java GUI building. After not finding a user-friendly visual gui bilder for eclipse I stumbled upon declarative GUI building with XML UI toolkits... and I thought: This must be it! I think it's the right way to go, easy and also close t...

Scheduling Swingworker threads

Hi, I have a 2 processes to perform in my swing application, one to fill a list, and one to do operations on each element on the list. I've just moved the 2 processes into Swingworker threads to stop the GUI locking up while the tasks are performed, and because I will need to do this set of operations to several lists, so concurrency wo...

Java JTabbedPane, how can I select a tab from a button?

Hi all How can I select a tab as if it was clicked by clicking on a button? I have googled and looked at all the actions but there are just just so many... :( Anyone know off hand? Thanks in advance! ...

Updating cell renderer after a DefaultCellEditor derived instance does its job

Hello, I use a JTable which has its own cell renderer and cell editor. Say, this table contains 2 columns and x rows: The first column contains a boolean value, its own cell rendering and cell editor (a radiobutton) The second column contains a string value, its own cell renderer: it makes it bold when the first column of the current...

Remove unnessesary spaces from Swings Components

i have 3 JPanel, the first is the base panel and the other two are added to the first. I have realised that there is a lot of space that is not used, shown by the black color and the white color around components. How do you remove this space? ...

Testing whether a Font is monospaced in Java

Hi there, I'm trying list all of the monospaced fonts available on a user's machine. I can get all of the font families in Swing via: String[] fonts = GraphicsEnvironment.getLocalGraphicsEnvironment() .getAvailableFontFamilyNames(); Is there a way to figure out which of these are monospaced? Thank...

Using MediaTracker to cache images in Swing Application

I have a Swing based financial ticker, that will display a financial symbol the price movement and an arrow for either up or down for each counter / company. This ticker can have a lot on counters (up to 100), and see the need to cache the images symbols to boost performance. I have tried following this article but fail to understand i...

How to pause execution while JDialog is open

How can I make my application pause when I open custom JDialog and after the dialog is closed to make continue again. ...

setBorder method for JLabel causing paint problem

I have a custom class that extends JLabel. For specific instances of that class, I want to add some spacing to the text on the left side. I need the spacing as I'm setting the background of this JLabel and I don't want the text to bump up right next to the edge of the colored background. I fished around quite a bit and implemented thi...

Swing: Problem distinguishing between user-induced and automatic components resizing (Writing a custom LayoutManager).

Hello! I'm trying to write an own layout manager. Components must be placed and sized relative to each other. This means: when the user drags or resizes an component, some other components (but not the one altered manually by user) have to be altered. Swing tells the layout manager to layout the components every time when some of them...

Java Slider - how to make custom ticks?

I have an audio track with an image slideshow - e.g. there's image 1 at 0:00, image 2 at 0:45, image 3 at 1:03 etc. I'm currently using a JSlider to change position in the track. I'd like to have ticks on the slider in the points where images change - but the spacing between ticks is not uniform, so setPaintTicks is not an option. Is the...

Stacking Jpanels on top of other

Hello this is my question; I have created 5 very similar panels that are suppuosed to be visible in the same area of a frane on at a time, What I mean is that when the app stars one of them (JPanel0) is visible and the other four are created but invisible and when i hit Button1, JPanel1 sets to visible and Jpanel0 goes invisible, same w...

Modifying a Swing Timer's Delay during Runtime

I'm developing a Queue simulation, using a Swing Timer to dequeue objects after certain amounts of time. The interval is determined by peeking at the next object in the queue, getting an integer from it, and setting the delay of its corresponding timer. Here's the relevant snippet from the program (Note: _SECONDS_PER_ITEM is a constant ...

How to make unique font color for lines in a JCombobox?

I want to set the font color for the lines/entries in a JCombobox, unique for each line. So basically when you click the dropdown arrow, you should see a few lines that are different colors, and I want to specify the colors myself based on their properties. How should I go about doing this? Thanks! ...

Lightest-weight spacer component in a GridBagLayout

In a GridBagLayout, what component is the best for providing empty space in a panel? Ideally I would like to use a component that has: Low overhead No side effect when no empty space is required (i.e. no minimum size) A trivial constructor (no parameters) A JPanel violates #2 above. A Box requires a constructor parameter (#3 above)...

Can I apply CSS to swing text components?

A number of swing text components will interpret HTML. I'd like to style this HTML with CSS if possible. Any one know how to do this? ...