jQuery in Action, 2nd edition*
The moose likes Swing / AWT / SWT and the fly likes Detecting skin component Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Detecting skin component" Watch "Detecting skin component" New topic
Author

Detecting skin component

Michel Legris
Greenhorn

Joined: Feb 21, 2012
Posts: 19
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

Joined: Jun 09, 2003
Posts: 4632
> 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

Joined: Feb 21, 2012
Posts: 19
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

Joined: Oct 27, 2005
Posts: 19682
    
  20

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
if you're iterating components, pehaps you can isolate it more
if you check first if 'container' is an instance of JPanel
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Detecting skin component