swing

How to launch a website in Java Swing, in a way that works in Gnome and KDE

As outline in a previous question I asked. A website can be launched by doing this: Desktop.getDesktop().browse(new java.net.URI("www.google.com")); This works fine in Ubuntu(gnome), but it doesn't appear to work in OpenSUSE(KDE flavour). There is a bug lodged with Sun about this. Any ideas on alternate ways to do this, that will wo...

Inserting radio buttons in a DefaultTableModel

I have a 2D array of objects which needs to be displayed in a table through a table model class which extends a DefaultTableModel. In addition to the columns needed to accommodate the data included in this array, I would like to add an extra column with radiobuttons, in order to enable the user to make a selection. As table model accepts...

JTextField - Java swing - no cursor?

Hey guys, see this snipped of code: JFrame loginFrame = new JFrame("Login"); loginFrame.setSize(500,400); JPanel loginPanel = new JPanel(); loginPanel.setLayout(new GridLayout(0,2)); JLabel header = new JLabel("Login"); JLabel header2 = new JLabel("blahvlah"); JLabel loginLabel = new JLabel("Login"); JTextField loginFiel...

Swing: TableCellRenderer that uses boldface for some of the cells

Simple question, but I can't seem to find the answer anywhere online. How do you use a custom TableCellRenderer to render some of the table cells in boldface? I know how to use TableCellRenderer to set the background color on a cell-by-cell basis. You do something like: public class MyTableCellRenderer extends DefaultTableCellRender...

Java Swing - JSlider and JCombobox causing runtime errors

Ok, I will post the code for the three classes as it's not too long. package guiDemonstration; import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; public class TabbedGUI { //create fields private JFrame frame; private JTabbedPane ...

java/swing: drag and drop with a list of strings

What data flavor should I use to transfer a list of strings? I guess I can serialize the list of strings in JSON format, but was hoping I could just transfer a List directly. ...

java swing background image

I am using JFrame and I have kept a background image on my frame. Now the problem is that the size of image is smaller then the size of the frame so i have to keep the same image once again on the empty part of the window. If user clicks maximize button than I may have to put the image on empty region of the frame at run time. Can anyone...

How to find out the preferred size of a JPanel which is not displayed, according to its content?

I am using a JPanel (with several labels inside) to add a dynamic information on a graph. This panel is dynamically created, it is not visible before I use it to draw. For this, I am using a BufferedImage, and I follow approximately the same steps as described on this other question. It works good, as long as I specify all sizes (the pa...

Over riding the Basic arrow button class in Java

The BasicArrowButton is a class is part of the Java SE. The BasicArrowButton Displays a Single Arrow Head in a specified direction. I want to override the class, preserving the existing methods but having the Basic Arrow Button display a double arrowhead instead of a single arrowhead. For Example See the following URL www.tiresias.org...

Why Java JTextArea doesn't receive the entire pasted text?

Using Netbeans 6.8 (Mac Version) drag and drop tool for making the GUI, I have designed a JTextArea which the user should paste his data which the program will modify and show it to him. It is working fine; however, when I tried to paste about 65 thousand lines of testing data in the JTextArea, the GUI showed only a few of these lines (...

How do I fade an image in swing?

I've got class which inherits from JPanel with an image on it and i want to set up a little animation to display the panel/image and then fade it out when an event fires. I presumably set up a thread and fire off the animation but how do I do actually do the fade? ...

selected Checkbox

Hi, I am new to swing, I would like to ask how can I make this code , so when the submit button is pressed to get the selected checkboxes and display their names. import java.awt.BorderLayout; import java.awt.Container; import java.awt.GridLayout; import javax.swing.BorderFactory; import javax.swing.JButton; import javax.swing.JCheckBo...

How to assign different colors to items in JComboBox?

I have a JComboBox and have 10 string items added in it. I want to assign different colors to each item. How i can achive this? Please help. ...

Is it possible to dynamically generate decent looking properties dialogs?

I have an application which displays properties dialogs for various GUI-accessible objects. Because there are a huge number of different kinds objects, there are also a huge number of different properties dialogs. Because we are lazy, we didn't want to hand-build each and every properties dialog; additionally, plugins might introduce new...

java/swing: drag and drop problems with two child windows

I have two child windows that I want to accept drops from drag+drop objects in two different ways. One is a JPanel that I want to accept a list of files. It works fine. The other is a JTable that I want to accept a list of strings. It works fine if I don't enable the JPanel as a drop target. When I try to enable both, the JPanel drop ...

Why doesn't the EDT shut down when all live threads are daemon?

The following code slides a card across the screen. When I shut down the main window, I expect the event dispatch thread to shut down as well, but it does not. Any ideas on why the ScheduledExecutorService thread prevents the EDT from shutting down? import java.awt.Graphics; import java.net.URL; import java.util.concurrent.Executors; im...

Focus traversal within components in a Cell Editor

Hi, i´m trying to make easy edit to a table thas uses a custom component for displaying info. Each Cell hast 3 data texts. What i want is: if a cell gets focus, start editing the 1st value. while editing the 1st value user press [TAB], then go editing the 2nd value (don´t go to the next cell) if i press [TAB] in the 3rd value, then, g...

find and replace dialog box

I'm newbie and am trying to figure out find and replace in notepad. Here is the code for find. I am wondering how can i implement a way so that after pressing the button the dialog box doesn't close and so i can use the dialog box for next find ( like find next in notepad). import java.awt.BorderLayout; import ja...

Java app makes screen display unresponsive after 10 minutes of user idle time

I've written a Java app that allows users to script mouse/keyboard input (JMacro, link not important, only for the curious). I personally use the application to automate character actions in an online game overnight while I sleep. Unfortunately, I keep coming back to the computer in the morning to find it unresponsive. Upon further testi...

Exception: java.io.StreamCorruptedException: invalid type code: 00

When I query through the EJB interface for a entity, under the console it is ok, but switch to query from Swing it throw this exception. The exception: java.rmi.UnmarshalException: failed to unmarshal MY_ENTITY**; nested exception is: java.io.StreamCorruptedException: invalid type code: 00 at weblogic.rjvm.ResponseImpl.unmarsh...