swing

Synth LaF JLabel DISABLED color

Hi all, Using the Synth LaF, I am unable to set a JLabel's FOREGROUND color for the DISABLED state. has anybody succeeded in doing this? Here is my label's style definition in my LaF.xml file. <style id="whiteLabelStyle"> <opaque value="false"/> <font name="Bitstream Vera Sans" size="16" /> <state> ...

Java Swing GUI - Problem

I have created a GUI in Java using swings with the help of Netbeans IDE. Now the problem is when I click on "Preview Design", the look and feel of the GUI is that of my O.S i.e Windows XP but when I click on "Run" button to run the application, then the look and feel of the GUI is metalic. How can I set the tone of the GUI. (It would b...

Using Java's JComponent repaint()

Hi there, I'm writing a simple Game of Life program in Java and am having a bit of trouble getting it to animate. I've got a JComponent class LifeDraw, which displays a grid of pixels, with the following paint method: protected void paintComponent(Graphics g) { super.paintComponent(g); for (int y = 0; y < lGrid.getHeight(); y+...

Java JTabbedPane questions

I'm using a JTabbedPane to hold each step in the wizard that I am building. Navigation between steps is doing using the Previous/Next buttons or by selecting a tab. The buttons decrement/increment the JTabbedPane's SelectedIndex. I need to validate each step before proceeding to the next step. Essentially, I'm having difficulty deter...

Java: GUI component for displaying diffs?

Hello, I'm writing a programm in which I need to generate a diff and display the result. Is there any GUI component out there, with which I can easily accomplish this task, or do I need to hack something for myself? I'd prefer using a Swing component, but any other technology will be fine, too. ...

Swing: Setting a function key (F2) as an accelerator

I have a menu item, "rename", for which F2 is set as an accelerator. Indeed when the menu is displayed there a little "F2" indication next to "rename". Sadly, this does not work. This accelerator triggers no response. When I change the accelerator to CTRL+F2 - it works. It seems that I should use an InpoutMpa/ActionMap. The problem wi...

Why does my icon handling code throw a NullPointerException?

I have added an image for my button,but when I run that frame this exception will be thrown .why?please help me. init: deps-jar: compile-single: run-single: Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at javax.swing.ImageIcon.<init>(ImageIcon.java:138) at ClientGUI.IdAndPasswordFrame.initCompon...

JEditorPane do not respect html table height 100%

Hi Stackoverflow, i have got a problem, my JEditorPane do not respect HTML-Table style="height: 100%;" do you have an idea? JEditorPane jEditorPane = new JEditorPane(); JScrollPane scrollPane = new JScrollPane( jEditorPane ); jEditorPane.setPage( url ); JFrame frame = new JFrame( ); frame.getContentPane( ).add( scrollPane, BorderLayou...

swing text editor that color and highlight.

hi, i am writing an application that the user need to writes a javascript script as an input, right now i have a simple JTextArea but i would like to change it with something that will do some highlights and code coloring to make the script more coherent. do you know any open source thing that does that? thanks ...

Embed Firefox browser in Java Swing

I am wondering if it is possible to embed Firefox browser as a component in a Java Swing based application. I have done a bit of research from the Internet, but I could not find an answer. Some people suggest to use other browser component avaiable in Java. I do not think that is preferable, as the rendering engine would be different to...

How I can add JScroll bar to NavigableImagePanel which is an Image panel with an small navigation view?

Hi, I have the following NavigableImagePanel, it is under BSD license and I found it in the web. What I want to do with this panel is as follow: I want to add a JScrollPane to it in order to show images in their full size and let the users to re-center the image using the small navigation panel. Right now, the panel resize the images ...

Java: MiGLayout: How to use `hidemode`?

Hi, I am starting out using MiGLayout for my GUI design, and one of the feature I would need is to show/hide certain components based on the state of other components. I was going to code this myself, when I noticed that one of the Component Constraints supported by MiGLayoutis hidemode. Does this do what I think it does? If so, how d...

displaying an image in swing

I'm developing a Snake game. Instead of showing moving rectangle, I'm planning to show a picture and want to move it with keystrokes. but I can't do it with Jlabel. since labels are static in position. Is there any way to display them as a image only?? thanx. ...

Can I add a button to a JTable column header?

I have a JTable where the first column in each row is a checkbox. The user can select and deselect individual columns. I've got this working. Now I'd like to add to the column header a checkbox which can be used to "select all" and "deselect all". I'm puzzled in how I should go about doing this. I can't work out how to put a component o...

Java OutputStream equivalent to getClass().getClassLoader().getResourceAsStream()

I am attempting to Store() the change made to my application's Properties. The .Properties file is located in 'resources' package, which is different from the package that contains my UI and model. I opened the package using: this.getClass().getClassLoader().getResourceAsStream("resources/settings.properties") Is there a functional e...

Making an Unfocusable Window in Java

(SOLVED: a WindowStateListener and a deferred call to toBack whenever the window is focused) Hello all! I've been trying to figure out how to make a java.awt.Window (any subclass will do) so that it cannot be brought to the front. I'm working on a Java "Samurize-like" program that appears below all the application windows and displays ...

Java Swing: dispose() a JFrame does not clear its controls

I have a closeWindow() method which uses dispose() for the current JFrame to close down. When I show the window again, the controls (textboxes, lists, tables etc.) still have their previous values in place that were there when I dispose():d the frame... Why is that? Is there another way to completley close and clear a frame? This is the...

Usable frame size and Windows Manager frame size

Hi, I'm setting a JFrame size with myFrame.setSize(Xsize,Ysize), but it gives me a problem : this doesn't define the usable space in the frame but the whole frame's size (it include the Windows Manager frame size, which isn't always the same). Is there any way to define the JFrame size by defining the usable space size ? ...

Maintaing JTextArea scroll position

I have a JScrollPane with a JTextArea set as its view port. I update the (multi line) text shown on the JTextArea continously about once a second. Each time the text updates, JScrollPane goes all the way to the bottom of the text. Instead, I'd like to figure out the line number that is currently shown as the first line in the original ...

JComponent not displaying text - Swing is pwning me!

Hello, everyone, I'm a High School AP Computer Science student doing an independent study project in Java. I have chosen to write an application for beginning piano students in which the computer displays a picture of the keyboard with a note highlighted. The user then selects the name of the note that corresponds to the highlighted key,...