swing

How to Use context menu with tray icon in Java?

I'm using Netbeans to develop a Java application and I want to create a tray icon at system tray and a popup menu will be display when I right click on tray icon. I have created a jframe and popup menu by drop and drap them. But I have a problem.My popup menu have 2 menu items (Exit and Show Login) but selected menu item is not high-li...

The best tool for build swing UI visually

What is the best and powerful tool for building swing interface? What tool do you use for swing? Why? ...

Java Swing: Generating dynamic GUI forms from XML

Hi, I am writing this application in Java, where I have a JTree on the left of the JFrame, and the item selected in the JTree determines what appears on the right. This is similar to Edit --> Preferences in Thunderbird, and several other applications' preferences. Anyhow the main difference is that in my app the stuff on the right is d...

Access a new frames methods

This method shows a new window in my application: public void ShowNewCustomerView() { if (NewCustomer == null) NewCustomer = new NewCustomerView(this); NewCustomer.setVisible(true); } The class NewCustomerView has this method: public void ClearFields() { txtAddress.setText(""); txtCity.setText(""); txtCompanyName....

Testing keyboard input with java.awt.Robot

I have a test that exercises a custom Swing component using java.awt.Robot. I'd like to run the test in our build server, but the build servers run on locked windows machines, and Robot.keyPress(char) doesn't work with the screen locked. The keystrokes I'm sending are sometimes things like down arrow and backspace, so sending them dire...

JScrollPane doesn't show if BorderLayout constraint is CENTER?

Hi all, Been developing a game for a while, and currently re working the GUI, or at least trying to. Had the massive problem of not being able to resize the frame (without issues), as I didn't understand layout managers very well. A few projects later, and time to come back and do some more on the game, and I hit a problem... The basic ...

Add a component into Jframe or JLabel created by Netbeans

I'm using Netbeans. I use Netbeans to create a Jframe and drop and drap a JLabel to Jframe. I want to add a JLinkButton (I use zfqjava JLinkbutoon) to Jframe and to JLable by using code(but not drap and drop) but it doesn't work. Here is my code to add JLinkButton to JFrame this.getContentPane().add(linkButton); and here is my cod...

JScrollPanes in JInternalFrames for right to left component orientations - Java bug?

So I have created some demo code, see below. What I am seeing is that if a JScrollPane is within a JInternalFrame and component orientation is set to right-to-left, when minmising the frame, the scroll bar stays to the left of the content. I would expect, seeing as RtL, that it would stay to the right of the content, which is true if th...

Button inside swing Rectangle2D.double

Hi Gurus, We have a swing application which displays a lot of rectangles. We use Rectangle2D.double class to draw the rectangles on a JPanel. My requirement is this. Upon clicking the rectangle, I have to pick an image from the local filesystem and show it in a popup window or a frame. My question is how can I provide a hyperlink or butt...

Right click on JButton

Hi guys, I am trying to write a Minesweeper clone in Java for fun. I have a grid of JButtons whose labels I will change to represent the danger count, flags, etc. My problem is, I don't know how to get a right click on a JButton to depress the button. I've done the following: button.addMouseListener(new MouseAdapter(){ public ...

Java GUI and Multiple Instances of the SwingWorker Class

I'm making a GUI using Java (who isn't?). I know the Swing Worker class enables computation in the background to prevent the GUI from hanging, but I was wondering if there could be too much of a good thing here... For instance, if there were too many instances of those background threads running, would it impact the performance of th...

jProgressBar with Database

Hi, how do I display the progress in a jProgressBar when I write something in the database? Thanks ...

java ui implementation: short-term test + progress indicator w/o using separate dialog

I need to add a simple GUI for running a stress-test. I would like to do something like this: State 0: stress-test is not in progress -- in this state the user can enter/increment a number in a spinner. Pressing the go button will start the test and transition to state 1. [spinner] [go button] State 1: stress-test is in progress -- i...

Disable Word wrap in JTextPane

I can't find an easy way to turn off word wrap in a JTextPane. I can't use JTextArea because I need different colors for different text. I have these big ugly lines that get uglier with word wrap turned on. JTextArea has a setLineWrap() method, but I can't find it for JTextPane. Why? ...

How do you record keystrokes when operating on another window in Java?

I'm looking to record keystrokes and mouse positions while I'm in a browser window on various websites, but I'm not sure how to do this outside the SWING (or some other GUI) window. How can I record keystrokes when a different application's window is the one active? ...

Jframe without frame border, maximum button, minimum button and frame icon

I would like to create a without frame border, maximum button, minimum button and frame icon. Pls guide me to do that! ...

Problem in Java GUI

Before reading about my problem, first look at this GUI Diagram. There are three bars at the top as follows: one having buttons "pictorial view", "textual view" etc. second having buttons "processes", "organisation" etc. third having buttons "application to processes" etc. After that two information bars are there. After that a can...

Java GUI Toolbar

I am developing a Java Desktop Application. In that I want some toolbars at the top of the JFrame (as in usual GUI appllications). I want to allow user to add/remove toolbars dynamically by clicking on some buttons. How can I implement this (through any Layouts or some other way) so that when a user add/removes a toolbar, the rest of th...

Binding enum values to RadioButton in Java

I am stuck in binding values from enum to RadioButton. Lets say I have a bean: public class ValueObject { public enum ValueEnum { FIRST_VALUE, SECOND_VALUE } protected ValueEnum value; } I want to create Swing RadioButtons where user can select one from these two enum values. As I use Netbeans as IDE I would also like t...

Dynamically adding toolbars in Java Swing GUI

I am developing a Java Desktop Application. In the GUI, I want that user can add as many toolbars dynamically as he wants. To implement this, the following are the things that I have done already: Have taken a mainPanel and set its layout as BorderLayout Then taken a topPanel and added it to the mainPanel's BorderLayout.NORTH set the t...