Based on http://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/size.html with the purpose to create a button that fits one tab from JTabbedPane How to add close button to a JTabbedPane Tab? I built the code below. It should show a mini button as is in java documentation, but even that I change the size the results are the same. What am I doing wrong please? Thanks in advance
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class buttontest {
public static void main (String[] args){
buttontest t = new buttontest();
}
public buttontest(){
JFrame test = new JFrame();
JPanel pnlTab = new JPanel();
JButton btnClose = new JButton("x");
btnClose.putClientProperty("JComponent.sizeVariant", "mini");
pnlTab.add(btnClose);
test.add(pnlTab);
test.setVisible(true);
}
}
EDIT ONE:
try {
for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (UnsupportedLookAndFeelException e) {
// handle exception
} catch (ClassNotFoundException e) {
// handle exception
} catch (InstantiationException e) {
// handle exception
} catch (IllegalAccessException e) {
// handle exception
}