Skip to content

Tag: swing

How do I close a JOptionPane once a button is clicked?

I’ve seen other solutions using yes-no-cancel options but I am using an array of three options for the user to choose from as a sort of pre-launch menu for my app. I’m sorry if my code is awful to look at, I’m still new to this. I want to close the JOptionPane.showOptionDialog() once any of …

Variables passes as null to another Java Frame in Netbeans

I am trying to take a value from MSSQL to a class. In my login GUI frame the variable passes exactly right, but when i pass that class object to another frame the name (String ograd) variable returns as null. Here’s the teachermanagement.java file: loginGUI.java file where i take variables from my MSSQL…

Swing – How to modify the border color of a JButton?

How to modify the border color of a JButton? I want to get something like this: But I can´t modify the color, the borde is black: And If I try to add a LineBorder or any other borde, I am not able to remove the inner border: Answer I tried an example below and all seems fine, unless you are

java swing – How to draw Rects one on top of the next using?

Using java swing, I have a horizontal line (acting as the horizon). I want to draw rects, stacked, one on top of the other where the rect with the largest width is at the bottom and the rect with the smallest width is at the top. I also want the rects to stick to the horizon when the user re-sizes