swing

JSlider for doubles

Hi, I am making a GUI (using swing) for a poker framework and need some sort of slider to allow players to select a bet size. However the Swing JSlider only works with int values whereas i need something that can support doubles for 1 decimal point. Are there any libraries I can use, or tricks with the JSlider? Thanks ...

How to draw a filled square box in Java that is exactly in the center of an applet window?

How do you draw a filled square box in Java that is exactly in the center of an applet window? and when resizing the window, it is centered horizontally and vertically within the applet window? I want it to adapt to the vertical height of the screen but stay square even as the horizontal width edges. If the window is resized to be too na...

Is it possible to have a java swing border only on the top side?

I know how to create borders using BorderFactory but I don't see anything that lets me specify what sides I want the border on :S ...

Swing ComboBox with the choice of "none of the below"

I have a perfectly normal ArrayList<MyObject> that I need to edit and pick an object from. In the application window, I have a JComboBox to select the appropriate choice from the list. I'm writing an editor dialog for these objects, which just includes a JList of these objects and editor fields. It's easy enough to do; I'll just have a ...

KeyListener receives the "key-hit" before my JTextField does..?

Hi. I got a JTextField, and to that field I have added a Keylistener. Inside the keyPressed method, I ask the method to print (System.out.println) whats inside the JTextField.. If I hit a letter, it seems as the Keylistener receives this key-hit before the JTextField is updated.. I have to hit two letters to see the first one.. All I ne...

Initializing JCheckBoxes when they are generated by a Table Model

In Java Swing I have created a JTable which uses a table model class which extends DefaultTableModel. As the values of one row of the table are of boolean type, these are displayed as check-boxes. As I want to add to these check-boxes 'item listeners' classes, I do need to initialize each of these check-boxes. But how do I do if these ar...

How can I place @Action methods in a separate class from a Swing component?

When developing Swing applications, I've typically defined a delegate interface for each UI component for action callbacks. For example, if there is a class, MyDialog, which contains a button, MyButton, then the ActionListener for MyButton will call MyDialog.Delegate.OnMyButtonClick(Event e). The UI component then becomes "dumb" and requ...

swing JTable: tweak "enter" so it acts the same as double-clicking a row

I'm having a brain cramp -- how do I set up a JTable so that the enter key acts the same as double-clicking a row? The "nice" brute force way is to call JTable.getInputMap() and JTable.getActionMap() and add a new action name and a new Action that does a double-click. But there must be a better way, I think.... ...

Java application does not work properly outside IDE's directory

When I run it with NetBeans it's all OK. When I copy dist directory contents and run .jar, some stuff gets buggy. Most important, JTable editing gets messy, some fields lose focus only when you hit ESC (if you did hit ENTER before, changes are accepted, otherwise they are not, but you need ESC in both cases) and similar weird stuff. I go...

JFrame not working after first instantiation?

As part of a larger application, I am writing a settings class, which collects and stores user-defined settings. This class is a singleton, and is instantiated during application startup. In order to accept user input, two different GUI frames are insantiated from within ConfigSettings.java, from a public static method, selectSettings(...

override display appearance of accelerator keys in JMenuItems in Java/Swing

I've noticed that on some macs the JMenuItem uses the word "space" to indicate that the space bar is the key binding. On other macs a symbol is used (looks like a short capital U). I'd prefer the "space" presentation since it's more transparent to users. Is there any way to override how the LAF graphically represents the accelerator key?...

Get DefaultListModel to use LinkedList

Is it possible to make a DefaultListModel use the contents of a LinkedList to display? This is then to be used with a JList. ...

setting Swing JInternalFrame lnf manually.

UIManager.put("InternalFrame.activeTitleBackground", new ColorUIResource(new Color(207,255,247))); UIManager.put("InternalFrame.inactiveTitleBackground", new ColorUIResource(new Color(207,255,247))); JDesktopPane baTabbedPane = new JDesktopPane(); JInternalFrame iframe = new JInternalFrame("Cheapest To Deliver",true,true,true,true); ifra...

How can we print docs from SWING application

We have swing application. It includes documents(PDF, MSWord documents) Can we call system's print dialog form our program to print this documents? Target operating system is Windows XP. And, id it is impossible, how can we process PDF and print PDF from java? ...

Can I build attractive GUI in Java?

Can I build attractive GUI in Java? If yes, how should I do it? Or should I use some other language or tool to do it? ...

Java Class Architecture for swing GUI programming

I am writing an application that requires a large amount of swing GUI components. I am having a lot of trouble organizing the class. Is there a methodology to organize and neatly layout class architecture? I find my constructor confusing it consists of many components being initialized followed by several event handlers. In addition, ...

Swing dialog Paint Issue

I have a Swing GUI that displays a dialog when a trade occurs, but sometimes the pop-up does not paint. Moving another application over the dialog paint area (place where the dialog should be displayed) causes the dialog to paint. I haven't been able to re-produce the problem consistently. I know that the "Direct3D Accelerated Rend...

Sharing state between JButtons

I want to create two or more JButtons that share state, i.e. when the mouse button is pressed over either JButton, both are rendered as depressed (aka "armed"), or if they are checkboxes, both are checked/unchecked simultaneously etc. To the user, it must appear as if both buttons were the same button, appearing in more than one place i...

Can I make a video of a running Java Swing application on the fly?

Hello everyone, I have a Java swing GUI program that renders anywhere between 1 and 25 frames per second. It is only one window and only one panel to which I do all the rendering, e.g. no other Swing components. I need to be able to produce videos of test runs of my program as it runs. The problem is that regular screen casting tools ...

How to propogate Swing events from a inner component to a container?

Hello, I created a component based on a JPanel that contains a textfield and a checkbox. Since I use it as component and put it around in other panels I'd like to be able to set a KeyPressed event for the panel. Obiouvsly this doesn't work as the keyPressed events fire for the inner textfield. Is it there a way to propagate them to the J...