swing

How to check that a JCheckBox is checked?

How can I check if a JCheckBox is checked? ...

Block entire swing ui except for one component - "dialog style"

[This question is in relation to this question] Setting: I have this home-crafted "editable label" component which looks like a label, but when you click it, it turns into an editable field, allowing you to edit it. You can hit Esc to cancel, or Shift-Enter to OK your edits - or click the respective buttons beneath the editable field. ...

"Whiteout" entire swing GUI except from one component

[This question is in relation to this question] Setting: I have this home-crafted "editable label" component which looks like a label, but when you click it, it turns into an editable field, allowing you to edit it. You can hit Esc to cancel, or Shift-Enter to OK your edits - or click the respective buttons beneath the editable field. ...

Displaying PDF document in a Java(SE) Standalone Application

Hello guys, Am working on a Java application that requires me to display PDF documents within the application. Am not sure if Java currently supports this or will i need to get a Java library to get this done. Please, i need advise on how to go about this. Thanks in advance. ...

jtable and custom combos

Hi, I want to implement a properties table in jtable (swing). I want to have e.g. ** 2 column table Row1: Property-text| Txtbox. Row2: Property-text| ComboBox of values A,B,C. Row3: Property-text| Txtbox. Row4: Property-text| ComboBox of values E,F,G. ** I can not understand how to get this started. I am using Net...

Java Swing popup window losing focus and not repainting

Hello, I have a simple Java Swing GUI Form with a browse button. The browse button creates a new JFileChooser when it's clicked. However, if you click browse immediately after the window opens, the file chooser window seems to loose focus, showing the parent window behind it, but it refuses to repaint itself. I have to drag it off scre...

Why would our Java app not display windows on secondary monitor?

We have a Java/Swing client that's been around for quite a few years. When I moved from XP to Vista (client ONLY runs on Windows), I noticed that whenever a new window is created (usually a JFrame descendant) on my secondary monitor, the window initially shows as blank, i.e. instead of showing the normal contents of the window, it's just...

The contents of my JComponent only refresh after a manual resize

I am trying to figure out why my JComponent refreshes when I manually drag my window, but it doesn't refresh when I call repaint or revalidate. The data is ready to be displayed, but it just won't show until I manually resize. Can anybody give some suggestions about what I can do or does this sound like it isn't a Swing problem since I t...

Handling user driven resizing, position changes in Java Swing

Hello, I'm currently building a Java Swing GUI and I was wondering how user (mouse, say) driven resizing is handled. My problem is that when I try and resize my main window, or when some other window opens over my application, then my application's window gets distorted - all it's parts don't change well in response to the resizing o...

Java - Check for selection on JList

Is there a way to see if my JList list is being selected or not? I say this because I have a JList and JTextfield and when I type "F" in the JList to do a keyevent action.. the letter F gets typed into the JTextField after I focus on it. For example: Let's say I go to JTextField and type "hi". I go back to my JList and click on selecte...

Java event propagation stopped

I have a main window: public class MainPanel extends JFrame implements MouseListener { public MainPanel() { setLayout(new FlowLayout()); setDefaultCloseOperation(EXIT_ON_CLOSE); addMouseListener(this); ChildPanel child = new ChildPanel(); add(child); JPanel spacer = new JPanel(); spacer.se...

How to find width of JTextField given no.of characters?

I have a JTextField which can accept a fixed number of characters (eg. 10 characters). I want to restrict the width of the TextField to exactly take that many characters. So given the no.of characters, is there a way to find out the width (pixels) it will take? Assume that we know the font. ...

how to convert a RGB color value to an hexadecimal value in Java?

in my swing application i was able to get the value of JButton color in terms of Red green blue values and i have stored these values in three integers, how to convert RGB values into hexadecimal value. example i need in these format "#0033fA" ...

JTextPane editor large file & performance

Hi, I'm using a JTextPane to edit XML files. A jflex parser split xml file in tokens and using a custom document (extends DefaultStyledDocument) i color syntax: doc.setCharacterAttributes(token.getCharBegin() + change, token.getCharEnd() - token.getCharBegin(), Token_Styles_Define.getStyle(token.getDescription()), true); My p...

How to write directly to a JTextArea?

I want to write some text into a JTextArea. I think the answer is to extend java.io.Writer, but I'd like an authoritative answer here; is that the right thing to do? ...

How can I record a Java Swing GUI as a video file on Mac OS X?

My Java Swing application has an animated playback of a poker hand. I'd like to let users record this playback so that it can be sent to other people and played back in, for example, QuickTime. Any ideas how to go about recording a Swing JFrame over time? ...

Resize Swing component when content has changed dynamically

Hey, I have, the same issue with two components JTextField and JComboBox, I assume the solution I'm looking for would solve it for all components. I have set the size of the components to default thus their size fits the initial content I supplied to it. when I change the content of a component to exceeds the region of the component, I...

addMouseListener or addActionListener or JButton?

When defining the behaviour of a simple click on a JButton, which is the right way to do it? And, what's the difference? JButton but = new JButton(); but.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.out.println("You clicked the button, using an ActionListener"); ...

Marquee effect in Java Swing

How can I implement Marquee effect in Java Swing ...

Java GUI How to Popup Message Windows like MSN Messenger

My Java application sometimes stays at system tray, just like MSN messenger does. I need popup a window to display some formated texts. Sometimes there is more than 1 message entry. I need to display them all. I am new to jave Swing/GUI. Anyone has idea or experience on this? ...