swing

How to retrieve header values from JTable

Hi! How can I retrieve the header values from a JTable? Thanks. ...

Java Swing: How do I define one minimal dimension (of the two) for components?

To define minimal size successfully, I have to do the following: // setting minimal width AND height Dimension min = new Dimension(100, 100); comp.setMinimumSize(min); comp.setPreferredSize(min); comp.setSize(min); When I left one line out it doesn't work, which is strange, but it's not the point. What do I do to limit just one of tw...

Resizing panel with flow layout does not invoke the scroll bars

Hey, I have a containing panel JPanel with a Flow Layout, the containing panel is in a JScrollPane, the containing panel holds a bunch of other JPanels, inner panels, in it. All the inner panels have the same dimensions. If there are more panels then the containing panel can hold in its width then they are gridded downwards, and if ther...

Java: adding Image to JTable ?

I have a big button when clicked , adds an image to a table class BigButtonListener implements ActionListener{ Image screenshot=null; Browser bigbrowser =null; BigButtonListener(Browser browser, DefaultTableModel dataModel, DefaultTableModel historyModel, JTable dataTable, JTable historyTable) { screenshot = browser.toImage(tr...

connection with LDAP Server using java swing application

I am trying to make a tool in swing for end user to use some specific web services..!! but got stucked in first phase..User authentication !! I want to authenticate the user with LDAP ..Please provide some efficient code snippet or Idea that i can authenticate my user for furthure processing. i have been working with swings only so still...

JButtons dont get the Correct Size and Location

Hello I have a Problem with some Buttons I would like to create a simple GUI with JButtons but when I start the App the Buttons Positions and Size changes every Time when i start the App. I use this Code: usr_in.setSize(120,40); usr_in.setLocation(10,40); usr_in is a JButton Created Like this: JButton usr_ro = new JButton("Use...

Java KeyListener not firing on JSpinner

Hi, have tried a few different approaches to this but with no success so far. Just wondered if I'm missing anything. I have a JSpinner which is a component of a DateSelector widget alongside a Calendar. I am trying to fire a validation method if the user changes any text in the JSpinner instead of using the Calendar control or the JSpinn...

Is there a simple way to know if a modal dialog is currently displayed?

Is there one method in AWT or Swing to either tell me if there's a modal window (or multiple) up, or to return an array of them? I looked in Window, Dialog, JDialog, SwingUtilities, etc. but couldn't find one. (I know I can loop through Window#getWindows and check Dialog#isModal.) ...

JSpinner.DateEditor must include year even though start and end is the same year

I have a JSpinner using a SpinnerDateModel which has a start at Jan 1, 2010 00:00:00.000 the end date is Jan 1, 2010 00:12:34.217. I would like my JSpinner.DateEditor to use the format HH:mm:ss.SSS but the spinner doesn't spin with this format. It only spins when "yyyy" is added to the format. How can I get around this? import java.awt....

Custom UI painting problem

I have a JInternalFrame that I am applying a custom UI to. The UI paints the component, but when I add a JPanel to the JInternalFrame it doesn't show up. I think the UI is paining over the whole component, but how do I paint the UI THEN paint the components? But if anyone has a better way of doing this, please let me know! Thanks! publ...

SingleFrameApplication that does NOT require ALT to activate menuitem mnemonics?

In the NetBeans 6.9 IDE, if you create a New Project >> Java >> Java Desktop Application and run it, you will find that the menu items have mnemonics, but only after ALT is pressed. (The netbeans program itself uses this style of menu.) However, if you create a new File >> Swing GUI Forms >> JFrame Form, and add a simple menubar with m...

MCE remote control and JAVA

hey i barrow an MCE remote control from a friend , i am trying to control a swing application using MCE remote control. i am listening to KeyEvent (keyboard) coming from the Remote Control i have no problem with basic buttons like up down left right ,ok pressing other buttons will process KeyEvent with a KeyCode of 0 other button will ...

store state/expanded nodes of a jtree for restoring state

Hi, I am working with JTree. I would like to know what is best the way to know which nodes are expanded in a JTree, so as to save its state (i.e. save all expanded paths). So that if I call model.reload() the Jtree would not stay collapsed, but I will be able to restore its original state to the user. I.e. all expanded nodes will be ex...

Get return value from new class with gui

Hi all, I have a class that extends JFrame to make orders. in the middle I have a button that opens a new window that is used to find an article. What I need is: When I click btnNewArticle, after searching new article, and confirm in new window, I will get as return article code. Click btnNewArticle --> (open new window to find an ar...

JTable add rows bottom up - rows added one after the other should appear at the bottom of the last one but all should be bottom aligned

I have a JTable in Java swing which needs to be bottom aligned. As in normal tables when a row is added to the table it is placed on top, when the next row is added it is added under it and so on. What I would like to do is place the new row at the bottom of the table. When a new row is added I would like the new row to be placed right...

returning the dialog from JOptionPane.showOptionDialog

I have created in Java swing an option dialog with the JOptionPane.showOptionDialog method. This dialog includes different buttons, and among those a Cancel button. I would like to attach a listener method to this Cancel button so that once selected, the dialog is disposed. My question is: how do I "retrieve" (or return) the dialog gen...

calling one JApplet form from another

Hi I have created all my project files as swing applications, i.e files extending JApplet, how to call one JApplet file from another? i kow set visible methods are there for jFrame but now i dont have time to convert everything to convert, please help as soon as possible ...

Retrieve JTextField text value

Hi! I'm trying to retrieve the text value from a JTextField but first I need to cast a component object (java.awt.Component) to a JTextFiel... mi code is like this Component[] x = this.getComponents(); for(int i = 0; i < x.length; i++) { if (x[i] instanceof JTextComponent) { //retrieve text...som...

Non-blocking modal Swing progress dialog

A daft question, but I really cannot get this to work: I have some long-running process in a Swing application which may take several minutes. I want to display a progress dialog to the user while this process is ongoing. I also want to prevent the user from performing further actions, eg pressing a button while the process is going on. ...

Why is this JPanel not sticking to the specified size?

So, I'm trying to learn Java Swing and custom components. I've created a JFrame, given it a background color, and added a JPanel: JFrame frame = new JFrame("Testing"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(1000, 2000); frame.setBackground(Color.WHITE); JPanel jp = new JPanel(); jp.s...