JTabbedPane pane = ...; følgende kode skulle vælge den næste tab, eller den første hvis ingen var valgt i forvejen. Hvis den sidste tab var valgt, vælges den første. int tabs = pane.getTabCount(); int index = pane.getSelectedIndex(); if ( index == -1 ) index = tabs - 1; // vælge sidste tab index = ( index + 1 ) % count; // ryk til "næste" tab pane.setSelectedIndex( index ); // vælg tab
public void windowOpened(WindowEvent e){} public void windowClosing(WindowEvent e){ dispose(); System.exit(0);} public void windowClosed(WindowEvent e){} public void windowIconified(WindowEvent e){} public void windowDeiconified(WindowEvent e){} public void windowActivated(WindowEvent e){} public void windowDeactivated(WindowEvent e){}
public void actionPerformed(ActionEvent e) { int temp = tabPane.getSelectedIndex(); temp++; if(temp >= tabPane.getTabCount()) tabPane.setSelectedIndex(0); else tabPane.setSelectedIndex(temp); } }
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.