Win a copy of Event Streams in Action this week in the Java in General forum!

vincenzo palazzo

Greenhorn
+ Follow
since May 26, 2019
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
1
Given in last 30 days
1
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by vincenzo palazzo

The button Border is painted with method paintBackground() inside the BasicButtonUI, you can change the border with the graphics object

syed fazal faheem wrote:Hi,
As a quick intro, i am developing look and feel implementation for my swing application. I am having a set of internal frames in my application.
When i try to set the button border in UIDefaults, even the minimize, maximize and close buttons of internal frames are getting affected. Can any one help me out with this.
This is the code i used to set the UIDefaults in a class derived from javax.swing.plaf.basic.BasicLookAndFeel
 protected void initComponentDefaults(UIDefaults table) {
   super.initComponentDefaults(table);
   Object[] defaults = {
     "Button.font", new FontUIResource("Arial", Font.BOLD, 12 ),
     "Button.border",new BorderUIResource(new OvalBorder()),
     "Button.margin", new InsetsUIResource(8, 8, 8, 8)
     };
    table.putDefaults( defaults );
 }
OvalBorder class implements javax.swing.border.Border interface

Waiting for a solution,
fazal.

2 weeks ago
Hello guys,

I'm developing a new look and feel for java, this look and feel import the Material-style.

I had used the UIDefault for import the change inside the look and feel, so now I must uninstall the look and feel and I have a problem with this operation.

The look and feel con not removed correctly, now I've used for all operation the UIDefault map and I think this is an error because my constant override the old constant and when I go to remove my look and feel. the new look and feel don't override my constant

This is the code on github for UIDefault at line 208

This is my look and feel


This is the wrong effect


The demo is inside the src/test/integration/gui/mock

I wanted to ask you if the problem is the one described above and especially if I used UIDefault badly
2 weeks ago
Thanks so much Piet, I will study in the next hours your code, thanks so much for your help.

Piet Souris wrote:Well, here is my (very) quick & dirty attempt. It has some serious limitations, but that for later.

3 weeks ago
Can you give me an example?

Les Morgan wrote:You can create shadow on any color by subtracting from the individual Red Green and Blue shades.

1 -- get the RGB value of the color you wish to shade...
2 -- break the values into Red, Green, and Blue...
3 -- subtract an appropriate vlue for shading that you desire
4 -- make sure all RGB values are 0 or greater
5 -- reintegrate the RGB values back into the custom color
6 -- use the custom color for your shading.

3 weeks ago
Hi thanks so much,

Is it that you want the border of the button to fade out? my answer is "The background of the panel"

I don't know where to fix my method, maybe it doesn't work and I have to change approach?


Piet Souris wrote:hi Vincenzo,

your method does also work for non-white backgrounds, but apparantly not in the way you want.

What you are doing, if I understand correctly, is drawing some RoundRectangles, from almost at the rim to the rim (in this case in three steps), with a color that starts slightly black and ends with fully transparent black. That happens for both the wihite and the blue/green button.

However, the effect is that we end with the background of the button, since the color that we use for that final RoundRectangle is fully transparent. For the white button, we end thus with a while color, but since the background of the panel is also white, it looks like the effect is working. But for the blue button, we end with the blue background of that button, unchanged, and that makes as if the effect is not happening there. The first RoundRectangle, with an alpha value of 50, is visible as you see, but then it rapidly changes to the background.

Now, it is not clear to me what the real effect is that you are trying to achieve. Is it that you want the border of the button to fade out? To What? The background of the panel, or the background of the button, or to white? I myself just experimented with a Shape, that is formed by two RoundRectangles, so that the inside of the shape is the area between the two rectangles, and filling the Shape with a GradientPaint. But that was not so easy to set up, and itstill leaves the question what colors to use to interpolate to.


3 weeks ago
I'm developing a new look and feel for swing and now I have a problem when I go to create a shadow in the JComponent an example when I go to create a JButton with a color different to White I have a not correct effect of shadow

This is the code like creating the shadow.



and this is the right effect with the white color




and this is the wrong effect with the other color



How I can do generalize my method paint shadow?

This is a minimal example for this code



The button white is a correct effect but the button green the shadow is wrong


3 weeks ago

Paul Clapham wrote:Okay, you're ahead of me in working with Swing look and feels. Good to hear you have the solution now.



Thanks so much for your answer and for you beautiful words
1 month ago

Paul Clapham wrote:Hi vincenzo, welcome to the Ranch!

To me it looks like you're setting the JComboBox's border at line 32 of your code. You say you don't want that border? Then it seems to me you could just remove that line of code.

You also have a method called createArrowButton which does a lot of things with your special border-maker, but I don't see any code which calls that method. Anyway I don't understand why you don't put the special border around the combo box, instead of making a separate button.



Hi Paul, thanks so much.

I'm setting my border round whit this code but the line of the border is round and the border doesn't is round.

To me it looks like you're setting the JComboBox's border at line 32 of your code. You say you don't want that border? Then it seems to me you could just remove that line of code.



Because this method is the method for setting a button od the JComboBox and I inherited all to BasicComboBoxUI

You also have a method called createArrowButton which does a lot of things with your special border-maker, but I don't see any code which calls that method. Anyway I don't understand why you don't put the special border around the combo box, instead of making a separate button




I found the problem and I edited the question with the solution, thanks so much
1 month ago
Hi guys,

I'm doing developing a new look and feel for swing and now I want to create a new style of a combo box with the border round.

I have implemented new Border and this is the code

and this is the effect


But my problem is when I add the panel black and the JComboBox background white the effect is wrong and it is equal this



My component MaterialComboBoxUI is this



My problem is how remove the rectangular border to JComboBox?

Solution
I rewrite the update method, this is the code


This is the effect
1 month ago