swing

How to prevent multiple dialogs to appear at the same time?

How can I avoid, that a dialog is shown, when there already is one on the screen? Details: In my application many Timers are running. If a fatal error occurs, all the affected threads are going to show a JDialog (by swingx.JXErrorPane.showDialog()), which is not desired. Even if I cancel all the running Timers, still some Dialogs will a...

Swing: How to create Events and dispatch them to a component?

I need to send some events to a component in Swing, so it is handled just like any user generated, standard Swing events. Basically, something like a macro recorder, and then executor for JEditorPane. But I need more control over the generated events. SO, assume I have an editor, I want to: capture all events sent to it, and at that...

Save JFrame location in multi-display environment

I want to store a JFrame's location (bounds, extendedState) when the user closes it. However, when the user moves the frame onto the 2nd screen and maximizes it, how can I store that information? My naive (and single display) implementation is like this: void saveFrame(JFrame frame) throws IOException { Properties props = new Prope...

How can I use Drag-and-Drop in Swing to get file path?

I have a JTextField in my swing application that holds the file path of a file selected to be used. Currently I have a JFileChooser that is used to populate this value. However, I would like to add the ability for a user to drag-and-drop a file onto this JTextField and have it place the file path of that file into the JTextField instead ...

Concurrency Question

I am writing an application in java (1.6) using swing. I currently have a JXBusyLabel on a JXLayer over the content area of my program acting as a busy indicator. I want to provide a way to allow others working with me to create a task that pops up the busy label while it's executing. The catch is, the task must be cancel-able. What is t...

What Java Swing event can be used to know when application has finished starting?

I'm looking for a place to hook some code to programmatically create, size and position a JPanel after the application has finished loading. I'm just starting with Java. I'm using NetBeans 6.5.1 with jdk1.6.0_13. I've used the new project wizard to create a basic Java/Swing desktop application. This is a SingleFrameApplication that uses...

How to include custom panel with NetBeans GUI Builder?

I have written a class that extends JPanel. Is it possible to use this in the NetBeans GUI Builder and have it survive all of the automatic code generation? I have used the customised code option in the GUI builder to instantiate the object as the new class, but it seems like the declaration can't be changed from JPanel, so only method...

What is the best way to link your application to Swing GUI?

If I have Swing GUI class and application, how should I manage communication between these objects? Should I pass GUI object link to app or app link to GUI? Example: public class App{ public App() { GUI gui = new GUI(this) } } or public GUI{ public GUI() { App gui = new App(this) } } ...

Make JScrollPane display scrollbars when JList inside is changed

Hi! I'm trying to change a JList inside a JScrollPane dynamically, using myList.setListData(someArray); After this I would expect the JScrollPane to show Scrollbars as needed, but this doesn't happen. Googling the issue was not very helpful. I tried various combinations of the following methods, with little success (basically poking ...

Changing JTable cell color

This is driving me absolutely insane. I know that, to change the formatting of table cells with JTable, I have to use my own renderer. But I cannot seem to implement this properly. This is my current setup: public class MyClass { public static void main(String args[]) { JTable myTable = new JTable(10, 10); myTable.se...

Tomcat update event

I am working on an application which uses tomcat as a web server and java swing app. as only client to communicate to the web server via webservices. I am stuck in a situation where i need the server to somehow notify the client of some kind of updated event, that occurred on the server side. Something like reverse ajax or similar. A...

How to make JCombobox look like a JTextField

Is there a good(and easy) way to make a JCombobox look like a JTextField? By this I mean there should not be a dropdown button, but when the user enters something it should show multible results. Basically the same way google, youtube, facebook etc. works. ...

How to create a custom Swing Component

I've always wanted to create custom components in Java, or customize existing ones, but my searches never resulted in anything useful. So I decided to ask the StackOverflow community: Where can I find information about customizing Java GUI Components in general? And when I mean customizing, I'm not talking about changing colors, fonts ...

Removing a JPanel from a JFrame

I am currently working on an intro screen for a game designed using JOGL. I want the intro to be a JPanel with a few buttons to alter options before starting the game. So, I have JFrame which I add a GLCanvas to. The GLCanvas also contains a GLEventListener. Finally, I add the JPanel. I have overridden the JPanel paintComponent method ...

JDialog lets main application lose focus

Hi, I wonder why my JDialog pushes my main application into background. That means if the JDialog will be shown and the user clicks "OK" or "CANCEL" the main application looses its focus and will be pushed into the background. After my investigation I found out, that this behaviour only happens if I disable my main frame for the time I...

Creating a Java GUI in Swing for form input

Well, I've looked all over the internet (including good ol' StackOverflow) and just haven't been able to find an answer to this question, so maybe someone can provide some insight. I'm working on developing a relatively simple Java app that will replace a Word doc currently used for system access requests. It's designed to allow form e...

Connecting swings with sql

I want to learn sql connectivity with swings(java) can any one suggest a good resource available for my purpose. ...

Closing a modal JInternalFrame

I followed approach 2 of this guide, so now I have a ModalInternalFrame that blocks input to all other frames, just as I wanted. However, I made one change from the example, and now I have two problems. The Change I removed the JOptionPane, because the whole point is to show my own pane. In order to make it close, I set closeable to t...

What are the options to replace Java Swing GUI?

We have a desktop client application developed in Swing. This application interacts with backend server using Servlet. The new requirement is to make a web based client. I have read about JavaFX, Flex, ExtJS, etc. I would like to know which solution is best fit to replace a swing application? Does anyone have any experience of doing th...

Text Field disabling in NetBeans

I want to ask if there is a way to make the text field active and inactive according to the radio button. For example, the textfield will be inactive and when the user click on the radio button, the textfield will be active. I am using Java language and NetBeans program ...