Note that there are some explanatory texts on larger screens.

plurals
  1. POModify the scroll button of a JTabbedPan
    text
    copied!<p>I'm working on a UI on Java with Swing, I want to change the scroll button of a JTabbedPane, so I use a new UI (MyTabbedPaneUI) that I create from the extends MetalTabbedPaneUI.</p> <p>But when I create my JTabbedPanel there are 2 tabs which appear and I don't want them. If I remove them my scroll bar disappear.</p> <p>The code :</p> <pre><code> public class MyTabbedPaneUI extends MetalTabbedPaneUI{ private Icon southIcon = new ImageIcon(MyTabbedPaneUI.class.getResource("south.png")); private Icon northIcon = new ImageIcon(MyTabbedPaneUI.class.getResource("north.png")); private Icon eastIcon = new ImageIcon(MyTabbedPaneUI.class.getResource("flecheVerte-gauche-20px.png")); private Icon westIcon = new ImageIcon(MyTabbedPaneUI.class.getResource("flecheVerte-droite-20px.png")); public static ComponentUI createUI( JComponent x ) { return new MyTabbedPaneUI(); } @Override protected JButton createScrollButton(int direction) { if ((direction != SOUTH) &amp;&amp; (direction != NORTH) &amp;&amp; (direction != EAST) &amp;&amp; (direction != WEST)) { throw new IllegalArgumentException("Direction must be one of: " + "SOUTH, NORTH, EAST or WEST"); } JButton b = new JButton(); //b.setText(""); b.setPreferredSize(new Dimension(eastIcon.getIconWidth(), eastIcon.getIconHeight())); if (direction == SOUTH) { b.setIcon(southIcon); } else if (direction == NORTH) { b.setIcon(northIcon); } else if (direction == WEST) { b.setIcon(westIcon); } else { b.setIcon(eastIcon); } return b; } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload