swing

Closing a dialog created by JOptionPane.showOptionDialog()

I am creating an options dialog using JOptionPane.showOptionDialog(...); For the options parameter I am passing an array of JButtons each with its own ActionListener. One of these buttons is responsible for closing the dialog. My question is: what code do I place in the close button's event handler to close the option dialog? A poi...

Adding a scrollable label to an option dialog

I am creating an options dialog using JOptionPane.showOptionDialog(...) When I click one of the buttons added to this dialog, I need a label to apear underneath on the dialog (and this label should be scrollable if necessary). I have written event handlers for the buttons, but I am not sure how to get this label to appear on the dialog...

How to update JTree elements

Hi guys I use JTree with TreeNode which extending DefaultMutableTreeNode.when I add new node,i cant update JTree.Any help will be appreciated ...

swing: event listener support class

Is there any preexisting class that helps support add/remove EventListener operations? (kind of like PropertyChangeSupport) I'm trying to partition my code into a model and view in Java. I have some data that arrives erratically, and would like the model to support some kind of EventListener so that a view can subscribe to changes in th...

Java - SwingWorker - problem in process() method

I am using javax.swing.SwingWorker for the first time. I want to update a JLabel from the interim results published by the swing worker as follows: publish("Published String"); Now to update the JLabel, I have coded the following: process(List<String> chunks) { if (chunks.size() > 0) { String text = chunks.get(chunks.siz...

Where are the really high quality and complex Swing components?

Looking at Swing, I have the feeling that it comes with many useful and reasonable atomic components in its core. And when I look at the Web there are hundrets of quickly plugged together components (among them many date/time pickers, pimped lists and tables), which have in common that I could easily write them on my own, if I needed the...

how to Update JTable

Good evening I have a JTable that I built with a TableModel how to update the elements of the table, because when I do table = new JTable (new TableProg (elementTab)) I create another table above the original table and it is very ugly So for example how to update element of table in a loop at each iteration as "elementTab" changes? th...

mouse listener event

I have got a program having an array of buttons, each of these button has their mouselistener event. Now, how can i find which of the buton is clicked through the mouse listener. ...

Java Swing - How to bind a JComponent in Netbeans?

I am using Netbeans Swing GUI builder to design my app's GUI. I have a JTextField tf and a JCheckBox cb. Now, I want that the tf is enabled only when the cb is both enabled and selected. I am performing the below steps to perform this in Netbeans: Right click on tf >> Properties >> Binding Click on button ... at the right of enabled ...

Identifying Swing component at a particular screen coordinate? (And manually dispatching MouseEvents)

I'm doing some work making a Java app compatible with alternative input devices. Unfortunately, the device in question has a Java API that's barely into the alpha stages right now, so it's pretty poor. What I need to do is essentially set up a replacement structure for the dispatch of MouseEvents. Does anyone know if there's a way in Swi...

How to display panel which is of Singleton class in two different frames at a time?

I am trying to display a singleton obj on two different Jframe, but it is displayed only in the Jframe in which the object is added at last ( in example Frame2). Other Jframe is empty. This Singleton class is inherited from Panel and contains a label in it. Can anybody please tell me how can i display this singleton object in two differe...

Displaying large file in JTextArea.

Hi All, I'm currently working in Swing UI Assignment. This work involves showing large file content in JTextArea. The file size can be as large as 2 GB. My initial idea is to lazily load content from the file, say 1 MB of content will be shown to the user. As the user scrolls i will retrieve the next 1 MB of content to be shown. All th...

Is there a Swing component for Google Maps?

I would like to have support for Google Maps in my Java Swing desktop application. Is there an Google Maps component for Swing that is freely available? It would be good if it was extendable and maybe had support for other maps i.e. like OpenStreetMaps. ...

JFrame is not acting as expected!

This is my first time using a JFrame. I can't get the window to display the text areas I've nested inside the JFrame. I am trying to get the text field with my name in it to display above the tabulated results, which I have omitted the formatting for until I can get the JFrame to work. public void printResults(String[] names, int[] temp...

How can i underline a text in JDK5, NOT JDK6

when i search internet i have found a way to underline font like this, Font f=jLabel1.getFont(); Map<TextAttribute,Object> map = new Hashtable<TextAttribute,Object>(); map.put(TextAttribute.UNDERLINE,TextAttribute.UNDERLINE_ON); f=f.deriveFont(map); jLabel1.setFont(f); it works well on jdk6, however it doesnt work on jdk5, and it does...

Progress bar in Java

I have got a form in Java (Swing) loading large amount of data from the database. I want to display a progress bar while the program gets actually loaded. How can i do it? The code is as follows: import java.awt.*; import javax.swing.*; import java.awt.event.*; import java.sql.*; import java.applet.*; import java.util.*; import java....

using JInternalFrame and some JButton

hi can we use a JInternalFame with a button into the main fram (by JDesktopPane of corz), the button that open up the JInternalFame ? how? thks ...

JFrame.setBackground() not working -- why?

JFrame mainFrame = new JFrame(); mainFrame.setSize(100, 100); mainFrame.setBackground(Color.CYAN); mainFrame.setVisible(true); My intent is to create a window with a cyan background. What is wrong with this? My window doesn't get cyan, as I'd expect! Also, could anyone point out why I seem to have all the colors in dup...

Set the amount of rows JList show (Java)

Hi all. Problem: I have a method that creates a list from the parsed ArrayList. I manage to show the list in the GUI, without scrollbar. However, I am having problem setting it to show only the size of ArrayList. Meaning, say if the size is 6, there should only be 6 rows in the shown List. Below is the code that I am using. I tried sett...

auto resize content of label

I have a label in my program that displays an image. The problem is, if an image is selected that is larger than the label, only part of the image is displayed. How do I display the entire image? image = new ImageIcon(movpath); l5=new JLabel(image); l5.setBounds(360,300,200,200); p1.add(l5); Help needed in reference with the abo...