swing

Swing GUI looks different under root user vs. non-root user

Hi. I have a Swing GUI that I developed Netbeans Matisse in Linux. For some odd reason, the look and feel of the application looks different when it's run by root (it looks better, actually). Is there a reasoning for this? Thanks ...

UIManager Font Setting

font = new Font("San Serif", Font.PLAIN, 24) val keys = UIManager.getDefaults().keys() while (keys.hasMoreElements()) { val key = keys.nextElement() val value = UIManager get key if (value.isInstanceOf[FontUIResource]) UIManager.put(key, font) } I used the code above to change all the default fonts in Scala Swing ...

Creating a gray space around a JPanel in Java

I'm developing an simple art program in Java and I was curious if it was possible to create an gray empty space around the canvas like is most art programs(Meaning, an empty space that isn't locked down and is scrollable). Is this possible and how could I go about doing this? Example: ...

Why doesn't my JPanel's preferred size change when its contained JScrollPane does in GroupLayout?

Using GroupLayout and the code below, I noticed that the leftPanel is not updating it's preferred size. I thought this was supposed to be automatic and appears to work in other layout managers. How can I get that behaviour with GroupLayout? import javax.swing.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; ...

Creating a Swing based GUI in Jython

Today, I've been dabbling in using jython to create a GUI using swing. I'm no expert programmer, so I decided to have a go at using the Netbeans IDE to design the interface and then adapt the output for use in jython as I have more experience in python than Java. After working through the code I managed to rid all the syntax errors but a...

Jython classes and variable scope

What I want to know is, how can I create GUI elements using swing inside a Jython class so that they can be referenced from outside the class, and I can use statements like button.setText("Hello") on an object that was created inside another class. For example: foo.py: from javax.swing import * class Test(): def __init__(self): ...

paint a property pane from xml schema

We need to build a swing component to let users enter property values in a property sheet. These properties are defined in a XSD file. For example: <xs:complexType name="email"> <xs:sequence> <xs:element minOccurs="0" name="body" type="xs:string" /> <xs:element minOccurs="0" name="from" type="tns:person" /> <xs:element min...

log4j redirection to desktop application in swing

Hi, I have a GUI application in swing, implemented in NetBeans. For the various functionality provided from the input of the user, a jar is used, which uses log4j for logging. All is ok, but I have to redirect information from log4j to a text area in my GUI. I have found that to redirect from log4j to swing text area, one must extend an...

Architecture for displaying dynamic data in real time

Executive summary: What kinds of sound architecture choices are there for displaying thread-safe, dynamic data in real time using Swing? Details: I have recently completed writing a multi-threaded, automated trading platform in Java. I say "platform" because I have made it very easy to implement new and multiple trading programs by su...

Get screen info in windows 7

In my app I'm using swing and awt. I am setting the size (and position) of the window I'm creating based on toolkit.getScreenSize() and this works fine. But I would like to deal with the size of the windows 7 task bar at the bottom (or wherever) of the screen. I can not seem to find out how to do this. Anyone know how I can get the s...

java guess the number game

import java.awt.*; import java.awt.event.*; import javax.swing.*; public class guess extends JFrame implements ActionListener { JLabel title = new JLabel ("SAMPLE 1"); JTextField txt1 = new JTextField (10); JLabel direction = new JLabel ("GUESS A NUMBER BETWEEN 1 AND 100"); JLabel status = new JLabel (); JPanel pnl1...

Closing Java FrameView

Is there anyting similar to JFrame.dispose() for Java FrameView I want that the FrameView should close when some action is performed ...

Hyperlink in JTextField

Is there some way to display text as hyperlink in JTextField so that when user presses it opens the link in a browser ...

Limiting JTextFieldInput to positive integers

What is the best way to restrict a JTextField input to only positive integers? Thanks! ...

Why will BoxLayout not allow me to change the width of a JButton but let me change the height?

I'm trying to get the Layout of a JDialog of mine to fit a particular look that a program in which I'm porting to Java has, I've used several LayoutManagers before with great success yet for some reason I cannot seem to get this working at all. My goal is to have the Right (East) side of the JDialog contain a "Find Next" and "Cancel" but...

HyperlinkLink in JeditorPane

I have few links displayed in JEditorPane ex: http://www.google.com/finance?q=NYSE:C http://www.google.com/finance?q=NASDAQ:MSFT I want that i should be able to click them and that it gets displayed in browser Any ideas how to do it ...

NewLine in JEditorPane

I was trying to set the text given below but for some reason JEditorPane is not recognizing \n and printing everything in a single line. this.jEditorPane2.setText("Hello how is the weather in \n California"); Is there any way to get a new line space? ...

Better GUI classes organization?

I am currently trying to program in Scala but I guess this can generally applies to other programming as well? In Swing, we generally organize our code and logic in a single class (perhaps our Frame or Panel). What I have learnt in the pass has always been dealing with a class as well. I am wondering if there is any medium size (not too...

Java Box (BoxLayout) does not work as expected

I have a weird problem using the Java Box class. I am using JDK 1.6.21. I have an own class, DropDownPanel, that inherits from JPanel. The purpose of the DropDownPanel is to be able to hide and show another Component on it. If you click on the title of the DropDownPanel, the hosted Component (now it is a JTable) is set to visible or inv...

GridBagLayout: equally distributed cells

Is it possible to completely emulate the behavior of a GridLayout with the GridBagLayout manager? Basically, I have a 8x8 grid in which each cell should have the same width and height. The GridLayout automatically did this. But I want to add another row and column to the grid which size is not the same as the other ones. That row/column...