swing

How do I position labels of varying heights in two rows using GridBagLayout?

I'm trying to use GridBagLayout to position labels in two rows, but I want some of the labels to span both rows and others to be placed on top of each other. I need to use GridBagLayout because of the proportional sizing functionality in the weightx and weighty properties of GridBagConstraints. This is the layout I'm looking for: +--...

Java JTextArea that auto-resizes and scrolls

I have a JTextArea in a JPanel. How can I have the JTextArea fill the whole JPanel and resize when the JPanel resizes and scroll when too much text is typed in? ...

Integrating a Swing App With Tomcat

Hi All. I recently created a web application with GWT. Then re-used most of the code to create a Swing version of the application that accesses a local database in offline mode. I am now implementing the 'online' mode of the application and want to access the same data as my GWT application. Any ideas? Considered connecting directly to...

problem displaying mouse coordinates on the screen in java

Hi, I'm trying to display mouse coordinates (math coordinates) in my JPanel , but i get each coordinates on top of the other ,can' figure out why . here's my code : import java.awt.*; import java.awt.event.MouseEvent; import java.awt.geom.Line2D; import java.awt.geom.Point2D; import java.applet.*; import javax.swing.JPanel; import java...

Setting Time Format for jspinner in swings

Hi All, I am working in a java swing application. In that application i have to take time input from user. I need to make a JSpinner for the time, only in the hh:mm am/pm format. i searched in properties but could not get this format. Please suggest me some way to display time in hh:mm am/pm format. I thank to all your valuable suggest...

GridBagLayout goes crazy

I have a GridBagLayout, but one label (maxSizeLbl) goes crazy and an other one (maxDateLbl) isnt visible, anyone knows what I've done wrong? Here is the Picture: And here is the Code: import java.awt.Component; import java.awt.Container; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import javax.swing.JButton; ...

Super simple java swing jlist question that I just can't figure out!

Ok, so I am working on a homework assignment, and I am using SWING to make a GUI for a Java project, and I am running into troubles with JList. I have a customer object that I have made and set attributes to, and I want to add the object into a TreeMap. I want to hook up the Treemap so that any and all objects that are in the map will p...

IzPack and accessibility (using a screen reader)

Hello, I'm curious if there is a way to set up an IzPack installer so that it works with screen readers (and has more accessibility features in general). Any thoughts? Thanks in advance, -Jon ...

Java - custom cursor is different in different operating systems

Hi I create custom cursor with bottom code: Toolkit toolkit = Toolkit.getDefaultToolkit(); Image image = toolkit.getImage("C:/Users/Administrator/Desktop/gaea/core/ui/gaeawindow/src/si/xlab/gaea/core/ui/gaeawindow/HandCursor.gif"); // Somewhere in mouse pressed action public void mousePressed(MouseEvent e) { Cursor cursor...

Sharing children among parents in a JTree

Hello everyone! I have a custom DefaultMutableTreeNode class that is designed to support robust connections between many types of data attributes (for me those attributes could be strings, user-defined tags, or timestamps). As I aggregate data, I'd like to give the user a live preview of the stored data we've seen so far. For efficiency...

Jython - attempting to call functions from JFrame, receiving 'NoneType' error

So I'm playing around with Jython, trying to slap together a generic GUI. Nothing beyond what they have on the Jython Wiki for swing examples. So I declare a JFrame, and then try to add a panel, some text fields, all that good stuff. I get this error when I run it, however. "'NoneType' object has no attribute 'add'" Here's the basic cod...

Problem in valueChanged method from the ListSelectionListener interface

I have created a JDialog with three JList lists. The selection of a row in the first list (named FirstList) updates the content of the second list (SecondList) and the selection of a row in the second list updates the content of the third list (ThirdList). In the ThirdList class I have included the following method: public void addRowsS...

Java - JFrame, JPanel, Layout, and Clipping

I have three questions/problems. (NOTE - I don't have enough reputation to post pics, so I linked them. And I needed to obfuscate them...) 1) I created a panel that holds my game graphics (the player area). The panel is supposed to be 800x800 and clip everything that lies below and to the right. But when I add the graphics panel to a JF...

How to switch two components

Hello, I have a JPanel with a GridBagLayout. And I would like to give the user the possibility to switch two components. I tried it like that, but it doesn't work, what is wrong? public void switchSites( boolean b ) { this.remove( blueSite ); this.remove( whiteSite ); GridBagConstraints c = new GridBagConstraints(); c....

Java: Show JPopupMenu without passing an invoker component.

Hi, When I let popup a JPopupMenu without passing the "invoker component", the menu doesn't work: submenu's don't open and isn't getting repainted. But when I create a completely useless JFrame with a JLabel inside, and I pass the JLabal as invoker, it works correctly... Any suggestions, how to avoid creating a useless frame. And my ap...

Java Swing; Problems with Horizontal Scroll for a JTable embedded in a JScrolledPane

I followed some tips in this guide: http://stackoverflow.com/questions/2452694/jtable-horizontal-scrollbar-in-java but still having problems. I have two column headers: Name and Description (for our purposes in this ex.) I want to be able to scroll horizontally whenever an entry is added (ie: Name/Description is just 1 line). However,...

Stop a swing Timer from inside the Action Listener

Hi , I'm trying to stop a timer inside the the ActionListener. Below is the code of what i'm trying to do. I'm tring to stop the timer i created when a certain condition is met inside the actionPerformed method. timer.stop() does not work , the compiler does not let me do that. Any help . suggestion , advice would be really helpful. ...

Java - JOptionPane.InputDialog - What if user enters no input and clicks OK?

Well, I'm trying to create a way of detecting if the user inputs nothing and clicks 'OK.' For example, if the user clicks cancel, I break out of a while loop with the following code: if (words[i] == null) break; //breaks out of while loop I tried something along these lines for a user clicking OK: else if (Character.isDigit(words[i]...

hide one part of JSplitPane in Applet

Here is my situation, i want to implement a sidebar on the right side of a JFrame. The sidebar is hidden in default, appear if i click a button. In order to hide the sidebar, I set the divider location of the JSplitPane with a very large value, say 10000. It works properly in normal java application. Also, i set the setResizeWeight of ...

Java Swing: Relative Positioning and Automatic Resizing ?

I have a createUI() function which loads JPanel into NORTH, SOUTH, EAST. private void createUI() { add(createToolBar(), BorderLayout.NORTH); add(createDataView(), BorderLayout.SOUTH); add(createHistoryView(), BorderLayout.EAST); createMenuBar(); setTitle("My Application"); } Each components display in the correc...