当前位置: 首页>>代码示例>>Java>>正文


Java JTabbedPane.indexOfTabComponent方法代码示例

本文整理汇总了Java中javax.swing.JTabbedPane.indexOfTabComponent方法的典型用法代码示例。如果您正苦于以下问题:Java JTabbedPane.indexOfTabComponent方法的具体用法?Java JTabbedPane.indexOfTabComponent怎么用?Java JTabbedPane.indexOfTabComponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JTabbedPane的用法示例。


在下文中一共展示了JTabbedPane.indexOfTabComponent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: TabComponent

import javax.swing.JTabbedPane; //导入方法依赖的package包/类
/**
 * Constructor for TabComponent class.
 * 
 * @param pane
 *            {@link JTabbedPane} parent component.
 * @param observer
 *            Main JNotepadPP frame.
 * @param lp
 *            Localization provider.
 */
public TabComponent(JTabbedPane pane, JNotepadPP observer,
        ILocalizationProvider lp) {

    super(new FlowLayout(FlowLayout.LEFT, 0, 0));
    this.lp = lp;
    this.observer = observer;
    setOpaque(false);

    JLabel label = new JLabel() {
        private static final long serialVersionUID = 1L;

        public String getText() {
            int i = pane.indexOfTabComponent(TabComponent.this);
            if (i != -1) {
                this.revalidate();
                return pane.getTitleAt(i);

            }
            return "";
        }
    };

    ImageIcon image = new ImageIcon(this.getClass().getResource(
            "res/green.png"));
    picLabel = new JLabel(image);
    add(picLabel);
    add(label);

    picLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));
    label.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));
    closeButton = new CloseTabButton(this);
    add(closeButton);

    setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0));
}
 
开发者ID:fgulan,项目名称:java-course,代码行数:46,代码来源:TabComponent.java

示例2: actionPerformed

import javax.swing.JTabbedPane; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void actionPerformed(ActionEvent e) {
    JTabbedPane pane = observer.getTabs();
    int i = pane.indexOfTabComponent(tab);
    JNotepadPPDocument editor = observer.getEditors().get(i);

    List<JNotepadPPDocument> editors = observer.getEditors();

    if (pane.getComponentCount() == 4) {
        return;
    }
    if (editor.isChanged()) {
        int answer = JOptionPane.showConfirmDialog(observer,
                lp.getString("saveMessage"), lp.getString("saveDialog"),
                JOptionPane.YES_NO_CANCEL_OPTION);

        if (answer == JOptionPane.YES_OPTION) {
            editor.saveDocument(false);
        } else if (answer == JOptionPane.CANCEL_OPTION) {
            return;
        }
    }

    pane.remove(i);
    editors.remove(i);
    int size = editors.size();

    if (i >= size) {
        observer.setActiveEditor(editors.get(size - 1));
        pane.setSelectedIndex(size - 1);
    } else {
        observer.setActiveEditor(editors.get(i));
        pane.setSelectedIndex(i);
    }
    observer.getActiveEditor().updateStatusBar();
}
 
开发者ID:fgulan,项目名称:java-course,代码行数:40,代码来源:TabButtonAction.java

示例3: ButtonTabComponent

import javax.swing.JTabbedPane; //导入方法依赖的package包/类
public ButtonTabComponent(final JTabbedPane pane) {
    //unset default FlowLayout' gaps
    super(new FlowLayout(FlowLayout.LEFT, 0, 0));
    if (pane == null) {
        throw new NullPointerException("TabbedPane is null");
    }
    this.pane = pane;
    setOpaque(false);
    
    //make JLabel read titles from JTabbedPane
    JLabel label = new JLabel() {
        public String getText() {
            int i = pane.indexOfTabComponent(ButtonTabComponent.this);
            if (i != -1) {
                return pane.getTitleAt(i);
            }
            return null;
        }
    };
    
    add(label);
    //add more space between the label and the button
    label.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));
    //tab button
    JButton button = new TabButton();
    add(button);
    //add more space to the top of the component
    setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0));
}
 
开发者ID:BlidiWajdi,项目名称:Mujeed-Arabic-Prolog,代码行数:30,代码来源:ButtonTabComponent.java


注:本文中的javax.swing.JTabbedPane.indexOfTabComponent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。