swing

Java Swing; How do I make it so the program starts on the right most hand of the screen?

By default, my Swing program starts at the top left hand side of the monitor. Is there a way to make it so it pops up at the right hand side? What about dual monitors? Can I get it to pop on the right monitor? Thanks. Carlo ...

Creating a JDialog with three related lists

I am an inexperienced Java Swing developer and I need to create a JDialog which displays three different lists of data. The user's selection of an item in the first list will update the content of the second list and the selection of an item in the second list will update the content of the third list. Also when the dialog is launched th...

pre-wrap in a JEditorPane

I am using a JEditorPane to show styled text and I am also using the <pre> tag to preserve all the whitespaces in the text. The problem is that I want to have the JEditorPane to wrap the text lines, but the HTMLEditorKit (or a related class) does not wrap text inside a <pre> tag. What I mean is that I want a behavior simitar to the styl...

Java Swing; Problems with Java GraphicsConfiguration.getBounds() returning 0.

It seems that the .getBounds() method of the GraphicsConfiguration class is not reporting the correct values. GraphicsDevice[] gdArr = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices(); int width = 0; for (GraphicsDevice gd : gdArr) { if (gd.getType() == gd.TYPE_RASTER_SCREEN) ...

how to modify the values of other fields in JDialog box based on the value in combo box

I am making a dialog box for the application.And I want to fetch the values from the other fields(such as textField) based on the value of combo box. Can anyone please tell me how to link both of these components? -Thanks in advance ...

Solved: Why does JComboBox seem to add multiple item instances?

This Java Swing JComboBox is modified based on changes to the system configuration. In the example image, "Press to Select" is the case where nothing is selected and there is one "Test Unit" in the configuration, but "Press to Select" is displayed twice in the drop down. The additional "Press to Select" item behaves like item 0 so it is ...

java swing: how to create dynamically columnizing table ?

How would you go about creating a java swing table, which automatically creates a new column whenever a column item is added ? For example, adding "Id", would intially add a Id column table. adding "title" would add "title" column table. any examples or library that can handle this already ? Also, how would you also display an image in...

Multi Columns Combo Box for Swing

Hello, currently, I am looking for a multi columns comb box components which can place in my Java Swing application. Currently, I use combo box as auto complete drop down list as user is typing. Is there any available GUI component, which enable me to have the following (multi collumns)? As you can see, there are 3 columns in the dro...

Adding spinning tool in jDialog in java

Hi All, I am working in a desktop application. In my application i am performing login operation where user enters his id and password. Login page is created in java swings using jDialog. When user enters his credentials, it takes few minutes to validate user. i want to add snipping tool with message "Please wait" which will be display...

How do I draw colored circles in Java on a JPanel?

Hey everyone, I'm doing another Java project for my class. In this assignment, we have to create a checkerboard and populate it with the appropriate number of checkers. I built the checkerboard correctly which displays nicely, but I'm having a hard time using the Graphics class to draw. Here's the code that I have so far: import javax...

can we zoom in zoom out the drawing we draw on the Canvas?

We have an old (more than 10yrs old) Java Swing applicatin which draws lots of circles and connections (lines) between those circles on a JCanvas (a subclass of JComponent) based on lab data. Because the data becames bigger and bigger, we cannot display the entire drawing now. We have put the JCavans into a JScrollPane but it is not con...

I am trying open a JPanel from another frame. Not able to do so.

I am creating a program for database manipulation with proper GUI and all. I am using swing for the same. Anyway, when I run the app, the following window opens: public class MusicShopManagementView extends FrameView { public MusicShopManagementView(SingleFrameApplication app) { super(app); initComponents(); // status bar...

Weird behavior of a MouseListener added to a JTable

I've hooked up a mouse listener to a JTable to call some stuff when mouse cursor leaves table's bounds. However, mouseExited() method is also called when the mouse cursor is leaving individual cells of a table. Is it some strange quirk in my code or a bug in Swing? EDIT: I didn't mention that my table is a subclass of a JTable and not a...

Java Swing - Display table in sub menu

I have a menu that displays say Item1 Item2 Item3 etc. Clicking on Item1 should display me a Table with 2 columns. I tried something below with displaying just a label. But the label gets displayed somewhere in the screen where as I am expecting it to be a submenu under menuitem1. JMenu mainMenu = new JMenu("MainMenuHeader"); JMe...

Sending keypresses to JTextField

Hi, I'm trying to simulate text input into a JTextField. I've got a 1 char long string containing the letter I want to add and I run: receiver.dispatchEvent(new KeyEvent(this, KeyEvent.KEY_TYPED, 0, this.shifted?KeyEvent.SHIFT_DOWN_MASK:0, KeyEvent.VK_UNDEFINED, text.charAt(0))); But this doesn't seem to change the contents at a...

how to make child dialog poped-up from and embedded into the parent window by double clicking it in Java SWing?

I want a main window with several child widgets and i want the child widget to be shown in the main frame at the same time and they can coordinate with each other to layout through the main window area. When i double click the child widget it can pop-up and when double click again it can embed back. I have done this in QT by QDockWidget ...

positioning with Java Swing

I'm new to Swing. This is the code I've written import java.awt.*; import javax.swing.*; public class NewMain { public static void main(String[] args) { // TODO code application logic here JFrame frame = new JFrame("test"); frame.setVisible(true); frame.setSize(300,300); frame.setDefaultCloseO...

Creating JButtons in Java

Hi, I'm fairly new to Java and I've been having some difficulties with Swing. I'm trying to create a very simple GUI program which should be create a set of buttons but my code doesn't work. Here's my code; myPanel = new JPanel(); JButton myButton = new JButton("create buttons"); myButton.addActionListener(new ActionListener() { ...

How to enable drag-and-drop inside JList

I have a JList and want the user to be able to reorder the elements in the list using drag-n-drop (using my own ListModel and ListCellRenderer, if that makes any difference). Which Objects do I need to create, and how do I process the action? ...

Swing Scrollable problem

I have a weird problem viewing a JPEG image by implementing Java Swing Scrollable interface. My code allows me to draw a rectangle on top of the image using left-mouse button. Everything works ok if I don't touch the scroll bars. But as soon as I scroll down, a rectangle gets drawn on a different location. Basically if I move the top-...