swing

Bubbling up in the AWT event model?

If I implement an action event on a JFrame that has some buttons it give me the button clicked via getSource but if I implement on the same frame a mouse event it doesn't rise me the event for the buttons but only for that JFrame. Why? The event bubbling seems to work only for action event so what model Swing implements? Which listene...

jtable columns too small

Hi, i am very stuck. Hopefully a kind person on here can help me with a line of code to make my jtable sretch a little further across the panel its in. At the moment it just stays really small in the middle of the screen! I have tried many approaches, just recently failing at trying to change the widths of the columns (as the page / gui ...

Dragging JPanel

I've got a problem when trying to drag a JPanel. If I implement it purely in MouseDragged as: public void mouseDragged(MouseEvent me) { me.getSource().setLocation(me.getX(), me.getY()); } I get a weird effect of the moved object bouncing between two positions all the time (generating more "dragged" events). If I do it in the way de...

problem with JFilechooser in netbeans

I am using netbeans for developing java dextop application,I have created a JFilechooser which will let user to save a new file created. But the this int returnVal = newFileChooser.showSaveDialog(this); line of the following code gives this error: method showSaveDialog in javax.swing.JFileChooser cannot be applied to given types requ...

How to Modify the default editing behavior of a TreeCellEditor (Java)

I have a custom object that has a description (String) and priority value (int). I display these values in a JTree because there is a hierarchical relationship between different objects of this type. I only display the description in the JTree nodes because the priority is not important for display purposes. I would like to have a JDial...

Align a JLabel with the text of a JCheckBox

Is there a look-and-feel-independent way to align a component (e.g. a JLabel) horizontally with the text of a JCheckBox? I am trying to use values from the UIDefaults to predict the location of the text relative to the top-left corner of the JCheckBox. I have found a combination that gives the right result for the Metal, Windows, Motif...

How set FilterExtensions for Swing JDialog?

How filter the files by extensions (in the screen), like this example thanks, celso. ...

Java Swing JSlider addChangeListener error

Hello, I am using Swing to make a simple GUI but when I add a change listener to a JSlider, I get the following runtime error: Exception in thread "main" java.lang.NullPointerException at XMovePanel.<init>(XMovePanel.java:15) My code is the following: public class XMovePanel extends JPanel { JSlider xCoord; private G...

how to nest complicated Swing components

In my Swing app, I have a POJO class called Command. Command has a few subclasses. Most of the Command subclasses consist of 2 or 3 Strings. But the data in one of the Command subclasses has a fairly different data format. I also have a class called CommandEditor, which creates the GUI for viewing and editing the various Command subc...

session management in swing based applications.

I am developing a swing based DEFECT TRACKER application. Now the problem is I have to maintain user sessions. I do not have a clue how to do this. Many users may access the system simultaneously and enter their own data. This is a basic scenario seen at many places. Like any login based application we have. Thanks for your help :) ...

SWT_AWT bridge - SWT in Swing problem

I wanted to embed brower into Frame.I wrote public class MyBrowser{ public static void main(String[] args) { final Display display = Display.getDefault(); Frame frm = new Frame("MyBrowser"); Canvas embedded = new Canvas(); frm.add(embedded, BorderLayout.CENTER); frm.pack(); fi...

(discussion) challenges in creating a video player that can stream a video from remote server

hello guys...! I am jay, I am supposed to write a video player which should have a capability to stream a video from a remote server. There may be more than one video streams incoming. please do help me discussing the issues in developing such a player based on following points. Underlying framework for the player to use. Language ...

problem with NumberFormatted Factory in Java swings

Hi all... I use a jFormattedTextField for a telephone number and only to accept the numeric values i declare it as "new NumberFormatterFactory(Integer.class, false)" . Now the problem is when the number starts with 0(zero) like 001345.. , after entered the value and moved to next column the entered value is trimmed as 1345.. here it...

How to prevent JPopUpMenu disappearing when checking checkboxes in it?

I want to use JCheckBoxMenuItems in a JPopupMenu. It works, but the problem is that the popup menu disappears when a checkbox item has been checked or unchecked. So if one wants to check/uncheck several items, the popup needs to be launched repeatedly, which is irritating. Curiously, if I use just plain JCheckBox items in the menu (inst...

fetching float values from jformatted text field

I am able to create JFormatted TextField that accepts only float values,but I am not able to fetch that value.... I am declaring it .. stopAppFormattedTextField = new javax.swing.JFormattedTextField(new DecimalFormat("#.00")); and fetching the value using : double stop=(Double)stopAppFormattedTextField.getValue(); but the above sta...

Spring Swing Integration

Spring does not play nicely with beans that are created outside of its application context. What's the best way in letting me design my forms using JFormDesigner but then using Spring to manage the actions of the components? There are a few ways of integrating Spring and Swing (eg https://www.ibm.com/developerworks/java/tutorials/j-spr...

Adding Color to Font's attributes java swing

I tried to add Color to java.awt.Font's attributes like this: font.getAttributes().put(TextAttribute.FOREGROUND, jColorChooser.getColor()); But I get the error The method put(TextAttribute, capture#12-of ?) in the type Map is not applicable for the arguments (TextAttribute, Color) The Font API says This Font only r...

Align Swing Components across Panels

We have a JPanel wich contains multiple JPanels wich contain JComponents (let's say JLabels and JTextboxes) Inside each of the internal JPanels we use JGoodies Layout in order to ensure proper alignement of all Labels. But of course we would like to have all the Labels aligned independently on which subpanel they are. How could we do...

Java - JPanel won't show up on JFrame when overriding JFrame's paint

I have a JFrame on which I am using overriding the paint method to display some graphics. I also want to add a JPanel to it that will show up on top of the graphics. Right now, all I see is the graphics created from JFrame paint method. Here's my JPanel: public class NoteDraw extends JPanel { public NoteDraw() { setSize(20...

Java - control Z order of JPanels

In short, my need is to have a background Image in my java app, and upon some event, create some other graphics on top of that image. I was thinking I would use a JPanel to draw the background image in, add it at to my JFrame the start of program, and then add other JPanels on top of that upon certain events. The problem is Swing gives ...