swing

How can Swing dialogs even work?

If you open a dialog in Swing, for example a JFileChooser, it goes somewhat like this pseudocode: swing event thread { create dialog add listener to dialog close event { returnValue = somethingFromDialog } show dialog (wait until it is closed) return returnValue } My question is: how can this possibly work? As you can s...

How to disable main JFrame when open new JFrame

Example now I have a main frame contains jtable display all the customer information, and there was a create button to open up a new JFrame that allow user to create new customer. I don't want the user can open more than one create frame. Any swing component or API can do that? or how can disabled the main frame? Something like JDialog. ...

Java - How to force resize JCheckBox to prevent clicking the empty space ?

When i create a JCheckBox in my Swing application i leave some extra space after its label, so if the JCheckBox label is for example 100 pixels width, i make the JCheckBox 120 pixels for safety. The problem as at runtime, it's not nice that a user can click on the empty space after the JCheckBox label and it can be actually clicked, lik...

How to change the value of a JLabel in runtime?

I want to change the image a JLabel is viewing during runtime, but I keep getting NullPointerExceptions or nothing happens when I press the magic button that's supposed to do things. Is it even possible in Java? Here is my code in its entirety: import java.text.*; import javax.swing.text.*; import java.util.*; import ja...

[java bean]hibernate Session breaks a java bean?

Hi all, i have a simple JPanel bean in my projects, now i want to drag my panel bean class into my jframe. My panel bean class is like this: public class BeanPanel extends javax.swing.JPanel { /** Creates new form BeanPanel */ public BeanPanel () { initComponents(); Session session=HibernateUtil.getSessionFactory().openSession...

Java login form with database connection

I am creating a login form in java by having a database connection, and I need 2 open DIFFERENT forms for each user. However, all of the three forms open except for one. The forms I have are, MAinWindow Nursery Primary Secondary ALL THE FORMS OPEN except for the nursery form, when I enter the correct username it displays the Primary for...

Cannot install Visual Editor Plugin on Eclipse

I try to follow the instructions from here to install a Visual editor pulgin for Eclipse: http://wiki.eclipse.org/VE/Update Both online and offline installations fails with the following mistake: Cannot complete request. Generating details. Here is the complete log: Cannot complete the install because of a conflicting dependency. So...

More swing design & actions

Im pretty new to gui programming so i've been reading through every post on this site about swing and design. Whats been answered over and over again is that one should have a multiton class for the actions. Like this: (GUI being some JFrame) Now, this works great for one-way actions, like OpenDialog. But the actions for buttons in Di...

java file picker with inline thumbnails

I need a nautilus-style file picker in java, where the files are shown "gallery-style" with a customisable thumbnail for each file. Is it possible to make the standard open file dialog do this? If not, does anyone know of an open-sourced widget that I can use? ...

Need Java Swing equivalent of "scrollIntoView" from Browser DOM

I have a JPanel with several levels of child components, also with a JScrollPane. I'm placing a focus listener on some of the child components to add some behavior to those components, but I would also like to have that component scroll into the JPanel's viewport when focus is gained. My question is, does anyone have a general purpose ...

JTable .. colour of selected row

Hello pip`s, I have a JTable in Java that has a custom dataMOdel and custom renderer. Now when i select some cell it has a dark blue border around it. I want the selected row to be all highlighted in some colour. How to do that? ...

Not sure how to get an object to display after loading from ObjectInputStream()

public void load() { final JFileChooser fc = new JFileChooser(); int returnVal = fc.showOpenDialog(this); if(returnVal == JFileChooser.APPROVE_OPTION) { try{ FileInputStream f_in = new FileInputStream(fc.getSelectedFile()); ObjectInputStream obj_in = new ObjectInputStream(f_in); ...

Why isn't componentHidden called for my JPopupMenu?

I want to be notified when my JPopupMenu is hidden — whether because an item was selected, the menu was dismissed, or setVisible(false) was called on it. Here is my test code: import javax.swing.*; import java.awt.*; import java.awt.event.*; public class A extends ComponentAdapter implements Runnable, ActionListener { private JBut...

Getting a JFrame's actual current location

Hello community, I am trying to create a (child) JFrame which slides out from underneath one side of a second (parent) JFrame. The goal is to then have the child follow the parent around when it is moved, and respond to resizing events. This is somewhat related to this question. I have tried using a ComponentListener, but with this met...

How can I create a bar in the bottom of a Java app, like a status bar?

I am in the process of creating a Java app and would like to have a bar on the bottom of the app, in which I display a text bar and a status (progress) bar. Only I can't seem to find the control in NetBeans neither do I know the code to create in manually. Thank you so much for helping! Paintrick ...

Creating component in Swing where text field takes only date type value

I want to create component in Swing where text field takes only date type value. ...

extending jtextfield value to take date format

I want a text field in java swing which will take only date type of value ...

Ugly swing fonts under ratpoison

I am writing a small application in swing. I am using Ratpoison as my window manager (with wmname LG3D) and Netbeans as IDE. My application fonts when started from KDE or directly from Netbeans look ok. Started from ratpoison they looks like this: Click for full size ...

What is the corresponding WPF .NET component to a JTable in Java Swing?

I have a small Java Swing application that I want to rewrite in WPF .NET. The application uses a JTable with an AbstractTableModel and a custom TableCellRenderer. I use my custom cell renderer to display the objects in two rows. What is the corresponding WPF .NET component to JTable? ...

Building a Monopoly Board with GridBagLayout

I have been building a Java version of Monopoly in my spare time and am having some trouble understanding layouts etc for Swing. Each one of my spaces on the board is a essentially a custom JButton and I have been trying to lay them around the edge of a frame (like on the monopoly board itself). I can't seem to find a useful explanation...