Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
Very general question, I am just confused on what setBorderPainted does. I'm creating a GUI and I need it. What happens if I don't include it in my GUI, will it effect anything?
Thanks
It is a property of javax.swing.AbstractButton.
When you set this property to true, and if the button has a border, it will paint the border.
As far as I know in certain OS like MAC, when you set the background color of the button, only the border of the button is painted with color. Some people will set this property to false so that the background can be seen colored.
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 months ago.
Improve this question
I have the following, code which almost does what I want except it doesn't automatically stretch to the right, so the whole label can be seen. I've tried different constrains on it, but it doesn't change, setting the JFrame bigger works, but I would like it to resize depending on the label length, so it doesn't occupy more space on the screen than needed.
The UI Window
Run JFrame.pack() to resize the frame according to it's components.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 months ago.
Improve this question
I am a java beginner and i tried to lock it up and tried diffrent command but none of them worked.
I want to change the Background Color of Button for example from red to green.
The following code will set a buttons color to red:
Button button = new Button("My Button");
button.setStyle("-fx-background-color: #ff0000; ");
If you need any more help with buttons you can refer to the documentation here:
https://docs.oracle.com/javase/8/javafx/api/javafx/scene/Node.html#setStyle-java.lang.String-
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
So there will be a text field that I disable using the textField.setEnabled(false) method. However later on in the code I want to enable this text field back again. textField.setEnabled(true) does not work at this moment.
How should I address this problem?
Try to create a Jtextfield like instance variables
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
My program contains of a JDialog with a button which opens a JFileChooser. After Clicking on this Button my main JDialog gets hidden even if it's set to modal. This shouldnt happen.
What to do?
Setting the JDialog as a parent to the JFileChooser should "hold" it in place.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I currently have a menu, that whenever I click on one of the options, I want to clear the screen (to clear all my JLabels and text areas). I use the code
getContentPane().removeAll();
getContentPane().repaint();
add(comboBoxOptions);
to clear the screen. After that I try to add a combo box, which adds but it doesn't show up. I can click on the options but it's hidden somehow I guess. How could I fix this?
How could I fix this?
Use a CardLayout, see How to Use CardLayout for more details
Swing's layout management API is lazy, it won't update the layout's automatically, it waits till you tell it to. This is a good thing.
You need to use revalidate to force the container hierarchy to be relaid out and repaint to schedule a repaint of the view, for example
getContentPane().removeAll();
add(comboBoxOptions);
revalidate();
repaint();