Color of JOptionPane border - java

How might I go about changing the color of a JOptionPane's border?
Here is a screenshot of the border I am talking about:
That blue border is what I am trying to get rid of.
I tried to set UIManager.put("OptionPane.border", new BorderFactory...)for LookAndFeel but that changed the inside border, not the outermost one.
I need to get rid of that blue border.
Any ideas?
-Mark

Read the JOptionPane API. It shows you how to create a JOption pane manually so that you have access to the JDialog. Once you have the JDialog you can remove the Border the same way you did in your last question:
Undecorated JDialog border

I have research on it these days, finally I found this code may help you!
UIManager.put("RootPane.frameBorder", new LineBorder(Color.red));
UIManager.put("RootPane.dialogBorder", new LineBorder(Color.red));
UIManager.put("RootPane.errorDialogBorder", new LineBorder(Color.red));

In LaF section there is the initialization of ShadowPopupBorder which used for tooltips, popups, and modal dialogs borders. So check if it is used around your software

Related

How to set a line border around JTextArea?

I have a JTextArea in my panel, but it is hard to distinguish it from the background.
I tried setBound() but it doesn't really help.
Screenshot of my GUI
(The textarea is next to
the 'DESCRIPTION')
Is there any way to have a clear bound around it other than changing the colour of the background? Say having a line bound like what JTextField has(I put one next to 'EXPENSE' in my GUI).
Thanks for the guys in the comment area! I put the textarea into a JScrollpane. It does create a border:
using JScrollPane
Then I also added a line border to make it more clear.
des.setBorder(BorderFactory.createLineBorder(Color.BLACK));
Thanks again to Andrew Thompson, the suggestion about using GridBagLayout does make everything look much better.
Using GridBagLayout

JComponent Titled Border

I am making a simple swing application and I want to add some titled borders to my components. The border on both of my JScrollPanes work fine, but the JTextField and the JButtons don't. Allow me to share some screen shots.
I just have simple code for this. i.e
TitledBorder border = new TitledBorder("Border");
convert.setBorder(border); //convert is the JButton
I don't see why it would not work for one thing, and work for the other. Can anyone help me out?
A JTextField and JButton both use a Border already. So the titled border works but it changes the appearance of the component because you lose the default Border.
I also agree that normally you don't use a TitledBorder for an individual component but I suppose you could try to use a CompoundBorder to see if it looks any better:
CompoundBorder border = new CompoundBorder(titledBorder, button.getBorder());
button.setBorder( border );
but then the problem with the above approach is that you lose dynamic repainting of the border when you press/release the mouse on the button.

how to make components visible in a transparent JFrame

I have some JButtons in a JFrame (its layout is null). The background Color of the buttons are set Black. I have made the JFrame Transparent by using this code.
AWTUtilities.setWindowOpacity(this, 0);
But the problem is it also makes all the buttons transparent as well. I don't want that. I want to see the buttons remaining black but the other portions of the JFrame becoming transparent (so that I can see the desktop background). Please someone help me.
Thanks in advance.
What about using the call button.setOpaque(true) ?
Yeh, the problem was opacity set to zero. Any non-zero value with all button.setOpaque(true), will display buttons clearly. For me, AWTUtilities.setWindowOpacity(frame, 0.7f) works too.

JButton setBackground doesn't work

i try to set Background color of jbutton, but doesn't work? Look at image. Why doesnt work? How to fix?
I want red background :-)
save_button.setForeground(Color.red);
save_button.setBackground(Color.red);
close_button.setForeground(Color.red);
close_button.setBackground(Color.red);
Add to the code for both buttons :
save_button.setOpaque(true);
It should work, if not try disabling the border color

Java - Is it possible to put a JLayeredPane inside JScrollPane?

when I try putting my JLayeredPane inside a JScrollPane I get a blank window (with white background) instead of the content I am trying to render (it could be an image, a button, a canvas). Does anyone know of a problem with layout managers that might cause it? Is it possible?
EDIT:
thanks to camickr help, I can now put a JLayeredPane inside a JScrollPane, though now I am facing a different problem:
I am using a very large image and I am trying to put it inside my JLayeredPane that's inside the JScrollPane. From some reason when I use this large image (I am not receiving a heap overflow exception) I get this blank (white screen). Has anyone experienced something like this?
Well this is pretty much a guess because you haven't provided much information, but it sounds to me like the JLayeredPane's preferred size is (0,0), and the "white" you're seeing is the background of the JScrollPane's JViewport child. Try setting a preferred size on the JLayeredPane as a start.
Read the Swing tutorial on How to Use Layered Panes for a working example.
Change the following line:
// add(layeredPane);
add(new JScrollPane(layeredPane));

Categories

Resources