swing

Java Swing JList

Hello. I'm trying to make a JList to display the contents of an array. The array itself is not an array of strings, however, but an array of Objects. Is it possible then, to use the same array of objects as the parameter to construct my JList (if the Objects are given a toString method)? Thanks. ...

Java Swing Updating JList

Hello again. I'd like to know if there is any way that I can update a Jlist after the user adds or removes an item to it and after a user sorts it. Is there any way that I can write a standardized method to update the display based on the order of items in an array or vector, and when the user remove or adds an object from the array tha...

Updating position of JSlider Swing

My apologies for posting tons of questions as of late. I'm trying to get a JSlider to update its position based on a constantly updating variable. The setValue(n) method doesn't seem to work. Is there any alternative? We're using this as a time marker for a music player. ...

Use default KeyMap of native OS

In Java, by using non-default system look and feel we will have different keymap. For example I'm using Mac OS X and use Substance look and feel (non-default system look and feel). The effect is I'm loosing my "meta" key for select all on text component In mac os x should be "meta + a", but using Substance we have to use "ctrl + a" (and...

Java Swing JEditorPane: manipulating styled documents

I have model that is a queue of Strings associated with enum types. I'm trying to display that model in a JEditorPane, with each element in the queue as a separate HTML paragraph that has attributes based based on the associated enum type. However, my updating methods are not doing what I want. I tried writing the HTML strings directl...

while loop ignore the event listener

so when i run this code to try to change the background the GUI crashes and gets stuck in a infinite while loop ignoring the event listeners. here is the code: private Panel getPanel1() { if (panel1 == null) { panel1 = new Panel(); panel1.setLayout(new GridBagLayout()); while(frame.isVisible()...

How can we make a movable sentence?

for example I want to have a sentence like "System" in my main frame which can move from left side of the frame to the right side of the frame or up to the down.how can I do it?? ...

Cannot set mnemonic in JLabel with HTML text

The following associates a JLabel with a JTextArea and sets a mnemonic that decorates the label. Pressing Alt-X on Windows moves the focus to the JTextArea. JTextArea textArea = new JTextArea(10, 20); JLabel label = new JLabel("Text"); label.setLabelFor(textArea); label.setDisplayedMnemonic(KeyEvent.VK_X); However, if ...

Java Architecture - Question about ActionListener Conventions

I am making a user interface which shows graphs and manipulates graphs. The class extends JFrame implements ActionListener. The ActionListener then calls different classes to manipulate graphs depending on the action. This worked while the class had few ActionListeners; however, now the class is becoming unmanageable. I know that in the...

only JLabel not showing up...

I am writting a simple application which has a button that opens a new window then display a simple GUI/Text to acccept inputs from a user. but for some reason, I can get JLabel to be displayed on the new window. The application has following structure: +mainFrame - JFrame +newFrame - JFrame -+newPanel - JPanel ----title - JLabel ...

Getting raw text from JTextPane

In my application, I use a JTextPane to display some log information. As I want to hightlight some specific lines in this text (for example the error messages), I set the contentType as "text/html". This way, I can format my text. Now, I create a JButton that copies the content of this JTextPane into the clipboard. That part is easy, bu...

Delay between drawing of two icons in Java

I have a piece of code in Java which draws 2 icons to the screen. I want to enforce a delay between them, and am unsure of the best way. At the moment I have; cell.setIcon(image1); Thread.sleep(500); // Ignored try() for brevity cell2.setIcon(image2); But this seems to cause the delay before either are drawn. Why is this, and how can...

Auto complete textbox in Java Swing

Is there any good ready made Java Swing component that can be used to implement auto complete textbox? ...

threading issues with java swing and web start

EDIT: After fixing a few issues, the bigger issue that I am having is being caused by Apache POI which I am using. I am working on figuring that out now. Apparently it is being restricted by the Sandbox. I'm very new to Swing, and created a small Swing app that I now need to have run via web start. I'm trying to use the FileOpenService ...

Adding a clickable, action-firing JMenuItem directly to a JMenuBar?

Is there a way to add a JMenuItem (or similar button-type object) to a JMenuBar? Adding a JMenuItem doesn't play well with the layout of a JMenuBar, and buttons look too button-like. Should we be tweaking the button to look like a JMenuItem or tweaking the JMenuBar to display the JMenuItem correctly? Or something else altogether? ...

Capturing the close tab event of a JTabbedPanel in Java Swing

Is it possible to capture the close tab event for a JTabbedPanel in Java Swing. I want to check for some conditions and if they are not met, then I have to prevent the user from closing it. Thanks! Update: I created a custom event, based on this code and it solved my problem. ...

Creating a Squircle

Hello there. I'm a first year programmer. I'm trying to create a squircle. (square with round corners). So far i have managed to get. I have been given the constants of a,b and r. If anyone could help i would be really thankful. I'm a total noob to this. So be nice :) package squircle; import java.awt.*; import javax.swing.*; import ...

When creating a custom Toolkit, why does createFrame fail on OSX?

We are trying to extend the UISpec4j testing framework to display the user interface when running tests. So we have a custom toolkit that wraps around the native toolkit for the relevant platform. We managed to get everything working well on windows XP, however when testing our changes on OSX, our extension of createFrame appears to beha...

Swing application framework for multilanguage application

Can the swing application framework be used to implement multilanguage swing applications? If so, how should it be done? Should I use multiple .properties files, one for each language? How can I let the system know which properties file to use then? Does anybody know a good tutorial for this? ...

Preventing the selection of next cell in JTable while using AutoComplete

Hi, I am using GlazedList's autoComplete support in a JTable using the below code itemColumn.setCellEditor(AutoCompleteSupport.createTableCellEditor(itemList)); How do I prevent the selection or editing the next cell, if the user hasn't selected any value in the CellEditor. ...