swing

Active rendering and the EDT (Swing animation)

How should I run animation in a Swing applet? I have an animation thread performing active rendering and it initially animates fine. Sometimes (anywhere from 1 minute to 2 hours later) it begins to fail to update the screen and only the sounds occur. I believe this is due to the fact that the paint is not performed from the EDT causing ...

Swing: How do I set a component height to the container's height?

I want to make a component to occupy the maximumAvailableHeight of the Container. In the code that I have pasted below for example, I have made the root frame to be 800,600. I want to set the height/width of only that frame (and I do not want to try and pixelify its children). If I run this, I see a badly aligned UI. Firstly, I want a p...

Link Java textbox to string in external class

I am currently working on a project in which I have a Java GUI class and another class which contains its relevant methods. I want a text area in the GUI to be updated with the content of a string in the other class whenever it changes. What is the easiest way to watch for these changes? Cheers! ...

AffineTransform: scaling a Shape from its center.

Hi all, I'm trying to scale a rectangle from its center using AffineTransform. I'm sure the solution is obvious but I cannot make it work ! Here is what I've tested so far... import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Rectangle; import java.awt.geom.AffineTrans...

Iterate / recurse through Containers and Components to find objects of a given class?

I've written a MnemonicsBuilder class for JLabels and AbstractButtons. I would like to write a convenience method setMnemonics( JFrame f ) that will iterate through every child of the JFrame and select out the JLabels and AbstractButtons. How can I obtain access to everything contained in the JFrame? I've tried: LinkedList<JLabel> h...

Quick Swing question: Need to shut down my database on close

I've been building a test application that works with a database that up until recently has been without a UI. I'm adding one now. Problem is, the JFrame is launched in another thread and I need my database connection to close when that thread closes (when the UI closes, I should say). How do I do this? Also, what happens to the appl...

How to select nodes in Netbeans Visual Library?

I create a graph based visual applicaion using a Netbens Visual Library. Can somebody post a code sample that enables a selection of nodes with mouse clicks (and Ctrl key fo multiple selection) ? Thanks in advance. ...

firePropertyChange on Sequence generated Id

Hi there, When calling persist the setId method never gets called which in turns causes the firePropertyChange not to execute. I need to fire the changeSupport method because I have functionality that dependants on the state of my entity. public void setId(Long id) { Long oldId = this.id; this.id = id; changeSupport.firePro...

What is the use of Container in Swing?

What is the use of Container in Swing? ...

how add different shapes partially on JPanel+image which is on JPanel

My Project is in Java Swing. I have a JPanel on which I am adding some images with .png extension (which are on JLabels) at center. Now I want to add a line which will be partially on the JPanel & partially on that image. Currently when I am adding a line, JPanel shows the line but when I resize the image & drag it to the image, the i...

how to set JTree "ctrl" selection mode to be always enabled

Hello, I have a JTree that implements multi selection logic. This works great when I do all my selections using the mouse + Ctrl key pressed. If user makes selections with the Ctrl key unpressed it breaks my logic. I can't really see why it breaks but I think that a possible solution is to always indicate the TreeSelectionModel that t...

Why is Java's GUI platform named "Swing?"

Why is Java's GUI development platform named "Swing"? What does it mean? ...

Is QT Jambi dead?

I know they announced in February that it was going to transition to a community-developed model over the next year... but right now, I can't find it on their website, at all, let alone version 4.5 that was supposed to be released this month. I am about to embark on the GUI portion of a major project, and while I had considered using QT...

What is the purpose of "Container c=getContentPane();" in Swing?

import java.awt.*; import javax.swing.*; public class import javax.swing.*; import java.awt.*; import javax.swing.tree.*; import javax.swing.event.*; /*<applet code="JT.class" width=200 height=300> </applet>*/   public class JT extends JApplet { JTree tree; JTextField box; Object nodeInfo; String node1; public voi...

Help with knowing which button number was pressed

import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.border.*; import java.util.Random; /** * */ public class GUI { private static final int BTN_MAX = 8; private JFrame frame; private JPanel panel; private JPanel scores; private JButton[] buttons; private ImageIcon[] icons; ...

How can I best implement a Fade Button Effect in Swing?

I have a JButton which, when pressed, changes background color from active to normal: final Color activeButtonColor = new Color(159, 188, 191); final Color normalButtonColor = new Color(47, 55, 56); I want to fade the active button color back to the normal button color when a specific task has finished executing. I'm using SwingWorke...

hex viewer/editor GUI component for Java Swing?

I'm looking for a decent hex viewer (read-only; I don't need an editor) GUI component that I can use within my Swing GUI. Is there anything out there? I suppose I could write my own, but am hoping to avoid doing this. (also it would be nice to be able to render certain bytes as colorized/bold to highlight particular bytes in question.) ...

JTable - drag and drop

OK, this problem is out of my league. I'm trying to implement a GUI widget in swing that allows files to be dropped onto a JTable, and allows the rows of the JTable to be dragged for re-sorting. Think VLC's playlists or the one in iTunes. I got dropping files from the OS (Explorer, Finder, etc.) working just fine, but I'm having an impo...

How to display japanese characters in JTextArea

There is strange behaviour of JTextArea when displaying japanese characters - I get well-known blank rectangles instead of kanji. The mostly strange thing is that JTextField displays them perfectly (in both cases I use "Tahoma" font family). Also, if I put this code: Font f = new Font("123", Font.PLAIN, 12); // This font doesn't ex...

Java Swing: How can you alter the margins in Nimbus Look and Feel

I'm trying to use Nimbus Look and Feel and I can't simply plug it in to replace other Look and feel because it adds some external padding around each component. So, I would like to remove this padding. This is the list of defaults that can be changed, however the following code changes nothing. UIManager.put("Button.contentMargins", ne...