swing

Intercepting exceptions

I'd like to use to a custom exception to have a user-friendly message come up when an exception of any sort takes place. What's a good straightforward way of doing this? Are there any extra precautions I should take to avoid interfering with Swing's EDT? ...

Apply arbitrary geometric transforms to a JPanel

I have some Swing controls in a JPanel. I want this panel to appear on the screen transformed by some arbitrary affine transformation, and for all the controls to remain interactive. Lets assume a rotation by 20 degrees and a scale down to 75% normal size for example. The closest I have seen for how to do this is here: http://www.code...

Making words different colors in JTextField/JTextPane/?

I'm trying and failing to understand how to use Java's text editor components to colorize text as you insert it. I don't want or need a fully featured syntax highlighting library. Basically, I have a JTextField (or some other JText... component), and a list of words. I want any words in the field that appear in the list to be red, and t...

JTable How to refresh table model after insert delete or update the data.

This is my jTable private JTable getJTable() { String[] colName = { "Name", "Email", "Contact No. 1", "Contact No. 2", "Group", "" }; if (jTable == null) { jTable = new JTable() { public boolean isCellEditable(int nRow, int nCol) { return false; } }; } ...

my program exits from close button of window but not from my exit button.help me i have used System.exit(0).tell me another way.

Here's my code: import java.awt.*; import javax.swing.*; import java.awt.event.*; import javax.swing.table.*; import javax.swing.JOptionPane; import java.util.*; import java.applet.*; /*<applet code=tabledemo.class height=300 width=300></applet>*/ public class tabledemo extends JApplet implements ActionListener { JScrollPane jsp1; ...

importance of JTable model?

Hi, What is the importance of JTable model.Does all the swing components has model associated with it. ...

JTable: how to select columns at runtime

I have too many columns in a table to display them all at once, and would like to let the user change which columns are visible. How can I do this? note: It is easy to make the application select columns at runtime. What I am asking is what UI element(s) to add to allow the user to hide/unhide columns at runtime. ...

How to make an input form in java code (NOT Netbeans using JForm) ?

Hi I want to make an input form so that the user can enter details in java code. Something like this : MY CODE import java.awt.GridLayout; import javax.swing.*; class JOptionPaneTest { public static void main(String[] args) { String[] items = {"One", "Two", "Three", "Four", "Five"}; JComboBox combo = new JComboBox(items)...

Java Swing - UI Freezing

Hi, I'm doing some routine in Java (1.5)+Swing, that damands some time. How the best way to implement this routing outside the swing thread, to avoid UI freezing? Thanks in advance ...

Java Swing: Process won't close after adding mouse listener

I want to know what the issue is when I try to close my Java Swing application when I add a listener to the form frameview. Here's how to produce my problem: In Netbeans, create a new Swing application project, then in the main class, create a local method that adds an empty mouse listener to the main window via this.getMainFrame().addMo...

How to set the default icon for all Java Swing windows?

How to set the default icon for all Java Swing windows? Otherwise i have to set icons for every frame i created. What's your suggestions? Simple hackings are also accepted. many thx Update: Best if the method you suggested can leave existing frame-creation codes untouched. thx ...

Suggest Java Swing Component libraries

I’m currently looking for a Java Swing all-in-one professional component pack to create good-looking UIs, charts, reports and so on. Surprisingly, after a couple of hours of googling all I was able to find is JIDE. Even though it looks sexy, I need more alternatives to choose from. Are there any recommendations? Thanks. ...

JTable with striped background

Using a different background color for odd and even rows is a commonly used trick to improve readability of large tables. I want to use this effect in Swing's JTable. I started out by creating a custom table renderer, but this can only be used to paint actual cells, and I also want to add stripes to the "white" part of the table where ...

Swing JButton don't change background color onclick

I want the button on click it never change the background color, by default the color will change to light blue grey color. So this is my code JButton b = new JButton(); b.setBackground(SystemColor.control); I want the button when on click it will never change the background color. ...

Java Swing: Autoscrolling using JList and JScrollPane

Hello community! I'm having this problem: I have a JList (within a JScrollPane) with say about 1000 elements, and the dimensions of this JList obviously doesn't allow to show all the data. Now, I have this JList within a JScrollPane and I need that when I say JList.setSelectedIndex(), the JScrollPane automatically scrolls into, and show...

Dynamic JComboBoxes

I have following data (String): Course1: A1 Course1: A2 Course2: B1 Course2: B2 Course2: B3 Course2: B4 Course3: C1 Course3: C2 I would like to make 2 JComboBox (JComboBox1, JComboBox2) JComboBox1 is Containing Course1,Course2,Course3. When I select, say, Course2 from JComboBox1 =>B1,B2,B3,B4 should be displayed in JComboBox2. Is i...

Fast replacement for JComboBox / BasicComboBoxUI?

I've got a JComboBox that potentially can have thousands of items. They're sorted, and there's find-as-you-type, so in principle it's not completely unusable. In practice, it's pretty unusable with just a couple of hundred items. I managed to improve the initial display performance using setPrototypeDisplayValue(), but BasicListUI still...

Swing I18N: When to load properties?

I'm refactoring an existing Java desktop application to load internationalized UI text labels from a .properties file. When in the application lifecycle is the appropriate time to load the properties file and populate the strings in memory? The existing implementation defines each component's label as e.g.: public static final String fo...

How to place a JButton at a desired location in a JFrame using java

Hey, I want to put a Jbutton on a particular coordinate in a JFrame. I put setBounds for the JPanel (which I placed on the JFrame) and also setBounds for the JButton. However, they dont seem to function as expected. My Output: My Code: import java.awt.Color; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing...

rtepainting issue with drawing image

i have a JTextField with background image. if we disable this textfield it is not looking like disabled because of image, so i want to apply another image which is in disabled mode. it's working fine but when we maximize a my window(frame) it's not repaiting my components. please advice ...