Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I don't recall seeing such a problem in the <a href="http://java.sun.com/docs/books/tutorial/uiswing/examples/components/index.html#TabComponentsDemo" rel="nofollow noreferrer"><code>TabComponentsDemo</code></a>, discussed in <a href="http://java.sun.com/docs/books/tutorial/uiswing/components/tabbedpane.html" rel="nofollow noreferrer"><em>How to Use Tabbed Panes</em></a>. You might compare your code with that example as a reference.</p> <p>Addendum: Re-factoring <a href="http://download.oracle.com/docs/cd/E17409_01/javase/tutorial/uiswing/examples/components/TabComponentsDemoProject/src/components/ButtonTabComponent.java" rel="nofollow noreferrer"><code>ButtonTabComponent</code></a> to include <code>getLabel()</code>, this version of <code>runTest()</code> in <a href="http://download.oracle.com/docs/cd/E17409_01/javase/tutorial/uiswing/examples/components/TabComponentsDemoProject/src/components/TabComponentsDemo.java" rel="nofollow noreferrer"><code>TabComponentsDemo</code></a> adds a button that evinces the desired behavior. In particular, each time the button is pressed, the tabs are redrawn to display the enlarged title.</p> <p>Update: Modify correct tab component after <code>pane.remove()</code>.</p> <pre><code>public void runTest() { pane.removeAll(); for (int i = 0; i &lt; tabNumber; i++) { final int titleIndex = i; String title = "Tab " + titleIndex; final JButton button = new JButton("Relabel tab"); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int index = pane.indexOfComponent(button); ButtonTabComponent btc = (ButtonTabComponent) pane.getTabComponentAt(index); JLabel label = btc.getLabel(); pane.setTitleAt(index, label.getText() + titleIndex); label.invalidate(); pane.repaint(); } }); pane.add(title, button); initTabComponent(i); } tabComponentsItem.setSelected(true); pane.setTabLayoutPolicy(JTabbedPane.WRAP_TAB_LAYOUT); scrollLayoutItem.setSelected(false); this.setPreferredSize(new Dimension(500, 200)); this.pack(); this.setLocationRelativeTo(null); this.setVisible(true); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

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