bebbo duce

Greenhorn
+ Follow
since Nov 14, 2009
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by bebbo duce

mark goking wrote:since you are using mouse events, you can use the consume() method to nullify any actions unless if it falls under the mouse drag released method


Thanks, I will try that
14 years ago
Greetings averyone,
this should be pretty simple but i can't figure out how to do it.

Is there a way to set a JFrame to repaint on resize only when the mouse drag is released?
JSplitPane has a similar behaviour for its divider, available through setContinuousLayout().

Thanks in advance.
14 years ago
I resolved adding an AdjustmentListener to the scroll pane and a TreeSelectionListener to the tree, both of whom call a repaint of the gradient pane.
Hope this will be useful to someone.
14 years ago
Sorry to bother again, but your solution has a little problem...
Calling repaint() inside paintComponent() causes an infinite loop, that causes the continuos rapaint of the tree.
You can notice that when your example is running the cpu usage goes over 70-80%.

Any ideas on how to call repaint only once?
Thanks in advance.
14 years ago
That worked perfectly.

Thank you very much, now my tree looks fine.
14 years ago
Thank you for your quick reply, however setting a custom renderer fails to solve my issues.
Transparent labels on the tree are very cool, but with them the problem gets even worse!
If you have time to spare, try and run that code i posted so you can understand what I mean.

Thanks anyway for your patience.
14 years ago
(I'm very sorry about posting again but I cant' find a way to edit the previous post)

I found a dirty way to partially solve the issue, it seems to work ok if you add super.updateUI() at line 54.
The problem is, this solution doesn't work anymore if the tree is contained inside a scroll panel like this:



Here's a list of the graphical issues this piece of code has:
1) sometimes, expanding and/or collapsing the nodes does not properly repaint the tree;
2) when the horizzontal scroll bar appears, the tree seems to lose it's transparent background in favour of a default grey one (this is courious beacuse in another piece of code, very similar to this one, this strange behaviour belongs to the vertical scroll bar instead);
3) scrolling the panel leaves awful after-images of the tree;
I am pretty sure that all of these have a common solution...

I apologize again for bothering, not being able to update the other post.
I'll be grateful to everyone able to help me.
14 years ago
Greetings everyone,
I'm having a lot of trouble with transparent JTrees,
I've extracted the portion of code that gives problems in a simple executable class:



The real piece of code inside my application is a little (a lot) more complicated, but i found out that a simple class like this one above presents similar problems to mine.
If you play a little with the tree (open and close various nodes several times) you will notice that the nodes tend to overlap one with another, giving an awful visual effect.
Please notice that this does not depend on the GradientPane that contains the tree, because it does the same with a normal JPane.
However, i found a workaround in the case of a non-gradient background, but that's not the thing i'm interested in.
The problem gets even worse if you put the GradientPane into a scrollPane and/or if you use a custom cellRenderer, you will get a real mess as you move around the scroll bars.
It's really important to me to have a gradient background under that tree, but it seems that my experience with swing is really not enough.

P.S.
If that could matter, i'm running on windows.
I don't know if the problem can be reproduced on other systems.
Thanks to everyone kind enough to help.
14 years ago