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

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

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

JTabbedPane.getIconAt介绍

暂无

代码示例

代码示例来源:origin: com.github.arnabk/pgslookandfeel

public SelectTabAction(JTabbedPane tabPane, int index) {
  super(tabPane.getTitleAt(index), tabPane.getIconAt(index));
  this.tabPane = tabPane;
  this.index = index;
}

代码示例来源:origin: girtel/Net2Plan

@Override
  public void mouseClicked(MouseEvent e) {
    int tabNumber = reportContainer.getUI().tabForCoordinate(reportContainer, e.getX(), e.getY());
    if (tabNumber >= 0) {
      Rectangle rect = ((TabIcon) reportContainer.getIconAt(tabNumber)).getBounds();
      if (rect.contains(e.getX(), e.getY())) reportContainer.removeTabAt(tabNumber);
    }
  }
});

代码示例来源:origin: net.java.dev.laf-widget/laf-widget

public void offer(JTabbedPane tabPane, int tabIndex,
      BufferedImage componentSnap) {
    int width = componentSnap.getWidth() + 4;
    int height = componentSnap.getHeight() + 4;
    BufferedImage result = new BufferedImage(width, height,
        BufferedImage.TYPE_INT_ARGB);
    Graphics2D g2d = (Graphics2D) result.getGraphics();
    g2d.setColor(UIManager.getColor("Label.background"));
    g2d.fillRect(0, 0, width, height);
    g2d.setColor(UIManager.getColor("Label.foreground"));
    g2d.drawRect(0, 0, width - 1, height - 1);
    g2d.drawImage(componentSnap, 2, 2, null);
    Icon tabIcon = tabPane.getIconAt(tabIndex);
    if (tabIcon != null) {
      tabIcon.paintIcon(tabPane, g2d, 2, 2);
    }
    // Component caroselComponent = carosel.add(result, tabPane
    // .getTitleAt(tabIndex));
    // caroselComponent.setForeground(UIManager
    // .getColor("Label.foreground"));
    // System.err.println("Setting image on " + tabIndex);
    previewControls[tabIndex].setRichImage(result);
    // System.err.println("Set image on " + tabIndex);
    previewControls[tabIndex].repaint();
    // previewControls.add(caroselComponent);
    // TabRoundCarouselOverviewPanel.this.previewControls[tabIndex]
    // .setPreviewImage(componentSnap);
  }
};

代码示例来源:origin: net.java.dev.laf-widget/laf-widget

public void offer(JTabbedPane tabPane, int tabIndex,
      BufferedImage componentSnap) {
    int width = componentSnap.getWidth() + 4;
    int height = componentSnap.getHeight() + 4;
    BufferedImage result = new BufferedImage(width, height,
        BufferedImage.TYPE_INT_ARGB);
    Graphics2D g2d = (Graphics2D) result.getGraphics();
    g2d.setColor(UIManager.getColor("Label.background"));
    g2d.fillRect(0, 0, width, height);
    g2d.setColor(UIManager.getColor("Label.foreground"));
    g2d.drawRect(0, 0, width - 1, height - 1);
    g2d.drawImage(componentSnap, 2, 2, null);
    Icon tabIcon = tabPane.getIconAt(tabIndex);
    if (tabIcon != null) {
      tabIcon.paintIcon(tabPane, g2d, 2, 2);
    }
    // Component caroselComponent = carosel.add(result, tabPane
    // .getTitleAt(tabIndex));
    // caroselComponent.setForeground(UIManager
    // .getColor("Label.foreground"));
    // System.err.println("Setting image on " + tabIndex);
    previewControls[tabIndex].setRichImage(result);
    // System.err.println("Set image on " + tabIndex);
    previewControls[tabIndex].repaint();
    // previewControls.add(caroselComponent);
    // TabRoundCarouselOverviewPanel.this.previewControls[tabIndex]
    // .setPreviewImage(componentSnap);
  }
};

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/toniclf

protected Icon getIconForTab(int tabIndex)
{
  return (!tabPane.isEnabled() || !tabPane.isEnabledAt(tabIndex))
    ? tabPane.getDisabledIconAt(tabIndex)
    : tabPane.getIconAt(tabIndex);
}

代码示例来源:origin: com.jtattoo/JTattoo

protected Icon getIconForTab(int tabIndex) {
  if (tabIndex >= 0 && tabIndex < tabCount) {
    return (!tabPane.isEnabled() || !tabPane.isEnabledAt(tabIndex)) ? tabPane.getDisabledIconAt(tabIndex) : tabPane.getIconAt(tabIndex);
  }
  return null;
}

代码示例来源:origin: net.java.dev.swing-layout/swing-layout

private int getMaxTabHeight(JTabbedPane tp) {
  int fontHeight = tp.getFontMetrics(tp.getFont()).getHeight();
  int height = fontHeight;
  boolean tallerIcons = false;
  for (int counter = tp.getTabCount() - 1; counter >= 0; counter--) {
    Icon icon = tp.getIconAt(counter);
    if (icon != null) {
      int iconHeight = icon.getIconHeight();
      height = Math.max(height, iconHeight);
      if (iconHeight > fontHeight) {
        tallerIcons = true;
      }
    }
  }
  Insets tabInsets = UIManager.getInsets("TabbedPane.tabInsets");
  height += 2;
  /*
  if (!isMetal() || !tallerIcons) {
    height += tabInsets.top + tabInsets.bottom;
  }*/
  return height;
}

代码示例来源:origin: org.bidib.jbidib.com.vldocking/vldocking

Icon icon = tabbedPane.getIconAt(targetTab);
if(icon instanceof JTabbedPaneSmartIcon) {
  JTabbedPaneSmartIcon smartIcon = (JTabbedPaneSmartIcon) icon;

代码示例来源:origin: net.sf.taverna.t2.ui-impl/zaria

/**
 * Swap the tab at index i with that at index i+1
 */
private void swapTabs(int i) {
  Component c = tabs.getComponentAt(i);
  String text = tabs.getTitleAt(i);
  Icon icon = tabs.getIconAt(i);
  tabs.remove(i);
  tabs.add(c, text, i + 1);
  if (icon != null) {
    tabs.setIconAt(i + 1, icon);
  }
}

代码示例来源:origin: net.java.dev.swing-layout/swing-layout

private static int getMaxTabHeight(JTabbedPane tp) {
  int fontHeight = tp.getFontMetrics(tp.getFont()).getHeight();
  int height = fontHeight;
  boolean tallerIcons = false;
  for (int counter = tp.getTabCount() - 1; counter >= 0; counter--) {
    Icon icon = tp.getIconAt(counter);
    if (icon != null) {
      int iconHeight = icon.getIconHeight();
      height = Math.max(height, iconHeight);
      if (iconHeight > fontHeight) {
        tallerIcons = true;
      }
    }
  }
  Insets tabInsets = UIManager.getInsets("TabbedPane.tabInsets");
  height += 2;
  if (!isMetal() || !tallerIcons) {
    height += tabInsets.top + tabInsets.bottom;
  }
  return height;
}

代码示例来源:origin: com.github.arnabk/pgslookandfeel

public void mouseDragged(MouseEvent e) {
  if(draggedTabIndex == -1) {
    return;
  }
  int targetTabIndex = tabPane.getUI().tabForCoordinate(tabPane,
                             e.getX(), e.getY());
  if(targetTabIndex != -1 && targetTabIndex != draggedTabIndex) {
    boolean isForwardDrag = targetTabIndex > draggedTabIndex;
    tabPane.insertTab(tabPane.getTitleAt(draggedTabIndex),
             tabPane.getIconAt(draggedTabIndex),
             tabPane.getComponentAt(draggedTabIndex),
             tabPane.getToolTipTextAt(draggedTabIndex),
             isForwardDrag ? targetTabIndex+1 : targetTabIndex);
    draggedTabIndex = targetTabIndex;
    tabPane.setSelectedIndex(draggedTabIndex);
  }
}

代码示例来源:origin: girtel/Net2Plan

@Override
  public void mouseClicked(MouseEvent e) {
    int tabNumber = tabbedPane.getUI().tabForCoordinate(tabbedPane, e.getX(), e.getY());
    if (tabNumber >= 0) {
      if (tabNumber == tabbedPane.getTabCount() - 1) {
        addTrafficMatrix(DEFAULT_NUMBER_OF_NODES);
        tabbedPane.setSelectedIndex(tabbedPane.getTabCount() - 2);
      } else {
        Rectangle rect = ((TabIcon) tabbedPane.getIconAt(tabNumber)).getBounds();
        if (rect.contains(e.getX(), e.getY()) && tabbedPane.getTabCount() > 2) {
          trafficMatrices.remove(tabNumber);
          tabbedPane.removeTabAt(tabNumber);
        }
        if (tabNumber == tabbedPane.getTabCount() - 1) {
          tabbedPane.setSelectedIndex(tabbedPane.getTabCount() - 2);
        }
      }
    }
  }
});

代码示例来源:origin: net.java.dev.laf-widget/laf-widget

/**
 * Stes the tab index.
 * 
 * @param tabIndex
 *            Tab index.
 */
public void setTabIndex(int tabIndex) {
  this.iconLabel.setIcon(this.tabPane.getIconAt(tabIndex));
  this.titleLabel.setText(this.tabPane.getTitleAt(tabIndex));
  final boolean isSelected = (this.tabPane.getSelectedIndex() == tabIndex);
  Border innerBorder = isSelected ? new LineBorder(Color.black, 2)
      : new LineBorder(Color.black, 1);
  this
      .setBorder(new CompoundBorder(new ShadowPopupBorder(),
          innerBorder));
}

代码示例来源:origin: sc.fiji/TrakEM2_

int i_tab = tabs.getSelectedIndex();
Component comp = tabs.getComponentAt(i_tab);
Icon icon = tabs.getIconAt(i_tab);
if (icon instanceof CloseIcon) {
  CloseIcon ci = (CloseIcon)icon;

代码示例来源:origin: net.java.dev.laf-widget/laf-widget

this.tabPane = tabPane;
this.setLayout(new TabPreviewControlLayout());
this.iconLabel = new JLabel(tabPane.getIconAt(tabIndex));
this.titleLabel = new JLabel(tabPane.getTitleAt(tabIndex));
this.titleLabel

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

private void moveTab(int prev, int next) {
  if (next < 0 || prev == next) {
    return;
  }
  Component cmp = pane.getComponentAt(prev);
  Component tab = pane.getTabComponentAt(prev);
  String str = pane.getTitleAt(prev);
  Icon icon = pane.getIconAt(prev);
  String tip = pane.getToolTipTextAt(prev);
  boolean flg = pane.isEnabledAt(prev);
  int tgtindex = prev > next ? next : next - 1;
  pane.remove(prev);
  pane.insertTab(str, icon, cmp, tip, tgtindex);
  pane.setEnabledAt(tgtindex, flg);
  if (flg)
    pane.setSelectedIndex(tgtindex);
  pane.setTabComponentAt(tgtindex, tab);
}

代码示例来源:origin: net.sourceforge.mydoggy/mydoggy-plaf

Content content = contentMap.get(index);
  if (content == null)
    return super.getIconAt(index);
    return super.getIconAt(index);
  );
  tabIconTitle.setLeftIcon(super.getIconAt(index));
    );
    Icon icon = new AggregateIcon(new AggregateIcon(super.getIconAt(index),
                            textIcon,
                            SwingConstants.HORIZONTAL),
    return (Icon) o;
return super.getIconAt(index);

代码示例来源:origin: org.netbeans.modules/org-netbeans-lib-profiler-ui

firstView = tabs.getComponentAt(0);
firstName = tabs.getTitleAt(0);
firstIcon = tabs.getIconAt(0);
firstDescription = tabs.getToolTipTextAt(0);
remove(tabs);

代码示例来源:origin: realXuJiang/bigtable-sql

private void convertTab(int prev, int next)
{
 if (next < 0 || prev == next)
 {
   return;
 }
 Component cmp = _dnDTabbedPaneData.getTabbedPane().getComponentAt(prev);
 Component tab = _dnDTabbedPaneData.getTabbedPane().getTabComponentAt(prev);
 String str = _dnDTabbedPaneData.getTabbedPane().getTitleAt(prev);
 Icon icon = _dnDTabbedPaneData.getTabbedPane().getIconAt(prev);
 String tip = _dnDTabbedPaneData.getTabbedPane().getToolTipTextAt(prev);
 boolean flg = _dnDTabbedPaneData.getTabbedPane().isEnabledAt(prev);
 int tgtindex = prev > next ? next : next - 1;
 _dnDTabbedPaneData.getTabbedPane().remove(prev);
 _dnDTabbedPaneData.getTabbedPane().insertTab(str, icon, cmp, tip, tgtindex);
 _dnDTabbedPaneData.getTabbedPane().setEnabledAt(tgtindex, flg);
 //When you drag'n'drop a disabled tab, it finishes enabled and selected.
 //pointed out by dlorde
 if (flg) _dnDTabbedPaneData.getTabbedPane().setSelectedIndex(tgtindex);
 //I have a component in all tabs (jlabel with an X to close the tab) and when i move a tab the component disappear.
 //pointed out by Daniel Dario Morales Salas
 _dnDTabbedPaneData.getTabbedPane().setTabComponentAt(tgtindex, tab);
}

代码示例来源:origin: net.sf.squirrel-sql/squirrel-sql

private void convertTab(int prev, int next)
{
 if (next < 0 || prev == next)
 {
   return;
 }
 Component cmp = _dnDTabbedPaneData.getTabbedPane().getComponentAt(prev);
 Component tab = _dnDTabbedPaneData.getTabbedPane().getTabComponentAt(prev);
 String str = _dnDTabbedPaneData.getTabbedPane().getTitleAt(prev);
 Icon icon = _dnDTabbedPaneData.getTabbedPane().getIconAt(prev);
 String tip = _dnDTabbedPaneData.getTabbedPane().getToolTipTextAt(prev);
 boolean flg = _dnDTabbedPaneData.getTabbedPane().isEnabledAt(prev);
 int tgtindex = prev > next ? next : next - 1;
 _dnDTabbedPaneData.getTabbedPane().remove(prev);
 _dnDTabbedPaneData.getTabbedPane().insertTab(str, icon, cmp, tip, tgtindex);
 _dnDTabbedPaneData.getTabbedPane().setEnabledAt(tgtindex, flg);
 //When you drag'n'drop a disabled tab, it finishes enabled and selected.
 //pointed out by dlorde
 if (flg) _dnDTabbedPaneData.getTabbedPane().setSelectedIndex(tgtindex);
 //I have a component in all tabs (jlabel with an X to close the tab) and when i move a tab the component disappear.
 //pointed out by Daniel Dario Morales Salas
 _dnDTabbedPaneData.getTabbedPane().setTabComponentAt(tgtindex, tab);
}

相关文章

JTabbedPane类方法