swing

How do you effectively add components to a swing panel with a background image?

I have a JPanel onto which I'm trying to add some buttons. I have a bitmap background image onto which I'm supposed to draw the buttons. I have images for all the buttons. I need the background to scale with the buttons and the spacing to be correct. Is there a clean way to do this or is this going to be painful? Thanks ...

GridBagLayout weight bug?

The layout of the components in the project I'm working on didn't look correct, I suspect there's a bug in Swing. Basically, what appears to be happening is that the weightx and weighty proportions aren't being adhered to when the cells being laid out have varying minimum sizes and/or preferred sizes. I created a sample program to demo...

JComboBox getSelectedItem() not changing

I'm binding a JComboBox to an observable List. I clear and add Objects form the observable list. This works fine and reflects the changes in the JComboBox correctly. The problem is I can't select the content of the list using the mouse although the newly added items are correctly displayed in the combobox when expanded. The getSelected...

After calling JTabbedPane.removeAll(), the JTabbedPane still has x number of tabs?

In my JTabbedPane, I am removing tabs in 2 different ways: tabbedPane.remove(index) and tabbedPane.removeAll() Both work fine in terms of closing the tabs. However, I have a change listener on my TabbedPane that calls back to another module to report on tab changes. This is where the problem is. When adding and removing tabs usin...

Swing GUI generator for XML

My application has an XML configuration file which users now edit in a text editor. I want to provide a (Swing) form for editing this configuration. I have a DTD for the XML, but the application does not accept all XML documents validated by the DTD i.e. the application imposes more restrictions than those in the DTD. I was about to sta...

Application framework for Java desktop applications?

Hi, I'm currently using a custom framework to build Java Swing applications which have event monitoring over a network. I'd like to replace our custom networking layer with something like JMS but our framework is tightly coupled to its current implementation. This lead me to search for existing application frameworks which may already ...

How to programatically deselect the currently selected row in a JTable (swing)?

I want to programatically deselect the currently selected row (or rows) in a JTable. Basically I want the oposite of this: JTable table = ...; table.setRowSelectionInterval(x,x); I tried (with little hope) using: table.setRowSelectionInterval(-1,-1) or table.setRowSelectionInterval(1,0) but it doesn't work. Any ideas? ...

Java Swing JTree Expansion

This method works as expected - it creates a JTree with a root node and two child container nodes (each with a respective leaf node): private JComponent createSideBar() { final DefaultMutableTreeNode top = new DefaultMutableTreeNode("Projects"); final JTree tree = new JTree(top); DefaultMutableTreeNode project = new Default...

circle packing - java

I have a task to draw a circle and then fill in with the most amount of circles without touching the sides. I can draw the circle, and I can make loops to pack the circle in a hexagonal/honeycomb format, but can't control whether they are inside or outside the circle. I have used this: g.drawOval(50, 50, 300, 300); to specify my circle....

In what way do many graphical components affect the performance of a Swing GUI?

I've creating a Java Swing application and I realized that I have many many components on a form. It's not that my interface is cluttered, but nevertheless the total amount can be quite high (hundreds) because the user can enable additional parts of the interface and there have to be list-like repeating panels on the form. Additionally...

How do i change the UI of a JComboBox

I like to change the UI of a JComboBox from the default metal look to some custom UI, see attached image. I have tried changing all the UIDefaults for the JComboBox but to no success. How does one achieve this? jdk1.4.2 ...

Printing two Jpanels in one document

Hi, I have two different Panels but i have need to send them in one document in to two pages. first page print at front and the second will print at the back side can anyone please help me i have send one jpanel but how to send second with it. Here is my code private void printCard() { PrinterJob printjob = PrinterJob.getPrinte...

Eclipse SWING app: breakpoint hit only after an uncaught exception is thrown

I have a really strange issue. I am working on a Java SWING application in Eclipse. I set a breakpoint somewhere in my code, then run the debug. I execute the piece of code containing the breakpoint but it is always skipped. As soon as I run some code that throws an uncaught exception, the breakpoints start being hit again, without cha...

Swing: What is a good way to implement fully-scalable components?

I am creating an application which has a scrollable and scalable (zoomable) view. Inside this view I want to place other components (most of them customized JPanels and JInternalFrames). Things such as fonts and borders, and sub-elements such as buttons don't need to be scalable. Only dimensions and position of container components shou...

Planning view component in Swing

I need to build a Swing GUI like this where there are typically 40 tour columns. In each column there are typically up to 20 orders per tour. Orders may be grouped together within a tour. It should be possible to horizontally enlarge to columns, to D&D orders within a tour and to other tours. Later the representation might change includ...

Is there a way to "attach" Swing frames to one another?

We have a program with multiple top-level swing windows (frames). We are adding some "debug mode" where for each window of the original application there should be a specialized window that displays some information and offers some controls related to the original window. This is running in the same process as the original application s...

Embedding a JPanel in a Frame

I created a Java application in NetBeans which consists of a bunch of components on a JPanel. I know want to embed this application on a frame which will be a completely separate application. I can't seem to be able to do this...any suggestions? ...

Swing: How can I prevent flickering and "vibrating" of a component, when restricting its movement?

Hello! I need to restrict movement of a component (JInternalFrame) inside a JPanel. More exact: a component should only move along one axis when dragged by the user. I tried to do it by adding a component listener and reset the position of one axis everytime the component moves. But it "vibrates" (moves rapidly during dragging). I eve...

JSpinner editor locale

I'm creating a JSpinner and setting a NumberEditor with a custom format. But no matter what I do the format uses "." instead of ",", not according to my locale (pt_BR). priceSpinner = new JSpinner(); priceSpinner.setEditor(new JSpinner.NumberEditor(priceSpinner, "0.00")); Is it possible to use "," instead of "." as a decimal separato...

Swing versus SWT

What should I be looking at when choosing between SWT and Swing? I've had a little experience with both, but I'm interested in: layouts/layout managers; data binding; pre-built controls; ease of development. I will assume that they are both satisfactory in terms of GUI performance and of platform availability. ...