swing

why doesnt setLocation() move my label

I have the following code where I try to place a JLabel in a custom location on a JFrame. public class GUI extends JFrame { /** * * @param args */ public static void main(String args[]) { new GUI(); } /** * */ public GUI() { JLabel addLbl = new JLabel("Add: "); ...

TableModel vs ColumnModel: who owns the column value?

What's the difference between JTable.getModel().getColumnName() and JTable.getColumnModel().getColumn(index).getHeaderValue()? The two don't seem to share any data. My guess is that TableModel.getColumnName() indicates the textual representation of a column while TableColumn.getHeaderValue() and TableColumn.getHeaderRenderer() determine ...

Transparency issue with overlay panel

Hello! I posted this question originally in the MigLayout forum since it is to some extend specific for that specific of Layout Manager, I'd say. Unfortunately it's a week old now without any comments at all, thus I'd like to repost the question here, in hope it's not considered X-posting. Well, I have the following problem: In general...

Eclipse: Java, no main method found

Ok I recently took all my code a manually imported it into an eclipse project from BlueJ, I then got use to the settings up "Run Configurations", finally thinking I was home free. Then I ran the code, and I got this error java.lang.NoSuchMethodError: main Exception in thread "main" so I figured I had to add a main method (I never had...

how to fill JTextFields with the columns of a JTable search?

I have a master/detail form with a JTable on top, and all the JTextFields corresponding below in the JPanel. I'm trying to make a search in the JTable, so that when the correct row gets picked, all the JTextFields can be filled with the column values. I don't know how can I call the rows programmatically to do so. How would it be done...

JTree node Rename

Hi Everyone, I am using a JTree and in this to raname a JTree node I am using right click(Rename through popup) or F2 key or double click. But problem is : when I rename a name and hit Enter key, node successfully renamed and when I rename a name and click anywhere on the frame(windows explorer style), node name does not rename. Please ...

Changing Delay in Java Timer

I'm trying to edit my timer so that every 25 times repaint() is called the timer firing speed cuts in half. So the first 25 times it's 500; then the next 25 times its 250; and so on. Two 'EASY FOR THE EXPERIENCED' questions: 1) Why is Eclipse making me make the variables static (or otherwise not compiling)? 2) The program doesn't seem...

Is it possible to add Textbox dynamically to JEditorPane

hi , iam new to Swings.I have a requirement. In my program i used JEditorPane to enter text.My requirement is when i perform any action a Textbox should come dynamically on left side of JEditorpane,which should be editable. please help me. ...

Automatically vertically resize JTable by contents

Hi everyone, Do you know any way of making a JTable resize itself up to a maximum predefined height and then provide scroll bars? ...

Scala MouseEvent - How to know which button was pressed?

I'm writing a scala application using scala swing. I can listen for MouseClicked to get notified whenever the mouse is clicked, but how do i know which button was pressed. The documentation is pretty bad, so i have looked in the Java documentation for MouseEvent, which says that the key can be retrieved from the modifiers field, so i tri...

Why does my new component not display in a null layout manager?

There is a panel in a JFrame called a WatchPanel extends JPanel which uses a GroupLayout and contains a WatchListPanel extends JPanel. The WatchListPanel uses a null LayoutManager and contains several instances of WatchItemPanel extends JPanel. The WatchItemPanel lays out its contents with a GridBagLayout. When I load up the frame and...

Problem with MouseListener on multiple JLabels

I have 5 JLabels inside a JPanel which is inside a JFrame. I am adding the JLabels using a for loop which iterates through an array of Colors: private JLabel target; // This is the origin of the first label added. Point origin = new Point(10, 20); // This is the offset for computing the origin for the next label. int offset = 200; f...

java swing vs mvc: is this pattern indeed possible?

Hi, I am new in swing, but managed to create a descend gui. My problem though is that I was not able to apply the patterns suggested in references/tutorials, mainly the MVC pattern. Is it me, or in JTree and using SwingWorker, it is not possible to have a clear separation of controller/view/model? For example I use a Swingworker, but t...

How best to manage Java Swing pop-up forms?

I am currently porting my Android app to a desktop app using Java (Swing, NetBeans). I need a main java window and several pop-up forms for user IO. In the android app I have been using activities, eg: startActivity(anotherActivity). I am currently using a JFrame for each pop-up form in the PC app I have been using setVisible to simulate...

java novice migrating objects from Swing to SWT

I am in the middle of converting an application that uses swing and awt to draw things to SWT. Since it's sort of overwhelming I'm going through, replacing all references to "awt" to the corresponding swt type. That works for rectangles (only a few methods had to be renamed) but there are some types I don't know how to deal with. If you ...

Simple way to have a hybrid JTextField / JPasswordField?

I am developing a simple applet that has a simpe sign-in interface. And to be concise in space, I have two JTextFields for username and password, which I also use as labels. i.e. to start with, the username JTextField will be pre-filled with grey text saying "username" and the password JTextField pre-filled with "simple password". Th...

What is the simplest way to implement a dynamic ComboBox using Java and/or Swing?

I need to create a combo box that can be modified by the user on the fly. I was able to do this in the android environment (Swing ComboBoxes seem to be the same as Android spinners) like this: final Spinner spinner = (Spinner) findViewById(R.id.spinnerI); String[] strings = configuration.getNames(); ArrayAdapter<String> adapter = ...

JDialog in front its JFrame parent

I want to create in Java Swing a JDialog which, when it's open, its parent window cannot be accessed (just like when you open the file explorer dialog in Microsoft Word). Is there any method in the JDialog class that provides this behaviour? ...

swing: creating "record" and "stop" buttons

I see that there is a JButton constructor which takes an Icon as a parameter... but how do I get an Icon from a bitmap file? Also, are there "record" and "stop" Icons available from the default look and feel? or do I have to provide them myself? ...

How can I ignore any KeyListeners that may have been added by client programs when certain conditions are met?

I haven't had any luck with the web as far as this is concerned, the closest I've come is to read up on the EventQueue, but I can't seem to find a way remove an event by default. I've overloaded a JTextField so that it displays the remaining characters in a "guessed" word (part of an auto complete component) and when "Enter" is pressed ...