swing

Swing Generator

Hi, I need to develop some java gui using swing. A few years ago I did develop a bit with swing. But it was pretty exhausting, you see, back than there weren't much tools to help you. But I do believe today it should be easier, there must be tools. I would like to use some kind of a generator or maybe a utility or even a framework. I kn...

Change the direction of growth for a JTexField object.

Hi SOers, I need to change the direction of the growth of JTextField object when more characters are added to it. Currently when I add more stuff to it, it grows from left to right but I need this growth of the bounds of the JTextField from right to left. For e.g. when I add "StackOverflow" to this JTextField the o/p is, <empty space>St...

setDataVector - javax.swing.Table

i had a situation where i had to use this setDataVector function. I was puzzled to see there was an extra second argument(Vector columnIdentifiers) in the function. I'm just resetting the data. Why do i need to send the column identifiers?? And it doesn't take the old column identifiers by default if i don't pass the second argument. Irr...

Using Java and its SWING library.

I am trying to code a very simple form using java but i am running into more trouble than i expected because of the way swing lays out components, I have tried various different layout managers and still cannot layout the form the way i would like. Here is how i would like the form to look: link text Does anyone have any ideas about h...

Launching jEdit From Java Swing App Using Runtime.getRuntime().exec()

I'm writing a Java Swing Application running on Red Hat Enterprise Linux 5 server that I would like to launch jEdit to view log files. Here is some example code. public static void main(String[] args) throws IOException, InterruptedException { String cmd = "sh -c \"java -jar /tmp/jEdit/jedit.jar /tmp/test.txt\""; System.out.p...

Is it safe to dispose a JFrame from a different thread in Java?

Is it safe to call the dispose() method of a JFrame from a different thread (not the EDT)? ...

Performing an action when an JMenuItem is clicked?

So i have made a simple program with a basic menu at the top of the frame, Now i just need to put actions behind each JMenuItem. Im struggling to work the code out though, Here is what i thought would work: JMenu file_Menu = new JMenu("File"); JMenuItem fileExit = new JMenuItem("Exit Program"); file_Menu.add(fileExit); fileExit.addActi...

MVC Framework for Swing

Is there any MVC framework for Java SE application ???? if we use Java EE we can use Spring or Struts, How about Java SE ? ...

How to auto resize JFrame according to content

I have created a custom JPanel that displays images (lets call it MyPanel), I have added this to JFrame's contentPane. I want JFrame to be resized automatically to fit the MyPanel when image changes. It looks like I need to call frame.pack() to do this. Calling pack() from MyPanel increases coupling so I don't want to do that. To solv...

Putting the contents of a JTextField into a Variable - Java & Swing

So i creating a little java app and am just wondering how i can get the contents of a JTextField and then assign the value into a String variable, I thought below would work: JTextField txt_cust_Name = new JTextField(); String cust_Name; txt_cust_Name.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ...

java swing repaint()

(second question in a few hours) Kay so I'm making a chess variant in java, I have my console program working how I want it but now I'm trying to convert it to a swing GUI while STILL keeping the console things intact. So up to now I have my array of squares with pieces in them for the console, and a 2-dimensional array of JPanels with ...

java.lang.ArrayIndexOutOfBoundsException: 0 >= 0 attempting to populate JTable

I'm subclassing JTable and using a DefaultTableModel to model my table data. The following class sets up the JTable, and adds one row to the model. import java.io.File; import java.util.Iterator; import java.util.Vector; import javax.swing.JTable; import javax.swing.table.DefaultTableModel; import javax.swing.table.TableColumn; pub...

How do I find the current focussed InternalFrame?

I am having multiple InternalFrames (JIF) added to a desktop manager. How do I know which one has the focus at the moment? ...

Maintaining a single instance of JInternalFrame?

Hi Everyone, I have an application which opens multiple JIFs, But I only want to create a single instance of the JIF, so I use these function to check that, and I use dispose to close the JIF after a key is pressed(JDesktopPane.getSelectedFrame().dispose()). However after 2-3 successive disposes, it doesn't create a new JIF? Am I doing ...

How to stop repeated keyPressed() / keyReleased() events in Swing

So the problem that I am having appears to be a bug that occurs only on Linux. I'm trying to have my swing app record when a key is pressed down, then to detect when that key is released. Now that shouldn't be in issue because KeyListener is supposed to handle this for me. The problem is that when I hold the key down I get lots of repea...

Java JTextField with input hint

I would like to add a hint value to my JTextField. It should look like Firefox rendering of <input type="text" title="bla">. This creates a edit field with the text 'bla' in the background. If the textbox has focus the title-text disappeares and just reappears if the user leaves the editbox without text. Is there a (free) swing componen...

how can install swing/matisse on eclipse?

i tried this link: http://downloads.myeclipseide.com/downloads/products/eworkbench/discovery-6.0/ but i'm fail how is this? ...

How to synchronize Swing model with a rapidly changing "real" model?

As is widely known, anything related to Swing components must be done on the event dispatch thread. This also applies to the models behind the components, such as TableModel. Easy enough in elementary cases, but things become pretty complicated if the model is a "live view" of something that must run on a separate thread because it's cha...

auto abbreviating JLabel

Hi all, Anyone written a JLabel (extension/util/??) that automatically abbreviates the contents depending on it's preferred/visible size? much appreciated. ...

What's wrong with this colored JTree? (custom renderer problem)

Hi, I want write custom TreeCellRenderer to have Root, nodes and leafs in different color. This is my code: tree.setCellRenderer(new DefaultTreeCellRenderer() { @Override public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) { { ...