Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Detecting skin component

 
Michel Legris
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm working on a kind of swing explorer (spy++ for java)

Container container = (Container) jScrollBar1; //previously created
for (int i = 0; i < container.getComponentCount(); i++)
{
JOptionPane.showMessageDialog(null, container.getComponent(i).getClass().getName());
}

The previous code show two childs for a JScrollBar... the children are com.sun.java.swing.plaf.*.*ScrollBarButton (the two buttons of the scrollbar)

My goal is to detect skin component when doing Getcomponent in order to ignore them.

Maybe you can answer to one of these questions :
1- Is there any what to tell that this Specific component (ex: container.getComponent(1)) is a **SKIN** component?
2- Is there any equivalent to javafx GetSkin() to return all the skinning part of a "control" ???
3- Is there any relation between JScrollBar1.GetUI() and the skin components returned as children of the scrollbar ?
4- Is ther any alternative to GetComponent()....a kind of GetComponentWithoutInternalSkin() who return only the highlevel control without all the skin ?

I really need help...thanks!
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> My goal is to detect skin component...

not heard of the term 'skin component' before.
are they specific components?
e.g. JScrollBar (or JScrollPane), JComboBox, JSlider etc?
 
Michel Legris
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The real term in swing is more Look and feel component.

By skin I mean any child components ONLY used for skinning and available with Container.GetComponent(). There are "skin components" for all possible components (e.g: JScrollBar, JScrollPane, JComboBox,JSlider, ...)

theses skin can be one of the standards look and feel (metal, Nimbus, ..) or any 1000 other possibles look and feel downloaded from the internet.

How can I distinguish a ScrollBarButton from a JButton since the scrollBarButton inherits from JButton
 
Rob Spoor
Sheriff
Pie
Posts: 20669
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A scroll bar button isn't a proper component of itself. The current one just happens to be a JButton because the ScrollBarUI implementation determines it is a JButton. If you want it to be something else, create your own ScrollBarUI implementation that uses a different way of displaying the buttons.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if you're iterating components, pehaps you can isolate it more
if you check first if 'container' is an instance of JPanel
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic