swing

Why Java jFrame setResizable() is failling to act?

This code is automatically generated by Netbean 6.8 GUI builder. The default application was not contained in a jFrame! It was in jPanel only which I didn't know how to make it none re-sizable. so I added a jFrame to contain all of them and although I set its setResizable(); to False...it still re-sizable! Here is the code: import o...

Performance Testing Swing application

We have a Java Swing application which is basically a two tier application - An UI layer which connects to a database and which does some heavy-lifting across both the layers. We have been observing some performance issues with the application and are looking for strategies to load test the application. Basically our goal is to launch...

JTree node labels change often but width is cached

Currently, I'm using a custom TreeCellRenderer to handle label and icon changes for my JTree. The problem comes when I need to change the text on a few nodes. The TreeCellRenderer works great in that the new text is displayed. However, the width from the initial text is cached and is not updated. I've attempted to hack it by overriding g...

getting information from different JComponents

i have a GUI that is mainly a survey, when the survey is finished the information would be extract to a table , i am currently having trouble getting all the information , i created a Actionlistener called finish handler which is attached to the survey GUI button "Finished" so when the finish button is clicked it will extract all the inf...

how to use hashMap with JTable

i have a hashMap which i would like its data to be viewed in a JTable how ever i am having trouble getting the hashMap amount of columns and rows and the data to be displayed.i have a hashmap which takes a accountID as the key and a object of students in which each students have their data like name,id, age, etc.however referring to the ...

Problem in choosing a design pattern for my java project

I am developing a Java Desktop Application. From a Swing GUI, a user enters 5 inputs through 5 checkboxes as follows: CheckBox1: Scrape Name CheckBox2: Scrape Address CheckBox3: Scrape Phone Number CheckBox4: Scrape State CheckBox5: Scrape Country I have made 5 functions, each for each checkbox. public static String getName(String...

Problems with SWT / AWT bridging?

Afternoon, I'm working on an Eclipse RCP plugin. I want to embed a Swing component into it. At the moment I'm using a SWT <-> AWT bridge like this: Applet applet = new myApplet(); Composite swtAwtComponent = new Composite(parent, SWT.EMBEDDED); java.awt.Frame frame = SWT_AWT.new_Frame( swtAwtComponent ); applet.init(); frame.add(applet...

How to monitor progress (JProgressBar) with FileChannels transferFrom() method?

I need a little help with the JProgressBar component. My program copies files from one place to another using java.nio FileChannels. The actual copy method is transferFrom(). I've got two questions now. How to I monitor the transfer progress of FileChannels? All tutorials I've found use the conventional java.io InputStreams and increa...

How to calculate the area of a java.awt.geom.Area?

I am looking for a way to calculate the area, in pixels, of an arbitrary instance of java.awt.geom.Area. The background: I have Shapes in my applications that may overlap. I want to know how much one Shape overlaps another. The Shapes may be skewed, rotated, etc. If I had a function area(Shape) (or Area), I could use the intersection of...

how to reposition JButton on resizing the window.

I have kept a JButton in the bottom middle part of my JFrame. Now whenever I resize the window the JButton should be repositioned (in the new centre) depending on new resized window. Can anyone tell me how to accomplish this. Thanks in advance. ...

Get Icon Image from the Title Bar of the JFrame

I m using Netbeans IDE, I need to get the icon from the title bar of the JFrame and set it in the JButton. Is there any way to get the Icon image from the JFrame, there is no getIconImage() method i tried getIconImages() but it doesnt works. ...

how to make JTextPane paint anti-aliased font?

in the a swing app i'm rendering text with a custom JComponent, using Graphics.drawString(). here is a sample: in that same app, i'm rendering text using a JTextPane. here is a sample: can you notice how the lower sample is a little 'smudged'? well, i can't figure out how to make it look like the upper sample. thanks, asaf :-) u...

Java: way to completely disable any Swing unwanted beeps?

I am working on a fairly complex Java application using Swing. On some occasions there are unwanted beeps without any user intervention. No crash, application keeps working fine, I'm respecting the EDT rules etc. Yet in some cases a beep can be heard: I may be doing something silly triggering that beep but in any case it s not a user a...

How can I bind an object to a row in a Swing table?

Hello. In my application I have some similar threads doing their stuff and I'd like to represent some of their properties in a row of a table (one thread per row). I'd pass a row object to corresponding thread and update them on changing values, but I couldn't find anything like that in API. So what is the right strategy to keep rows upd...

Changing a JTextField causing exception in cleanup method?

import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; public class MainForm extends JFrame{ private JPanel p; private JButton clear; private JLabel nameLabel; private JTextField nameText; private JLabel genderLabel...

Swing: Dynamically Displaying a Panel

I'm currently making a java swing GUI with the Netbeans GUI builder. I have a bunch of panels that are being replaced on my main JFrame as the user navigates the GUI and a controller class is taking care of this. At one step, however, there is a panel (FilterDefinitionPanel) that contains a combo box as well as a blank inner panel (Query...

JTable sort with dual tables to keep in sync in Java 1.4

Is there a way where I can have a parent JTable sort value be passed and set the sort of a child JTable in Java 1.4? What I have is a parent JTable of subjects with about 6 columns and a child JTable that is a subset of the parent JTable with the same columns. What I need to do is when the user selects a item from the parent JTable and...

Set the Location of the JFileChooser

How can we set the location of the JFileChooser window, I tried setLocation() and setBounds() methods but it doesn't works. ...

Get rid of wasted/unused space in a JMenu

In my app, I've got a menu bar with a File menu. In the submenus, each JMenuItem is wasting a lot of white space to the left of the text for a checkbox (I think), even though I'm not including any JCheckBoxMenuItems. I'm seeing lots of other java/swing apps who's menus don't waste this space. How do I do it in my app? ...

When will getGraphics() return a valid graphics instance?

I'm trying to render a custom Swing component where I've extended the JComponent class. For the purpose of simplifying the component requirements, lets just summarize my component as needing to render a few strings, each with their own fonts. I need my component to be sized exactly to the summed width and height of my rendered strings....