javax.swing.JTabbedPane.setTabComponentAt()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(8.8k)|赞(0)|评价(0)|浏览(143)

本文整理了Java中javax.swing.JTabbedPane.setTabComponentAt()方法的一些代码示例,展示了JTabbedPane.setTabComponentAt()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTabbedPane.setTabComponentAt()方法的具体详情如下:
包路径:javax.swing.JTabbedPane
类名称:JTabbedPane
方法名:setTabComponentAt

JTabbedPane.setTabComponentAt介绍

暂无

代码示例

代码示例来源:origin: deathmarine/Luyten

@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);
    }
  }
});

代码示例来源:origin: stackoverflow.com

// 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);

代码示例来源:origin: stackoverflow.com

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);
}

代码示例来源:origin: magefree/mage

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);
}

代码示例来源:origin: ron190/jsql-injection

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());
  }
}

代码示例来源:origin: ron190/jsql-injection

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(

代码示例来源:origin: JetBrains/jediterm

@Override
public void setTabComponentAt(int index, Component component) {
 myTabbedPane.setTabComponentAt(index, component);
}

代码示例来源:origin: triplea-game/triplea

@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++;
 }
}

代码示例来源:origin: stackoverflow.com

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

代码示例来源:origin: stackoverflow.com

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

代码示例来源:origin: senbox-org/snap-desktop

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);
}

代码示例来源:origin: net.sourceforge.ondex.apps/ovtk2

/**
 * Set close button to given tab.
 * 
 * @param i
 *            number of tab
 */
private void initTabComponent(int i) {
  tabbedPane.setTabComponentAt(i, new ButtonTabComponent(tabbedPane));
}

代码示例来源:origin: senbox-org/snap-desktop

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);
}

代码示例来源:origin: lbalazscs/Pixelitor

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);
}

代码示例来源:origin: stackoverflow.com

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);

代码示例来源:origin: org.nuiton.jaxx/jaxx-swing-action

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);
  }
}

代码示例来源:origin: otros-systems/otroslogviewer

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);
 }
}

代码示例来源:origin: igniterealtime/Spark

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;
}

代码示例来源:origin: org.wildfly.core/wildfly-cli

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);
}

代码示例来源:origin: icza/scelight

@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 );
}

相关文章

JTabbedPane类方法