swing

Learning Java Swing?

I am a veteran C/C++ programmer who has used Win32, MFC and WTL to write Windows apps for many years. I have some very basic Java experience, but haven't done anything with a UI. I want to start learning how to write desktop apps in Java and from what I can gather, Swing is the way to go. My question is: where do I start? Can anyone ...

Canvas3D not appearing in Swing window

I am attempting to insert a Canvas3D object inside a Swing JPanel, but the code doesn't seem to be working (i.e. nothing happens): Canvas3D canvas = new Canvas3D(SimpleUniverse.getPreferredConfiguration()); SimpleUniverse universe = new SimpleUniverse(canvas); BranchGroup root = new BranchGroup(); root.a...

Find "real" height/width of Swing/AWT object

Because Canvas3D doesn't have the ability to resize dynamically with the parent frame, I would like to be able to track when a user resizes a window and then resize it manually myself. (If this ends up crashing Canvas3D, as some docs suggest, I will simply destroy and recreate it when the user resizes their window). Part of this procedur...

Do I have to explicitly call System.exit() in a Webstart application?

Recently I converted a Swing application to Webstart. The process was pretty straightforward, but I found that after I close all windows, my application's JVM did not terminate. The thread dump showed that there are a couple of non-daemon threads, notably Swing's EDT, AWT and a couple of websart related threads. The actual strategy use...

How do I center a JDialog on screen?

How do I go about positioning a JDialog at the center of the screen? ...

Open-source improvements or replacements for Swing components

I develop a number of desktop Java applications using Swing, and while Swing is quite powerful (once you get the hang of it), there are still a lot of cases where I wish some advanced component was available right out of the box. For example, I'd really like to see easy-to-use components (without writing them myself, which I could do gi...

Custom swing component - Turning a node into text

I'm writing a custom swing component (something completely new, but think JTree or JList). I'm trying to follow the general design of JTree, JTable, JList etc for consistency (I've also seen various poor 3rd party components abandon the separable model and/or renderer approach). So, I have a model full of nodes, the component itself and...

How do I change JPanel inside a JFrame on the fly?

To put it simple, there's a simple java swing app that consists of JFrame with some components in it. One of the components is a JPanel that is meant to be replaced by another JPanel on user action. So, what's the correct way of doing such a thing? I've tried panel = new CustomJPanelWithComponentsOnIt(); parentFrameJPanelBelongsTo.pack...

How to reduce space between JCheckboxes in GridLayout

Hi everyone, I have three Java JCheckboxes in a column, arranged by setting the layout of the container JPanel to GridLayout(3, 1, 1, 1). When I run the program, there is too much vertical space between the JCheckBoxes; it looks like more than 1 pixel. Since I've already set the vertical space between the JCheckboxes in the layout to ...

How Do You Get the Height of the Titlebar Using Java (Swing)?

I am getting a MouseEvent in Java. the getPoint() method is adding the height of the title bar into the y portion of the coordinate. I was wondering how I can find the height of the title bar of the current window in order to offset the y value by the correct amount. ...

Portability of Java Swing applications to OSX

Recently I wrote an extremely basic Java Swing program with a couple of text fields and buttons. The program works fine for me on Ubuntu with Java 1.5. But when I try to run it on OSX (10.4), the main window is displayed correctly but the program seems unresponsive. Nothing seems to happen, no matter which button I click on. I know next...

Resize a JPanel in line with a JDialog

Hi, I've got a JDialog which contains a series of JPanels in a CardLayout. Some of these panels contain JTables which I would like to be resized in line with any resizing of the JDialog. I am not sure how to achieve this and any help would be greatly appreciated. At present the tables simply remain their current size and do not scale...

Bus or listeners/delegates in client-side Swing application?

Building a client-side swing application what should be notified on a bus (application-wide message system, similar in concept to JMS but much simpler) and what should be notified using direct listeners? When using a bus, I always have an unescapable feeling of "I have no idea who uses that and where". Also, no set order, hard to veto e...

Java Swing, textarea as input/output?

Hi guys, I want to load up a window using the java swing, something like this However I want to be able to use it for text input also not just to dump data into it.. any idea how to do it? ...

What methods get called when you resize a JFrame?

I'm using a JFrame in which the CENTER portion of the BorderLayout is occupied by a JScrollPane that wraps around a JPanel. What I'm finding is that when I initiate the action that actually causes the JPanel to be displayed, the display doesn't change. But when I resize the JFrame, the new JScrollPane has now magically appeared. So wh...

How do I create a custom JPanel extension and use it from the NetBeans palette?

I have a JPanel extension that I've written and would like to be able to use it in the NetBeans designer. The component is simply adds some custom painting and continues to function as a container to be customised on each use. I have properties to expose in addition to the standard JPanel ones and have a custom paintComponent() metho...

Is it possible to display Swing components in a JSP?

I was wondering if I could pop up JOptionPanes or other Swing components from within a browser using JSP. ...

Java: When is Java 6 ready for end-user desktop application?

I am writing a desktop application written in Swing developed using Java 1.5. Some of the users seem to be using Mac, but I am interested in Java 6's scripting feature (Java 6 ships with Rhino). Java 6, although it came out almost 2 years ago, doesn't seem to be widely in use. I also hear Apple ships Java 6 only for Intel 64 Macs only. I...

Problem with Swing GUI on Macintosh

Hi, I am new to Swing. Are there any specific issues related to customizing the paint operation on the Mac? I have developed a sample application using NetBeans + Swing on Windows. It is working fine. But if I run the same application on a Mac, panels' buttons' labels don't appear on the screen. Only when the mouse over operation is p...

How to reliably get row index in JTable from MouseEvent ?

I want to find out at whih row of JTable the user clicked. How to do it ? ...