swing

How is messaging between Java classes best accomplished?

I have multiple classes and threads that need to write to a Java Swing JScrollPane. In the Android/Eclipse environment I used android.os.Message. Is there something similar in the NetBeans/Windows environment? Here is where I would like to send the message from: public class PrintStatusTask extends Thread { PrintStatusTask(String na...

how to change java swing look and feel without application restart?

is there a specific way to change the look and feel of a swing application without needing to restart the application every time the LAF got changed by the user? im looking for a solution where one can select the LAF from a configuration dialog and it changes directly on apply without having to fall back to telling the user to restart t...

java.awt.print.PrinterException: Invalid name of PrintService.

I would ask it in the form of a question, but I have no idea why I'm getting this exception. I can't find any real documentation online either. To give you context although I don't think it's really relevant, I'm using it within the JFreeReport classic engine reporting framework. The stacktrace is: java.awt.print.PrinterException: In...

Interaction with a cell renderer in JTable

Is there any way to get a cell renderer to respond to mouse events, such as mouseovers? ...

Java/Swing: Update data on stateChange

I have a list of Map.Entry<String,Integer>s that I am looping through, and for each one, making a JLabel/JSpinner representing that particular entry. How can I make it so that when the ChangeListener fires on the JSpinner, it updates that entry to reflect the new value? My code looks like for (Map.Entry<String,Integer> entry : graph.g...

JcheckBox in Jtable

Hi , I am having Check box in my Jtable.Check box displayed in center of column.My problem is when i click on check box it moves to left of that column and comes to center functionality wise works fine.Can any one tell How to stop the movement of checkbox Thanks Ganesh ...

Swing MenuEvent menuCanceled

I don't understand when menuCanceled is invoked on a JMenu. In fact when I open a menu is called menuSelected when I close a menu is called menuDeselected but never will be called menuCanceled. Any examples? ...

Swing, Eclipse RCP or which way to go?

Hi there, I'm a developing primary Java webapplications at work. I would like to start creating a little java desktop app. It should be a simple CRUD app with database connection, 2 - 3 forms and a smart stats page. To be honest: I'm kinda lost in this topic. I've took some time to guide through swing but the tutorials are all old and m...

How can a Swing WindowListener veto JFrame closing.

I have a frame, and want to prompt when the user closes it to save the document. But if they cancel, the frame shouldn't close. frame.addWindowListener(new SaveOnCloseWindowListener(fileState)); ... public class SaveOnCloseWindowListener extends WindowAdapter { private final FileState fileState; public SaveOnCloseWindowListener...

Is there SQL-syntax aware Swing component?

Hello, I am looking for some Java Swing component (textarea like) which is aware of SQL syntax - meaning it recognizes and highlights it. If there isn't I will need to do it myself, any useful advices there how not waste too much of time (eg. which component to use) ? ...

JComboBox border is transparent in Java 1.6 but not in Java 1.5

In my application we are using customized look and feel. In Java 1.5 I am using one JComboBox and its popup border is not transparent it is coming in blue color. But in Java 1.6 this same combo box border is coming as transparent and not in blue color. Any idea? import java.awt.Dimension; import javax.swing.JComboBox; import javax.swi...

problem when implementing a selection listener in a JTable

I am developing a JTable with different rows. I would like to associate an event to the selection of a row in this table. I have used the following selection class to provide behaviour to the table selection: public class TableSelectionListener implements ListSelectionListener{ public Integer item; public TableSelectionListener(In...

properly writing a model with a property intended for view binding

I have a class MyModel with a property datalogEnabled (and other ones, but let's start there) that I would like to be able to implement properly for use with UI/view binding. public class MyModel { static final String KEY_DATALOG_ENABLED = "datalogEnabled"; final private PropertyChangeSupport pcs = new PropertyChangeSupport(th...

ActionMaps in java

public class XXX { public static void main(String args[]) { JComponent comp = new JTable(); // some panel or table comp.getInputMap().put(KeyStroke.getKeyStroke("F4"), "xxxaction"); comp..getActionMap().put("xxxaction", new XXXAction()); } public class XXXAction extends AbstractAction { @...

Does this game have a solution

Hi, I am developing a simple game using Java swing. I want to know whether this particular game has a solution in the following scenario. If I am convinced that theoretically a solution cannot be arrived at this point, I will throw a notification to the user. 3x3 4x4 The objective of this game is to fill numbers from 1 to 8 (or 1 t...

resize child panel when resizing parent JFrame

I have a JFrame which contains a JPanel. The frame can be resized by the user using the mouse. When the width of the frame is > 400, the jpanel inside's width is set to 10; otherwise 1080. In between the frame and the panel, there is also a JScrollBar. Here is my code: import java.awt.BorderLayout; import java.awt.Color; import java.a...

How to abort a already-started swing worker thread?

If I have started a SwingWorker thread by invoking its execute(). Is there any way that I can interrupt it at its execution? ...

Swing send an event programmatically

How can I do to create a custom event and send it programmatically to a component? E.g. If I had a JButton and wanted to create an ActionEvent or a MouseEvent and than send it as if an user had pressed on it which code I'd to use? The following code not work: JButton btn = new JButton("Click..."); MouseAdapter my = new MouseAdapter()...

save/restore Java swing JList Element to/from MySQL

I'm new to Java (and swing) and looking for a way to save (and reload it later) all JList elements to Database or in particular MySQL. I read about Java Serializable and cannot find a working code for reference. ...

linking jcombobox values with jtextfield values

I've created an application in netbeans IDE 6.9 where I need to set values for each value in the jcombobox. In my pane I've a combobox and below that are the textfields for entering values for each value in the combobox. Can anyone suggest that how do I link the combobox with textfield. I mean there are different values for each value in...