List of usage examples for javax.swing JTabbedPane getTabCount
@BeanProperty(bound = false) public int getTabCount()
tabbedpane
. From source file:Main.java
public static void main(String[] argv) throws Exception { JTabbedPane pane = new JTabbedPane(); int count = pane.getTabCount(); for (int i = 0; i < count; i++) { String label = pane.getTitleAt(i); Icon icon = pane.getIconAt(i); String tooltip = pane.getToolTipTextAt(i); boolean enabled = pane.isEnabledAt(i); int keycode = pane.getMnemonicAt(i); Component comp = pane.getComponentAt(i); }// ww w. j a v a 2s. c o m }
From source file:Main.java
public static void main(String[] argv) throws Exception { JTabbedPane pane = new JTabbedPane(); int src = pane.getTabCount() - 1; int dst = 0;// w w w . j ava2s . c o m Component comp = pane.getComponentAt(src); String label = pane.getTitleAt(src); Icon icon = pane.getIconAt(src); Icon iconDis = pane.getDisabledIconAt(src); String tooltip = pane.getToolTipTextAt(src); boolean enabled = pane.isEnabledAt(src); int keycode = pane.getMnemonicAt(src); int mnemonicLoc = pane.getDisplayedMnemonicIndexAt(src); Color fg = pane.getForegroundAt(src); Color bg = pane.getBackgroundAt(src); pane.remove(src); pane.insertTab(label, icon, comp, tooltip, dst); pane.setDisabledIconAt(dst, iconDis); pane.setEnabledAt(dst, enabled); pane.setMnemonicAt(dst, keycode); pane.setDisplayedMnemonicIndexAt(dst, mnemonicLoc); pane.setForegroundAt(dst, fg); pane.setBackgroundAt(dst, bg); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JTabbedPane pane = new JTabbedPane(); pane.addTab("Tab Label", new JButton("button")); int index = pane.getTabCount() - 1; int keycode = KeyEvent.VK_L; pane.setMnemonicAt(index, keycode);// w w w .j a v a2 s. c o m }
From source file:Main.java
public static void main(String[] argv) throws Exception { JTabbedPane pane = new JTabbedPane(); JButton component = new JButton("button"); // Remove the last tab pane.remove(pane.getTabCount() - 1); // Remove the tab with the specified child component pane.remove(component);/* w ww . j ava2 s . co m*/ // Remove all the tabs pane.removeAll(); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JTabbedPane pane = new JTabbedPane(); pane.addTab("Tab Label", new JButton("Button")); // Get index of the new tab int index = pane.getTabCount() - 1; // Determine whether the tab is enabled boolean enabled = pane.isEnabledAt(index); // Disable the tab pane.setEnabledAt(index, false);// w ww . j ava 2s.c om }
From source file:Main.java
public static void main(String[] argv) throws Exception { JTabbedPane pane = new JTabbedPane(); // Get the index of the currently selected tab int selIndex = pane.getSelectedIndex(); // Select the last tab selIndex = pane.getTabCount() - 1; pane.setSelectedIndex(selIndex);//from w w w . j av a 2 s. com }
From source file:Main.java
public static void main(String[] argv) throws Exception { JTabbedPane pane = new JTabbedPane(); String label = "Tab Label"; String tooltip = "Tool Tip Text"; pane.addTab(label, null, new JButton("Button"), tooltip); int index = pane.getTabCount() - 1; tooltip = pane.getToolTipTextAt(index); tooltip = "New Tool Tip Text"; pane.setToolTipTextAt(index, tooltip); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JTabbedPane pane = new JTabbedPane(); pane.setForeground(Color.YELLOW); pane.setBackground(Color.MAGENTA); String label = "Tab Label"; pane.addTab(label, new JButton("Button")); int index = pane.getTabCount() - 1; pane.setForegroundAt(index, Color.ORANGE); pane.setBackgroundAt(index, Color.GREEN); }
From source file:Main.java
public static final void main(String[] args) { JFrame frame = new JFrame(); JTabbedPane tabbedPane = new JTabbedPane(); frame.add(tabbedPane);/*ww w . j av a 2 s . c o m*/ JButton addButton = new JButton("Add tab"); addButton.addActionListener(e -> { JPanel newTabComponent = new JPanel(); int tabCount = tabbedPane.getTabCount(); newTabComponent.add(new JLabel("I'm tab " + tabCount)); tabbedPane.addTab("Tab " + tabCount, newTabComponent); }); frame.add(addButton, BorderLayout.SOUTH); addButton.doClick(); frame.setSize(800, 300); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { final JTabbedPane jTabbedPane = new JTabbedPane(); jTabbedPane.addTab("Red", new JLabel("Roses")); jTabbedPane.addTab("Blue", new JLabel("Skies")); jTabbedPane.addTab("Green", new JLabel("Grass")); for (int i = 0; i < jTabbedPane.getTabCount(); i++) { final JLabel tabComponent = new JLabel(jTabbedPane.getTitleAt(i)); tabComponent.addMouseMotionListener(new MouseMotionAdapter() { @Override//ww w. java2 s . c o m public void mouseDragged(MouseEvent e) { System.out.println("tabComponent dragging"); } }); tabComponent.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { int x = tabComponent.getLocationOnScreen().x - jTabbedPane.getLocationOnScreen().x; int y = tabComponent.getLocationOnScreen().y - jTabbedPane.getLocationOnScreen().y; MouseEvent me = new MouseEvent((JLabel) e.getSource(), e.getID(), e.getWhen(), e.getModifiers(), x, y, e.getLocationOnScreen().x, e.getLocationOnScreen().y, e.getClickCount(), e.isPopupTrigger(), e.getButton()); jTabbedPane.getMouseListeners()[0].mousePressed(me); System.out.println("tabComponent mousePressed e=" + e); } }); jTabbedPane.setTabComponentAt(i, tabComponent); } JFrame jFrame = new JFrame(); jFrame.add(jTabbedPane); jFrame.setSize(400, 500); jFrame.setVisible(true); jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }