@Override public void run() { try { final String title = open.name; RTextScrollPane rTextScrollPane = open.scrollPane; if (house.indexOfTab(title) < 0) { house.addTab(title, rTextScrollPane); house.setSelectedIndex(house.indexOfTab(title)); int index = house.indexOfTab(title); Tab ct = new Tab(title); ct.getButton().addMouseListener(new CloseTab(title)); house.setTabComponentAt(index, ct); } else { house.setSelectedIndex(house.indexOfTab(title)); } open.onAddedToScreen(); } catch (Exception e) { Luyten.showExceptionDialog("Exception!", e); } } });
// Create tabbed pane and add tabs. JTabbedPane tabbedPane = ... // Create bespoke component for rendering the tab. JLabel lbl = new JLabel("Hello, World"); Icon icon = new ImageIcon(getClass().getResource("/foo/bar/hello.jpg")); lbl.setIcon(icon); // Add some spacing between text and icon, and position text to the RHS. lbl.setIconTextGap(5); lbl.setHorizontalTextPosition(SwingConstants.RIGHT); // Assign bespoke tab component for first tab. tabbedPane.setTabComponentAt(0, lbl);
private void addTab(JTabbedPane tabbedPane, Component tab, String title, Icon icon) { tabbedPane.add(tab); JLabel lbl = ... // Create bespoke label for rendering tab title. tabbedPane.setTabComponentAt(tabbedPane.getTabCount() - 1, lbl); }
private void setTabTitle(int tabIndex, String title, String iconResourceName) { // tab caption with left sided icon // https://stackoverflow.com/questions/1782224/jtabbedpane-icon-on-left-side-of-tabs JLabel lbl = new JLabel(title); Icon icon = new ImageIcon(getClass().getResource(iconResourceName)); lbl.setIcon(icon); lbl.setIconTextGap(5); lbl.setHorizontalTextPosition(SwingConstants.RIGHT); tabsList.setTabComponentAt(tabIndex, lbl); }
public void exportTab(int dragIndex, JTabbedPane target, int targetIndex) { Component cmp = this.getComponentAt(dragIndex); Component tab = this.getTabComponentAt(dragIndex); String title = this.getTitleAt(dragIndex); Icon icon = this.getIconAt(dragIndex); String tip = this.getToolTipTextAt(dragIndex); boolean isEnabled = this.isEnabledAt(dragIndex); this.remove(dragIndex); target.insertTab(title, icon, cmp, tip, targetIndex); target.setEnabledAt(targetIndex, isEnabled); target.setTabComponentAt(targetIndex, tab); target.setSelectedIndex(targetIndex); if (tab instanceof JComponent) { ((JComponent) tab).scrollRectToVisible(tab.getBounds()); } }
tabsSchema.setTabComponentAt( tabsSchema.indexOfTab(I18n.valueByKey("SQLENGINE_DATABASES")), labelDatabase tabsSchema.setTabComponentAt( tabsSchema.indexOfTab(I18n.valueByKey("SQLENGINE_TABLES")), labelTable tabsSchema.setTabComponentAt( tabsSchema.indexOfTab(I18n.valueByKey("SQLENGINE_COLUMNS")), labelColumn tabsSchema.setTabComponentAt( tabsSchema.indexOfTab(I18n.valueByKey("SQLENGINE_ROWS")), labelRow tabsSchema.setTabComponentAt( tabsSchema.indexOfTab(I18n.valueByKey("SQLENGINE_FIELD")), labelField tabsSchema.setTabComponentAt( tabsSchema.indexOfTab(I18n.valueByKey("SQLENGINE_FIELDS_SEPARATOR")), labelFieldSeparator tabsSchema.setTabComponentAt( tabsSchema.indexOfTab(I18n.valueByKey("SQLENGINE_METADATA")), labelMetadata tabsStandard.setTabComponentAt(
@Override public void setTabComponentAt(int index, Component component) { myTabbedPane.setTabComponentAt(index, component); }
@Override public void addTab(final String tab, final Component contents) { super.addTab(tab, contents); final JLabel sizedLabel = new JLabel(tab); sizedLabel.setPreferredSize(tabDimension); super.setTabComponentAt(tabIndex, sizedLabel); tabIndex++; } }
JTabbedPane tabPane = new JTabbedPane(JTabbedPane.LEFT); // Add tabs with no text tabPane.addTab(null, component1); tabPane.addTab(null, component2); // Create vertical labels to render tab titles JLabel labTab1 = new JLabel("Tab #1"); labTab1.setUI(new VerticalLabelUI(false)); // true/false to make it upwards/downwards tabPane.setTabComponentAt(0, labTab1); // For component1 JLabel labTab2 = new JLabel("Tab #2"); labTab2.setUI(new VerticalLabelUI(false)); tabPane.setTabComponentAt(1, labTab2); // For component2
JLabel label = new JLabel("Tab1"); label.setHorizontalTextPosition(JLabel.TRAILING); // Set the text position regarding its icon label.setIcon(UIManager.getIcon("OptionPane.informationIcon")); JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.LEFT); tabbedPane.addTab(null, new JPanel()); tabbedPane.setTabComponentAt(0, label); // Here set the custom tab component
private void addTab(String text, JPanel contents) { JLabel tabText = new JLabel(text, JLabel.LEFT); Border titledBorder = BorderFactory.createEmptyBorder(); contents.setBorder(titledBorder); this.bundleTabPane.addTab(null, contents); this.bundleTabPane.setTabComponentAt(this.bundleTabPane.getTabCount() - 1, tabText); }
/** * Set close button to given tab. * * @param i * number of tab */ private void initTabComponent(int i) { tabbedPane.setTabComponentAt(i, new ButtonTabComponent(tabbedPane)); }
private void addTab(JTabbedPane tabControl, String title, JPanel content) { JLabel tabText = new JLabel(title, JLabel.LEFT); tabText.setPreferredSize(new Dimension(6 * controlHeight, controlHeight)); TitledBorder titledBorder = BorderFactory.createTitledBorder(title); titledBorder.setTitleJustification(TitledBorder.CENTER); content.setBorder(titledBorder); tabControl.addTab(null, content); tabControl.setTabComponentAt(tabControl.getTabCount() - 1, tabText); }
private void addTab(String name, EffectPanel configurator) { JPanel tabPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); JCheckBox tabSelectionCB = new JCheckBox(); tabSelectionCB.setModel(configurator.getEnabledModel()); tabPanel.add(tabSelectionCB); tabPanel.add(new JLabel(name)); tabPanel.setOpaque(false); tabs.addTab(name, configurator); tabs.setTabComponentAt(tabs.getTabCount() - 1, tabPanel); }
public static void addTag(JTabbedPane tab, String title, Icon icon, int index){ MouseListener close = new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { //your code to remove component //I use this way , because I use other methods of control than normal: tab.remove(int index); } }; final ButtonClose buttonClose = new ButtonClose (title, icon, close ); tab.setTabComponentAt(index, buttonClose); tab.validate(); tab.setSelectedIndex(index);
protected void registerTab(final JTabbedPane container, final String tabName, final TabContentConfig config, final JAXXTab comp) { container.addTab(tabName, comp); JComponent header = addTabHeader(container, tabName, config, comp); if (header != null) { container.setTabComponentAt(container.getTabCount() - 1, header); } }
public void addClosableTab(String name, String tooltip, Icon icon, JComponent component, boolean show) { JTabbedPane tabbedPane = getJTabbedPane(); if (tabbedPane.indexOfComponent(component) == -1) { int tabCount = tabbedPane.getTabCount(); tabbedPane.addTab(name, icon, component); tabbedPane.setTabComponentAt(tabCount, new TabHeader(tabbedPane, name, icon, tooltip)); tabbedPane.setSelectedIndex(tabCount); } if (show) { tabbedPane.setSelectedComponent(component); } }
public SparkTab addTab(String title, Icon icon, final Component component, String tip) { final SparkTab sparktab = new SparkTab(this, component); TabPanel tabpanel = new TabPanel(sparktab, title, icon); pane.addTab(null, null, sparktab, tip); pane.setTabComponentAt(pane.getTabCount() - 1, tabpanel); fireTabAdded(sparktab, component, getTabPosition(sparktab)); return sparktab; }
public void actionPerformed(ActionEvent ae) { JTabbedPane tabs = cliGuiCtx.getTabs(); int newTabIndex = tabs.getSelectedIndex() + 1; ManagementModelNode newRoot = node.clone(); tabs.insertTab(calcTabName(this.node), null, new ManagementModel(newRoot, cliGuiCtx), newRoot.addressPath(), newTabIndex); tabs.setTabComponentAt(newTabIndex, new ButtonTabComponent(tabs)); tabs.setSelectedIndex(newTabIndex); }
@Override public void unhideTab( final int hiddenIdx, final int toIdx ) { // Adding a component to a container first removes it from its current parent. // To avoid complications, first store references, remove, then add to the new parent. final Component titleComp = titlesPark.getComponent( hiddenIdx ); final Component contentComp = contentsPark.getComponent( hiddenIdx ); titlesPark.remove( hiddenIdx ); contentsPark.remove( hiddenIdx ); wrappedTabbedPane.insertTab( null, null, contentComp, null, toIdx ); wrappedTabbedPane.setTabComponentAt( toIdx, titleComp ); }