swing

Can a Jtable save data whenever a cell loses focus?

The high level: I have a JTable that the user can use to edit data. Whenever the user presses Enter or Tab to finish editing, the data is saved (I'm asusming that "saved" really means "the TableModel's setValueAt() method is called".) If the user leaves the cell in any other way after making an edit, the new data is not saved and the v...

Java Swing: multiple windows

I'm new to GUI programming, but need to create a multiple window GUI. Does anyone know of any good tutorial online or could you please show a simple code that will launch 2 windows? ...

[Java] How to get rid of the flicker that appears during my animation ?

Hi, I'm learning Java by making a small game in a JApplet. I got a little problem with my sprite's animation. Here is the code : this.sprite.setBounds(0,0,20,17); this.sprite.setIcon(this.rangerDown); for(int i = 0; i< 16;i++) { this.sprite.setBounds(this.sprite.getX(), this.sprite.getY()+1, 20, 17); this.sprite.update(this.s...

writing global listener

I want the active window (i.e JFrame ot JDialog) to receive specific keyEvent so that whereever the focusing this keyevent is handling by the window such as ALT+F4 if you press it wherever the focusing the active window will close,I try to override postprocesskeyEvent but it doesn't work fine ...

Java Swing: Read many images files without memory problems?

Hi, I'm writing a Java Swing application that will load from disk about 1500 png images that range in size from 50kb to 75kb each. I don't need to load all of them at once, but I will need to load at 50 images at a time. I've been trying to load them using the typical: new javax.swing.ImageIcon(getClass().getResource("myimage.jpeg") ...

JTextField and \r\n problems

Hello, Part of an app I am working on includes a log file viewer, with a find text function, which calls a pattern matcher on JTextField#getText(), like so: Matcher m = somePattern.matcher(textField.getText()); m.find(startPosn); System.out.println("startPosn: " + m.start()); System.out.println("endPosn: " + m.end()); where textField...

How to implement "Saving..." dialog box in Java?

I want to pop up a dialog box that says "Saving..." and once the operation is completed, it simply disappears. While the saving is in progress, I dont want the user to be able to do anything. I also dont want an OK button. What is the name of the Java class that allows me to do this? ...

Why getToolTipText is never called?

I have got a JComponent. The paintComponent Mehtod is overridden. I mentioned that tooltips were not occuring reliable. Sometimes they were displayed and sometime they didn't. Now I dont't see tooltips anymore on this component. I overwrote getToolTipText(MouseEvent e) to specify the contents of the tooltips. But the methods getToolTipTe...

How to force a tooltip to update on a TableCellRenderer, when the text is identical ?

In a Java program, I am using a custom renderer for cells in a JTable. On this renderer I set a tooltip, for which the content depends on the current cell. When the values are different, the tooltip is updated, and will appear next to the mouse pointer, over the cell. However, when the text for this tooltip is identical when changing c...

Images will not work in a .jar file

When a .jar of an application is created, the images in the application no longer appear. An example of our code for loading images is: ImageIcon placeHolder = new ImageIcon(src\Cards\hidden.png); We have no idea why this is happening. The application runs as expected if we do not compress it to a .jar; as a .jar, the images simply dis...

Accessing look and feel default icons?

I want to change the selected icon for a JCheckbox to a different icon, let's say for example the disabled selected icon for a JCheckbox. How can I get the disabled selected icon from the UIManager? I tried UIManager.getIcon("CheckBoxUI.disabledSelectedIcon"); Is that the wrong icon property name or is that just the wrong way to get ...

WPF client sided and Java server sided?

Hi, I would like to ask for some ideas regarding a scenario like this: 1) we need to build up a real time application that runs on a client. Some sort of stock trading functionality, updates pushed to few clients in different geo locations every 25 secs. 2) the data is collected and pre-processed on the server side (Glassfish/Java) We...

Session management using Hibernate in a *multi-threaded* Swing application

Hi, I'm currently working on a (rather large) pet project of mine , a Swing application that by it's very nature needs to be multi-threaded. Almost all user interactions might fetch data from some remote servers over the internet , since I neither control these servers nor the internet itself, long response times are thus inevitable. A ...

Changing JList row color at runtime

Hi, I am trying to change JList rows dynamically. I need change nth row colour, highlight it(n is unknown during compilation). I saw a lot of examples with custom ListCellRenderer, but all were "static". In other words I have JList with x rows. During runtime my "business logic" detects nth row is important. So I want make its backgroun...

Best approach for dual-state Action

I have recently implemented an Action that toggles the enabled status of a business function. Whenever the user invokes the action I set a boolean flag: "willEnable" to determine whether the next invocation will enable or disable the function. Likewise I update the action name, short description and icon to reflect the new state. Then...

Java Swing: what class can be used to implement this?

What Swing class can I use to implement something like this? EDIT: Hmm..for some reason I cannot add the image here. Well, here's the link: Basically, I need a list table, where each column can be of different type of gui (i.e. plain text, check box, or drop-down menu). EDIT I have re-publish the image for you ;) ...

Java Swing: JInternalFrame: need a dialog popup

I have a JInternalFrame window that needs to popup a modal dialog box when a JButton is pressed. At first, I tried using JDialog, but I found that JDialog constructor needs: JFrame boolean modal I tried passing JInternalFrame to it, but the type didn't match. Should I use JDialog with JInternalFrame? What if I dont specify the owner...

ToolTip on second monitor is displayed at the edge of the monitor.

Hi, I have got a component. The ToolTip of the component is set by the setToolTipText() method. On the first monitor everything works fine. Now when I move the frame to the second monitor, the tooltips are displayed at the edge of the monitor (on the side to the firt monitor). This happens only with tooltips of this component. The probl...

How to close a modal JDialog when user clicks outside of JDialog?

I have a Undecorated Modal JDialog which I want to setVisible(false) when the user clicks outside of the modal dialog. Is this possible in Swing? What I am doing is popping up a custom editor for a text field like a date selector. Is there an easier way to do what I want? EDIT Remember that modal blocks on the call to setVisible(tru...

Why is paint()/paintComponent() never called?

For the last two days I have tried to understand how Java handles graphics, but have failed miserably at just that. My main problem is understanding exactly how and when paint() (or the newer paintComponent() ) is/should be called. In the following code I made to see when things are created, the paintComponent() is never called, unless...