swing

How to enable events on components in JList

I'm using custom renderer on JList, but none of components rendered are accessible. list.setCellRenderer(new ListCellRenderer() { public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { JCheckBox c = new JCheckBox(); JButton b = new...

Merging cells in a JXTreeTable

Hi, I want to merge two cells in a JXTreeTable. Is this possible? I have read the solution for Merging cells in JTable, but this does not work for JXTreeTables. What I mean with merging cells: I want to create a structure like this: node 1    | title for 3 cells | title for 3 cells |   subnode |  c1  | c2  |  c3  |  c1  | c2 ...

What advantages are to be had by using Java+Swing over C#+WinForms/WPF?

There is a group here using Java, server-side and client-side, with Swing for the client UIs. I plan to suggest that they change the front end to C# and WinForms or WPF, but I want to come prepared with: A list of benefits to be had from moving to Winforms / WPF from Swing, A list of Swing benefits that might get thrown back at me ove...

progress bars + MVC in Java = ???

So I have this nice spiffy MVC-architected application in Java Swing, and now I want to add a progress bar, and I'm confused about Good Design Methods to incorporate a JProgressBar into my view. Should I: add a DefaultBoundedRangeModel to my controller's state, and export it? class Model { final private DefaultBoundedRangeModel pr...

Are the names of default actions in Swing component's ActionMap standardized?

Say I have a standard Swing component like JSlider, but I want to slightly adjust the input map. Default input maps and action map are installed by look and feel, and I want to reuse some of the actions already available in ActionMap. To do that, I need to put ActionMap entry's key into the value of an InputMap's entry. I can easily loo...

Handling overflowing components in swing

In my app I have some longish labels, on a chinese os the labels overflow and push out other components also. This has only been observed on a chinese os. How can I detect and handle overflowing components? ...

Printing headers and footers in color?

I am trying to create colored headers and footers when printing a JTable. Specifically, I am looking at getPrintable() in javax.swing.JTable, but MessageFormat does not give me the option to specify the color of the header or footer. How can I do it? clarification I am interested in setting the header/footers while printing. For exam...

Swing: Positioning a popup from within a JScrollPane

I have a JTable inside of a JScrollPane. I am creating a custom cell editor for one of the columns of the table, and I want this editor to pop up a scrolling JList. I've done this by using a Popup to show a new JScrollPane containing the JList. Everything is working, except for the position of the Popup. My custom component for the edit...

Positioning in java swing

I have some troubles with positioning my label/password field. With this code they both get positioned in the center next to each other, while I actually want them in the middle of my panel on top of each other. Does anyone know how I should do that? import java.awt.BorderLayout; import java.awt.FlowLayout; import javax.swing.ImageIcon...

Printing from swing on Mac & Windows - Where is postscript support?

I'm printing a complicated swing application UI to a physical printer via an Airport. I've got Mac & windows machines both printing to the same printer. Printing from the Mac looks great. Printing from windows looks far from great - everything is very pixelated, including fonts and graph lines. Some digging around reveals that the av...

Java equivalent of OpenLayers

I am looking for a Java library to display map data from various sources, including shapefile, WMS, WFS, Google Maps, possibly ArcIMS, etc. It seems like OpenLayers is the closest thing to what I want, except it's a JavaScript library, and I'm writing a Swing application. GDAL looks promising, but as far as I can tell there won't be Jav...

How to display java swing on X11 when running on Mac

I would really like to be able to run our test suite on Xvfb so that swing windows don't keep popping up in the way of my work. Unfortunately I cannot seem to find a way to get the java runtime to use the display specified in the DISPLAY environment variable. I suppose this is because the Mac JDK is hardwired to use the (non-X-based) Mac...

Java layout manager vertical center

I have panel that is using group layout to organize some label. I want to keep this panel center of the screen when re sized. If i put the panel inside a another panel using flow layout i can keep the labels centered horizontally but not vertically. Which layout manager will allow me to keep the panel centered in the middle of the screen...

JFrame in Java

Hi, I am using a JFrame as a pop-up from a main frame, where the user is supposed to enter some information and then press OK. But the problem is that once this sub-frame has opened up, I want the program to ignore any other signal until the OK button is pressed, similar as how it is done with JOptionPanes. As it is now, you could click ...

Set the text color in a Java textbox

How does one set the color of text in a Java Swing textbox at run-time? At startup, the color is grayish and when the user enters the textbox, I wish to change the color to the normal text color. I am currently using the following code: private void txtScheduleInfoFocusGained(java.awt.event.FocusEvent evt) ...

The Need To Restore Graphics Original State When Overwritten paint or paintComponent

Hello all, I realize most of the Java code to overwritten paint or paintComponent, most of them doesn't restore the old state of graphics object, after they had change the state of graphics object. For example, setStroke, setRenderingHint... I was wondering whether it is a good practice that we restore back the old state of graphics ob...

How can I split up paint swing method in java?

I'm developing a fair sized hospital simulation game in java. Right now, my pain method is starting to look a little big, and I need a way to split it up into different sections... I have an idea, but I'm not sure if this is the best way. It starts by painting the grass, then the hospital building, then any buildings, then people, then a...

How to implement multilanguage in Java/Swing applications?

What are the different ways of implementing multilingual support in Swing applications? Are you using ResourceBundle with property file and implementing it in every frame? Does it work good for you? What if you use some kind of GUI editor? Is there any other way around? At work we are using Matisse4MyEclipse and the code gets regenerat...

Fixing a swing component's height within a Box layout

Good morning, I am making a GUI thanks to javax.swing.Box class Inside the panel: JLabel JTable with fixed height JLabel JTable with automatic height I tried everything to fix the first JTable height but without any success. I dedicate a Box.createHorizontalBox() for each component of the above rows and then I add them to the Box.cr...

How are Swing components internally created, laid out, repainted, notified of events, ...?

Hello! I wonder if there's a good documentation (or a (viewable) ebook) about the lifecycle of Swing components. Is "lifecycle" the correct term, anyway? I hope to find answers to question such as: How, when, in which order painting methods are called? How, when, which events are called by whom? What is the exact sequence of method ...