swing

Fastest Way to Draw a Static Image in Java

I'm in the process of writing a custom heatmap generator. I'm wondering what the fastest way is to draw boxes (up to around 1 million) in Java. Most questions I've found have concentrated on dynamic images (like in games), and I'm wondering if there's a better way to go for static images. I've tried using swing (via a GridLayout and addi...

Can I run one SwingWorker within another?

Hi, I need to run two SwingWorkers. One of them can only run after the other is done. Can I run them like this? class TestWorker { private FirstWorker worker1; private SecondWorker worker2; public TestWorker() { worker1 = new FirstWorker() { @Override protected void done() { ...

JComponent.revalidate() doesn't update until code finishes

**Hello, I'm trying to create an archiver in java. This means that I am constantly reading and writing from streams. I want to be able to update a JProgressBar to show how much I have written. My code currently updates the progress bar after each entry in the archive. My variables and everything say that the code is updated, except its ...

Can I limit the length of text in a JTextField which can be painted, while still storing the full text?

I have a text field in my application. Despite it being a text field, users sometimes paste huge amounts of text into it. Additionally, other functions of the problem set large amounts in as well. Sometimes there is so much text that the JVM gets an access violation in fontmanager.dll. Oracle doesn't appear to be interested in fixing...

Swing: Preventing CellEditor from losing focus

I have a table ( in which I make a table cell editor consisting of a text field and a button. Clicking the button brings up a pop up menu with a date picker. The idea is that the text field should be updated whenever a date is selected in the date picker. Problem is, when interacting with the date picker, the focus of the cell editor is...

Should one inherit GUI JFrames?

I've a JFrame 'A' and I'd like to provide a very similar one, but with extra buttons, and different functionality. I was wondering if I should inherit 'A' and then overwrite the handler methods, and add components, or whether a different approach is recommended. ...

Java/Swing FEST test fails absurdly

I have a test that sometimes fails on the requireSelected() call, and I can't figure out why. public void testSimple() { JRadioButtonFixture fixture = getFixture(); fixture.check(); fixture.requireSelected().requireVisible(); } I tried changing the code to run on the EDT instead of in the test's main, but none of the fixture's m...

Java Swing button colors

I am using NET Beans IDE for developing my application in LINUX. I have used synthetica package to generate new look and feel. All is well till now. Now my next stage is to add colors to buttons when some database status changes. For example: In a restaurant i have 2 tables and when 8 people came in to dine and i will create 2 table i...

error in running a simple swing program

i just started learning swings. And thought of trying out a simple program, but i can't run it. import java.awt.*; import javax.swing.*; class MyDrawPanel extends JPanel { public void paintComponent(Graphics g) { g.setColor(Color.orange); g.fillRect(20,50,100,100); } } I am getting the following error: E...

Java JPA, Swing and Beans Binding: Changes to a OneToMany collection in entity not immediately reflected in GUI

Hello, I am trying to learn JPA with Hibernate and binding it to a GUI built in Netbeans with Beans Binding. It is a application listing dogs. Each dog can have one to many puppies. You can add and delete dogs, and for each dog you can add and delete puppies. The dogs are displayed in a JList, when the user selects a dog its properties...

Best way for automatic databinding between database and user interface in java swing app?

Hi, I'm currently facing a need of creating user frontend application to database with dozens of tables and thousands of fields. It should be java swing application, and I'm trying to find as most automated solution as possible. Ideally to completely avoid manual creation of DAO layer, beans definition and GUI creation. Currently we ...

how to hide a text area in java swing form?

i used textarea1.setVisible(false); but still i can see the border of the text area at run time. i want the textarea to be completely invisible Can anyone help in this issue? ...

How to wrap a Component to several lines

Hi all, I have a large component (say width=4000px, height=200px) and would like to be able to see it entirely even on a small screen. I don't see any easy way to do a wrapping component, my idea is the following : given a factor (for example 4), the component would be of size 1000x800, by wrapping the child to 4 lines. The size reques...

Initializing a Java Swing JScrollPane to the bottom

I am trying to initialize a JScrollPane to start life at the bottom. I do not want it to scroll automatically after it is initially shown. The scroll pane does not contain a subclass of JTextComponent, but rather a JPanel(GridLayout(0, 1)) containing many JPanels. I tried using JViewport.scrollRectToVisible() inside an event handler on ...

How to add JComboBox to a specific cell in the JTable

I want to change defaultCellEditor to JComboBox only when a specific cell in a table is selected. ...

Java Swing and Netbeans GUI Designer: How to remove small gaps between components when I set them invisible?

Hello, I am a newcomer to Java Swing. I am using the GUI builder of Netbeans. I have three main panels for three different views in my application. These views can be switched by a menu on the left. I switch these views by setting one visible and setting the other two invisible. It works but there is a little problem. In order to ac...

Java Thread problem - updating GUI

Hello All, I'm trying to use threads to run a lenghty operation in the background and update the UI. Here's what i'm trying to do: on a button click, display a popupjframe with a message "Inserting into DB" create a new thread to insert 1000s of entries into a database. when the entries are inserted, i want the popupjframe to disappe...

Eclipse visual editor giving error when trying to run a java UI bean

Hi all, I was able to successfully create and run a UI Java class by using the eclipse visual editor. After few days when I opened eclipse and tried running the same class by doing this -> Run > Run as > Java Bean, eclipse errors out with the following message- "iwav0120e Launch failed no java bean found" It does not show the visual e...

Using JTable for a JTree cell editor

I would like to use a JTable for editing a JTree, I extended DefaultTreeCellEditor and implemented isCellEditable getTreeCellEditorComponent, in getTreeCellEditorComponent I return a JTable. Everything works up to this point when a node is edited swing displays the JTable filled with the objects content however when editing is complete, ...

How to create 3D Tag Cloud in Java

Hi All! I need a suggestion/idea how to create a 3D Tag Cloud in Java (Swing) (exactly like shown here: http://www.adesblog.com/2008/08/27/wp-cumulus-plugin/) , could you help, please? ...