swing

Vertical progress bar in swing?

I need a veritical progress bar in swing to display a temperature in one case and a voltage in another. How can I accomplish this? Can I set the progress bar to a vertical mode? Can I use the slider control in a read only mode in which it id not adjustable? I was thinking I could simply set the slider to the actual value when the user...

CardsLayout in Java Swing

I have taken a JPanel (say cardsPanel) and have set its layout as CardsLayout. After that I have added 3 cards on it (say card1, card2, and card3) all of JPanel type. Now I want to get the topmost card of the cardsPanel whenever a user clicks on a button "Show". So, How can I get the top-most card of the cardsPanel. ...

why the frame will confused!![:-)]

Hi, these are my classes.when i run my MainClient class,one frame will be shown that get text from client and then send it to the server.at the first time when i click on the Send button,it will work correctly and send data to the server but suddenly the frame will confused and I can not do any thing like writing or clicking on the butto...

Java localizing number formatting

Java uses period in decimals, e.g. 1/2 = 0.5 Is there any way to make it use comma instead, as in 1/2 = 0,5? And not to use comma for thousands (as in one hundred thousand = 100,000) but use space instead (100 000)? When it comes to output I suppose I could use all sorts of string format functions, but the problem is input (JTable). ...

JLabel is not repainting

I am doing an animator showing a series of .jpg. The animator is a thread which is running as it is updating the other JLabel which I use to display text. But it just will not repaint the ImageIcon. The thread class is txAnimate. What's wrong? public class main extends JFrame implements ActionListener, ItemListener, ChangeListener { ...

How to abort windows shutdown in a swing application?

I have a swing application and I want to present a confirmation box to user before the application is closed on windows shutdown and if the user selects cancel, the shutdown process should abort. I went through couple of discussions in the forum but couldnt get a concrete answer. If anybody has successfully implemented this requirement,...

Moving JLabel with arrow keys

Sorry, for double posting, already posted this question once, but I realized I weren't explicit enough. I still haven't managed to find an answer to my question so I'll try to better describe my problem here: I have the following classes: public class Paddle extends JLabel {} public class Canvas extends JPanel implements Runnable {} ...

Java swing "children" windows

Sorry for really simple question, but I wasnt able to find anything in the net, probably because I dont know the right terms to look for. When you have a desktop application, there are many so called children windows: one for options, one for "about" and so on. How to make them in Java Swing (with NetBeans tools - optional)? So far ...

Respond to events in other JPanels

Ok so lets say I have 3 Jpanels - 1 parent and 2 Children //Assume necessary imports etc parent is something like: public class ParentPanel extends JFrame { private JPanel mainPanel,controlPanel; public ParentPanel(){ MainPanel pp= new ParentPanel(); controlPanel cp = new controlPanel(); } ... Main Panel in real thing is ...

SerialPortEventListener from another class....

basically my program should display a frame in which a panel draw a point on the screen according to "input" data (integer values) coming from a serial connection on my pc. The problem is: how to "transfer" values from the serial port to the OTHER class Frame and call the REPAINT() method?????????? Given that via console I receive ever...

Java Swing: A list of all UIDefaults properties

Question: Where can I get a list of all UIDefaults properties that exist in Swing? I know of the possibility to write a small snippet of code that just extracts and displays them but I would like to know whether the list I get that way is really complete. When I do so, I get 636 properties for the Metal L&F, 613 for Windows L&F and 550 ...

Using IP 127.0.0.1 for network communication

I have created a list of my friends' names. By clicking on their names one frame should get opened for me and a second one on the machine where the friend has the same application running.Just like the chat window in a messenger application. I use the IP address 127.0.0.1 fort this. Will this wor? this is my list action performed: priv...

opening 2 frames just with one object

Hi, this a a part of my code ,but i don't know that why it shows two chat frames for me when i click on the list? also this is a client/server application with 127.0.0.1 IP address.would you please help me? private InformationClass client; private static DefaultListModel model = new DefaultListModel(); private ListSelectionMode...

How to set a backgroud color of a JButton in Java?

I am developing a Java Desktop Application. In it I have 4 JButtons on a JPanel. Now I want that whenever a button is clicked its background color changes to some other color (say orange) to represent that it has been clicked and the background color of all other 3 buttons reset to their default color (in case any of them had Orange back...

Migrating Oracle Forms to Java

Does anyone know an automated solution to migrate Oracle Forms to Java desktop forms (e.g. a code generator whose input are Oracle Forms definition files and output is Java code in AWT/Swing/SWT/whatever)? Preferrably open-source or free, but commercial ones are also a possibility. ...

How to convert a JButton into JToggleButton in Java?

I have created hundreds of JButton using Netbeans in my Java Desktop App. Now I want to replace all of them with JToggleButtons. Can I do that by selecting all the buttons in the "Inspector" window of Netbeans and perform some task? Is there any short-cut method? It will take a lot of time to manually replace all of them. ...

Add a new line to the end of a JtextArea.

I have a text area with some text in it and I want to add some lines to it again, (the first lines + the other lines that I want to add) but it doesn't work. The way I'm doing it right now erases the old text and shows just the new lines. ...

JOptionPane customize input

All I want to do is have a JOptionPane inputDialog with a JTextArea instead of a JTextField. I tried putting the JTextArea inside of the Message parameter like so Object[] inputText = new Object[]{new JLabel("Enter Graph Information"), newJTextArea("",20,10)}; graphInfo=(String)JOptionPane.showInputDial...

How to add add a TreeModelListener to the NetBeans Outline?

I'm using the NetBeans Outline model to create a TreeTable, the technique is described here: Everything looks nice and clean and I now want add a TreeModelListener to my model to listen for changes in the model: Outline outline = new Outline(); MyNode root = new MyNode("data", 0); //... TreeModel treeMdl = new MyTreeModel(root); Outli...

If Swing models' getters aren't thread-safe, how do you handle them?

It is well known that updating a Swing GUI must be done exclusively in the EDT. Less is advertised that reading stuff from the GUI must/should also be done in the EDT. For instance, let's take ButtonModel's isSelected() method, which tells (for instance) ToggleButton's state ("down" or "up"). In every example I've seen, isSelected() is...