swing

JOptionPane to appear on selected JCheckBox

Hi all I am having some difficulties with adding a joptionpane in JcheckBox listener public void itemStateChanged(ItemEvent evt) { if(evt.getStateChange() == ItemEvent.SELECTED){ ///some code JOptionPane.showMessageDialog(null, "Message", "Alert", ...

Custom Monitor Resolution not recognized by Java

My weird monitor's native resolution isn't recognized by Windows, so I have to set a custom resolution for it. The problem is that java doesn't recognize it since it's not on Win7's "approved" list, so full-screen mode gets "stuck". Netbeans comes out of full-screen fine, so there has to be a way around this. Anyone know it? //Edit (3/2...

how to draw a line between two labels in a panel where labels are added during runtime

A panel contains two labels which are generated by mouse clicks on the panel. I want to connect these two labels by drawing a line between them probably by dragging the mouse pointer from one label to another. There are two events here - one is clicking on the panel to generate the labels and the second is connecting these two labels (m...

Making serach on database and Listing results with Hibernate in Java

I am developing swing based application with hibernate in java . And ı want to make search on database , and listing result... Before ı used to JDBC and ResultSetTableModel , and my before code is here : try{ Class.forName("*****************").newInstance(); Connection baglan=(Connection) DriverManager.getConnection("*******...

jList in Scrollpane, seeking and displaying value of selectedIndex

I have a JList inside a Scrollpane. If you click on the list and move the arrow keys up and down it works like you expect, you can move your selection index and display around just fine. Now, what I want to do is basically have a text box and i'm typing in the text box like "comic" and want it to seek to the index of that value. This ...

print matrix in dialog box

Hello, I'm having a little difficulty to print a matrix array on dialog box. The matrix is integer and as far as i understood i need to change it into string? anyway, here's the code: public void print_Matrix(int row, int column) { for (int i = 0; i <= row; i++) { for (int j = 0; j <= column; j++) { JOptionPane.s...

How can I set size of a button?

I put my buttons in a JPane with GridLayout. Then I put JPanel into another JPanel with BoxLayout.Y_AXIS. I want buttons in the GridLayout to be square. I use tmp.setSize(30,30) and it does not work. I also try to use new GridLayout(X, Y, 4, 4) but I cannot figure out what X and Y are. So, what is the correct way to do this stuff? ADDED...

JComponent undock effect

I'm trying to accomplish an undock effect for a custom Swing JComponent. By default the component is used inside a form along with other components. I want to be able to maximize this component to use the whole screen and then be able to dock it again. So far I've tested public void showDialog() { JFrame mainFrame = App.getAppl...

Can Box Layout accept size of included elements?

I used myPanel.setLayout(new BoxLayout(myPanel, BoxLayout.Y_AXIS)); to order panels vertically (one under another one). But myPanel defined in the shown way change the included panel. In more details, it tries to set the same hight and width for the included panels. Can it be changed? Can BoxLayout adopt size of the included elements? A...

A classic StackOverflow : Java Swing

Greetings everyone! I programmed GUI Application using Java Swing under Windows. Under windows everything works well. Now I am trying it under Linux (using distribution Linux Mint 7). I am getting and nasty StackOverflowException, when I call frame's dispose method! The problematic frame is JDialog component. Here is some output : ed...

Can I fix the width of JRadioButton?

I have sever JPanels which have to be ordered vertically. For that I want to fix the width of the JPanels. Because if they are too short in comparison with the windows width, they will go horizontally (one after another) and I do not want it. At the moment the width of the JPanel is not constant because the width of the JRadioButton (inc...

Multiple Components in a JTree Node Renderer & Node Editor

I am attempting to create a JTree where a node has several components: a JPanel that holds a JCheckBox, followed by a JLabel, then a JComboBox. I have attached the code at the bottom if one wishes to run it. Fortunately the JTree correctly renders the components. However when I click on the JComboBox, the node disappears; if I click on t...

Positioning child panels using FlowLayout

I have two panels: main_panel child_panel The main_panel layout is set using: main_panel.setLayout(flowlayout) I then added child_panel to main_panel: main_panel.add(child_panel) The child_panel gets added to main_panel but its position is at the cross-section of horizontal midpoint and top vertical section of screen. I want ch...

I have to select the checkbox two times to check/uncheck in jTable

I have a jTable code i intend to use, but the problem with it is that when i click on the checkbox once it doesn't select/deselect it, instead i have to click twice. But if i select any other cell in the row except the one containing the checkbox the purpose is solved. HERE IS MY CODE : public class TableSelectionTest extends JFrame im...

Java - Swing / AWT ComponentListener unexpected behaviour

Hi, Got a problem with ComponentListener. I'm using it to check if a certain component is resized, and to update some stuff if it is. The code looks like this though this probably won't be much use to you: @Override public void componentResized(ComponentEvent e) { // Graph resized, reposition slice nodes Component c = e.getCom...

Why a Swing app stops my Java servlet ?

I have a Swing runnable app which updates messages, then I have a Java servlet that gets messages from Paypal IPN (Instant Payment Notification), when the servlet starts up, in the init(), I starts the Swing runnable app which opens a desktop window, but 30 minutes later an error in the Swing caused the servlet to stop, how can that happ...

Plugin support for a Java swing App (like Eclipse)

I need to add Plugin support to a Java Swing App (like in Eclipse). The Plugin should have the ability to add new Menu items and tab components to the swing app. I am looking for frameworks or libraries which support it. So far I have found Java Plugin Framework http://jpf.sourceforge.net/ and planning to use it. Are there any other b...

How do I lock the mouse inside a JFrame

Hello, I would like to lock the mouse inside a JFrame. That is, the mouse can not leave the contents of the JFrame (unless the user hits escape, alt-tab, or the window otherwise looses focus). Ideas? Thanks! ...

How to adjust position of scroll in the scrollpane

I have created JTextpane and inserted components inside textpane (components like Jtextarea). (vertical scrollbar of )Jscrollpane of JTextpane is automatically set to bottom when I insert new components in that JTextpane. I want to keep it to be set to the top position. How can I do this Thanks Sunil Kumar Sahoo ...

Java Swing application won't quit after recieving TERM signal

I have a Java Swing application that is being used as a cluster application. The problem is that every time the cluster tries to terminate the Java application, it just hangs and Windows displays the "End Now" dialog. The said application is a server type one so it spawns a thread for every attempt to connect to it is made. I learned th...