java titlebar modification - java

I'd like to change the color of the java titlebar and add some text to the ends and the middle.
The previous coder used setUndecorated(false) and a JPanel to achieve this effect but I am trying to change this to modify the actual title bar because the panel solution is an issue with menus and focus.
tl;dr Want to change the color of the titlebar and set text in the middle and one the ends.

I think you can change the title bar color with the method described here: http://www.coderanch.com/t/346141/GUI/java/set-JFrame-titlebar-color
Changing the text should be possible via setTitle(). You can call this method as many times as you want throughout the life of the application to change the title text on the fly.

Related

Is there any method in java which returns the system's theme color?

I am currently working on a JFrame which is to be set to fullscreen by the user. When in fullscreen, the title bar has to be removed by the JFrame's setUndecorated() method. However doing this deprives the user of the title bar. So I added a JPanel named titleBar at the top which appears only when the cursor is very close to the JFrame's top. Now the problem is that I want the titleBar's color to be the same as the user has set in his System's settings. I have tried to find a method in the System and Toolkit classes but it didn't help. Can anyone tell me if there is a method in java that returns me the current System's title bar color. Any help will be appreciated. Thanks for the attention.
Use UIManager.getColor(key). You have to find the appropriate key for your needs. See this other post for more on the keys:
Swing UIManager.getColor() keys

put title of title border to the right in java swing

I have a swing form in my program and I used a panel which uses title border as you see in the picture:
I want to put the title ( marked with red oval ) of title border to the right but I don't want to use applyComponentOrientation function because it reorders all my element in the ?panel, is there any way to do that ?
The place to start is by reading the TitledBorder API.
There are methods like:
setTitleJustification(...);
setTitlePosition(...);
to help you position the title. I'll let you read the API to find the appropriate values for your requirements.
Try this one it has justification method as #camickr said.
setBorder(BorderFactory.createTitledBorder(BorderFactory.createMatteBorder(10,10,10,10,Color.BLACK),"Title",TitledBorder.RIGHT,TitledBorder.TOP));

Java Swing - How to make the JButton's boundaries invisible?

In the screenshot below, you can see four buttons in the selected area. I want to mimic this kind of buttons in my GUI application. Each of these buttons has an image on them (play,stop, forward, rewind). I can use the icon property of the button to add an image to it.
When the user hovers the mouse pointer over a button, three things happen:
it changes color- I don't need this feature.
It displays a tool tip. I know how to do it by using the tooltip
text property of a button.
Most importantly, these buttons don't have a border around them,
That is their bounds are not visible at all. It's just the image
which is visible. I want to do something like this. But when I add
an image to a button, its border does not go away (I mean it's
bounds are clearly visible in the form of a line - as you can see in
the second image)
So what property of an button should I manipulate, or what method should I use, to make its borders (and every visible trace of the button except the image present on it) invisible?
A border is painted when setBorderPainted is set to true, otherwise not:
setBorderPainted:
Sets the borderPainted property. If true and the button has a border,
the border is painted. The default value for the borderPainted
property is true. Some look and feels might not support the
borderPainted property, in which case they ignore this.
Note that some look and feels may ignore this property.
Update:
The default look and feel is called CrossPlatformLookAndFeel. This is not a look and feel but an indicator of the default one. What you get as default depends on the platform you are using. See How to Set the Look and Feel for details. I personally loke the Nimbus Look and Feel, but I have encountered some problems with it. I am not sure if it respects setBorderPainted, but I will not be surprised if it does not.

Draw round Button in LookAndFeel-Style

I'm experimenting with JRadioButton's to put them on a JToolbar and select the last one clicked. If i'd use JButtons they wouldn't keep the Selection.
Since JRadioButton always have that Dot, I need to draw them myself by overriding the paint-methods.
The Button's will be circles with an Icon in it. That works if I draw Images, but looks aweful. The problem I have is that I would like to draw the circle so that these Buttons always look like the JButtons with the current LookAndFeel.
How can i do that? I searched for a while now, but I didn't find methods to read some default-colors of the LookAndFeel which I could use.
So how can i read Background-Colors etc. of the current LookAndFeel to use it for some custom Button-Drawing?
So how can i read Background-Colors etc. of the current LookAndFeel to use it for some custom Button-Drawing?
See UIManager Defaults.
I need to draw them myself by overriding the paint-methods
Don't do custom painting in the component. If you don't like the default Icons, then create your own Icon and do the custom painting there or create an Image and use an ImageIcon. The you can use the setXXXIcon() methods.

Java: Remove title bar buttons only

I've only found ways to completely remove title bar + borders. I want to create a window in Swing without title bar buttons but still retain the default system's border. Is this possible?
The following link has a complete working example that uses remove() on the buttons:
http://www.coderanch.com/t/344419/GUI/java/deactivate-close-minimise-resizable-window
You can use the frame's setUndecorated() method and render your own decorations. You may want to leverage the JInternalFrame UI defaults, which typically recapitulate those of the platform's default Look & Feel, as shown here. These seem especially relevant:
InternalFrame.activeTitleBackground
InternalFrame.activeTitleForeground
InternalFrame.inactiveTitleBackground
InternalFrame.inactiveTitleForeground

Categories