swing

Disabling 'paste' in a jTextfield

Hi I have an app that is written in Swing, awt. I want to prevent users from pasting values into the textfields. is there any way to do this without using action listeners? ...

Mix of Arabic and English causes problems in JTextArea (Java)

I have a JTextArea which displays HTML of an Arabic web page. So it's essentially a mix of English and Arabic. In the JTextArea, with columns set to 30, certain text just disappears instead of wrapping properly. The weird thing is that if I copy the invisible text and paste it into Notepad, then I can see it in Notepad. If I change the n...

Are the Swing LayoutManagers adequate?

I just had to add a checkbox to an application that was written before I got here, and it was way more difficult than it had to be because the app uses some third-party LayoutManager that attempts to do pseudo-absolute, gridlike positioning. The API was terrible, it takes position-designating strings that are comma-delimited lists of tw...

Gui - Best way to navigate between windows?

Hi, I try to build a gui (Swing) for a simple java application. The application should have a start window like a menu. From there I would like to navigate to several other windows. My question is what is the best-practice to achieve such a navigation? Should I build several JFrames and switch the visibility of them on/off when navig...

How to access multiple JPanels inside JFrame?

I have a JFrame that contains a "display" JPanel with JTextField and a "control" JPanel with buttons that should access the contents of the display JPanel. I think my problem is related on how to use the observer pattern, which in principle I understand. You need to place listeners and update messages, but I don't have a clue where to pu...

Do I need to free Swing components before letting them get garbage collected ?

Wnen I use external resources such as files or DB connection I need to close them before I let them go. Do I need to do the same thing with Swing components ? If yes then how ? ...

Is there any (real) Office 2007 look and feel for Java/Swing?

I'm aware of the Substance look and feels and that they have a Office 2007 look-a-like look and feel. But this look and feel doesn't look like the Office 2007 design at all, the colors are a lot different for example. Are there other look and feels which mimic the Office 2007 more accurately? ...

Looking for recommendations on open-source Java instrument visualization components

I am putting together an Java application that needs to display some basic lab instrument components. For example, I'd like to display: a strip chart, oscilloscope-style trace, and a panel meter (galvanometer needle). Rendering requirements are open (as long as the engine is free and generally available). Any suggestions? ...

How can I turn off anti-aliasing for one specific JLabel?

How can I turn off anti-aliasing for one specific JLabel? It uses a very small font which might look better without anti-aliasing. If important, I'm using Java 1.5 on Mac OS X. ...

How do I activate JButton ActionListener inside code (unit testing purposes)?

Hi, I need to activate a JButton ActionListener within a JDialog so I can do some unit testing using JUnit. Basically I have this: public class MyDialog extends JDialog { public static int APPLY_OPTION= 1; protected int buttonpressed; protected JButton okButton; public MyDialog(Frame f) { super(f); okButt...

Handle Swing events in JUnit test

I have Swing java application with network communications to several "Players" that are represented as player objects, each with their own communication thread. The app has a "Team" object managing all player objects. Several UI components listen to events passed from the players through the Team object. In my design, the team object f...

Is there a multiple input JOptionPane in Java?

Hey all, I was wondering if there is a JOptionPane where you can get multiple inputs from a user instead of just one? If not, how could i accomplish this using some type of prompt. I am creating Battleship, and wanted to prompt the user to specify locations to place each ship. Thanks, Tomek ...

Why is itemStateChanged on JComboBox is called twice when changed?

I'm using a JComboBox with an ItemListener on it. When the value is changed, the itemStateChanged event is called twice. The first call, the ItemEvent is showing the original item selected. On the second time, it is showing the item that has been just selected by the user. Here's some tester code: public Tester(){ JComboBox box = n...

Can Swing tell me if there is an active tooltip?

Is there an elegantish way in Swing to find out if there are any tooltips currently being displayed in my frame? I'm using custom tooltips, so it would be very easy to set a flag in my createToolTip() method, but I can't see a way to find out when the tooltip is gone. ToolTipManager has a nice flag for this, tipShowing, but of course i...

How to return actual cell component bounds in a JTable?

I have a custom renderer in a JTable to display Jcheckboxes for booleans. However, this causes a slight issue because when the user clicks in the table cell, but not in the checkbox, the checkbox is still checked. Is there a way I can return the bounds of the actual JCheckbox that is rendered by the JTable at a particular point so I ...

Detect whether FocusEvent of component is lost or gained

I implementing a EventQueue and get notified when AWTEvents are send. I wait till instances of FocusEvent are send to the dispatchEvent methode. The FocusEvent by itself does not have a methode to ask if the focus of the component is gained or lost. The methode paramString returns a String in which the information is placed, but i dont ...

Any good Java Swing Timeline Widget?

Is anybody aware of a good Java Swing Timeline Widget with features comparable to the Janus Winforms timeline component? ...

Find composite location on screen

I am implementing a on screen keyboard in Java for SWT and AWT. One important thing is to move the keyboard to a position where the selected text field can show and is not lying behind the on screen keyboard. For AWT i can detect the position of the current selected component with Component owner = KeyboardFocusManager.getCurrentKeyboa...

A better way to do Swing Applications

Is there a better way to develop Java Swing applications? SWIXML? JavaFX? Anything else that developers out here have liked and recommend? ...

Why do I keep getting a NullPointerException in the Java BasicTableUI$Handler.setValueIsAdjusting?

I keep getting this NPE in my application and I can't seem to get rid of it because it is not showing up in any of my source code. As you can see from the stacktrace it is not happening in my code but in the Swing plaf. Has any of you had this problem and maybe figured out what is happening here? 11:28:23,273 [AWT-EventQueue-0] ERROR...