當前位置: 首頁>>代碼示例>>Java>>正文


Java JTabbedPane類代碼示例

本文整理匯總了Java中javax.swing.JTabbedPane的典型用法代碼示例。如果您正苦於以下問題:Java JTabbedPane類的具體用法?Java JTabbedPane怎麽用?Java JTabbedPane使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


JTabbedPane類屬於javax.swing包,在下文中一共展示了JTabbedPane類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: main

import javax.swing.JTabbedPane; //導入依賴的package包/類
public static void main(String[] args) throws Exception {

        Robot robot = new Robot();
        SwingUtilities.invokeAndWait(() -> {
            frame = new JFrame();
            frame.setSize(500, 500);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

            tabbedPane = new JTabbedPane();

            for (int i = 0; i < TAB_COUNT; i++) {
                tabbedPane.add("Header " + i, new JLabel("Content: " + i));
            }

            frame.getContentPane().setLayout(new BorderLayout());
            frame.getContentPane().add(tabbedPane, BorderLayout.CENTER);
            frame.setVisible(true);
        });

        robot.waitForIdle();

        SwingUtilities.invokeAndWait(() -> {
            for (int j = 0; j < ITERATIONS; j++) {
                for (int i = 0; i < TAB_COUNT; i++) {
                    tabbedPane.setTitleAt(i, getHtmlText(j * TAB_COUNT + i));
                }
            }
        });
        robot.waitForIdle();

        SwingUtilities.invokeAndWait(() -> frame.dispose());
    }
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:33,代碼來源:bug8017284.java

示例2: closeAllButCurrent

import javax.swing.JTabbedPane; //導入依賴的package包/類
void closeAllButCurrent() {
    Component comp = getComponent(0);
    if (comp instanceof JTabbedPane) {
        JTabbedPane tabs = (JTabbedPane) comp;
        Component current = tabs.getSelectedComponent();
        int tabCount = tabs.getTabCount();
        // #172039: do not use tabs.getComponents()
        Component[] c = new Component[tabCount - 1];
        for (int i = 0, j = 0; i < tabCount; i++) {
            Component tab = tabs.getComponentAt(i);
            if (tab != current) {
                c[j++] = tab;
            }
        }
        for (int i = 0; i < c.length; i++) {
            ((RefactoringPanel) c[i]).close();
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:20,代碼來源:RefactoringPanelContainer.java

示例3: componentClosed

import javax.swing.JTabbedPane; //導入依賴的package包/類
@Override
protected void componentClosed() {
    isVisible = false;
    if (getComponentCount() == 0) {
        return ;
    }
    Component comp = getComponent(0);
    if (comp instanceof JTabbedPane) {
        JTabbedPane pane = (JTabbedPane) comp;
        // #172039: do not use tabs.getComponents()
        Component[] c = new Component[pane.getTabCount()];
        for (int i = 0; i < c.length; i++) {
            c[i] = pane.getComponentAt(i);
        }
        for (int i = 0; i < c.length; i++) {
            ((RefactoringPanel) c[i]).close();
        }
    } else if (comp instanceof RefactoringPanel) {
        ((RefactoringPanel) comp).close();
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:22,代碼來源:RefactoringPanelContainer.java

示例4: stateChanged

import javax.swing.JTabbedPane; //導入依賴的package包/類
/**
 * {@link ChangeEvent} of the {@link #tabbedPane} (Menu: Single Player /
 * Duel / Tournament / About)
 */
@Override
public void stateChanged(ChangeEvent e) {
	if (e.getSource() instanceof JTabbedPane) {
		if (tabbedPane.getSelectedIndex() == 4) {
			if (buttonStart != null) {
				buttonStart.setEnabled(false);
			}
			if (runInBackgroundCheckbox != null) {
				runInBackgroundCheckbox.setEnabled(false);
			}
		} else {
			if (buttonStart != null) {
				buttonStart.setEnabled(true);
			}
			if (runInBackgroundCheckbox != null) {
				runInBackgroundCheckbox.setEnabled(true);
			}
		}
	}

}
 
開發者ID:gamefest2017,項目名稱:ants,代碼行數:26,代碼來源:MenuListener.java

示例5: HookPanel

import javax.swing.JTabbedPane; //導入依賴的package包/類
public HookPanel(VCSCommitPanel master, Collection<? extends VCSHook> hooks, VCSHookContext hookContext) {            
    super(master, (hooks.size() == 1)
            ? hooks.iterator().next().getDisplayName()
            : getMessage("LBL_Advanced"), //NOI18N
            DEFAULT_DISPLAY_HOOKS);
    this.hooks = hooks;
    this.hookContext = hookContext;
    
    // need this to happen in addNotify() - depends on how 
    // repositoryComboSupport in hook.createComponents works for bugzilla|jira
    if (hooks.size() == 1) {                
        JPanel p = hooks.iterator().next().createComponent(hookContext);
        if (Boolean.TRUE.equals(p.getClientProperty("prop.requestOpened"))) { //NOI18N - some hook panels may want to be opened (hg queue hook with previously configured setts)
            super.displaySection();
        }
        sectionPanel.add(p);
    } else {
        JTabbedPane hooksTabbedPane = new JTabbedPane();
        for (VCSHook hook : hooks) {
            hooksTabbedPane.add(hook.createComponent(hookContext), hook.getDisplayName().replaceAll("\\&", ""));
        }
        sectionPanel.add(hooksTabbedPane);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:25,代碼來源:CollapsiblePanel.java

示例6: initSidePane

import javax.swing.JTabbedPane; //導入依賴的package包/類
private void initSidePane() {
	sidePane = new JTabbedPane(JTabbedPane.TOP);
	centerPane.setLeftComponent(sidePane);
	sidePane.setMinimumSize(new Dimension(180, 0));

	projectPanel = new JPanel();
	sidePane.addTab("Project", null, projectPanel, null);
	projectPanel.setLayout(new BorderLayout(0, 0));

	projectScrollPane = new JScrollPane();
	projectPanel.add(projectScrollPane, BorderLayout.CENTER);

	repositoryPanel = new JPanel();
	sidePane.addTab("Repository", null, repositoryPanel, null);
	repositoryPanel.setLayout(new BorderLayout(0, 0));

	repositoryScrollPane = new JScrollPane();
	repositoryPanel.add(repositoryScrollPane, BorderLayout.CENTER);
}
 
開發者ID:roscisz,項目名稱:KernelHive,代碼行數:20,代碼來源:MainFrame.java

示例7: tabbedPaneFactory

import javax.swing.JTabbedPane; //導入依賴的package包/類
/**
 * Creates new {@link JTabbedPane} with {@link ChangeListener}.
 */
private void tabbedPaneFactory() {
    tabs = new JTabbedPane();
    tabs.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
    tabs.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            int index = tabs.getSelectedIndex();
            activeEditor = editors.get(index);
            if (editors.size() > 1) {
                activeEditor.updateStatusBar();
            }
            updateFrameTitle();
        }

    });
}
 
開發者ID:fgulan,項目名稱:java-course,代碼行數:21,代碼來源:JNotepadPP.java

示例8: initialize

import javax.swing.JTabbedPane; //導入依賴的package包/類
/**
 * Initialize the contents of the frame.
 */
private void initialize() {
	frame = new JFrame();
	frame.setBounds(100, 100, 450, 300);
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	frame.getContentPane().setLayout(new GridLayout(1, 0, 0, 0));

	JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
	frame.getContentPane().add(tabbedPane);

	JScrollPane scrollPane = new JScrollPane();
	tabbedPane.addTab("New tab", null, scrollPane, null);

	JScrollPane scrollPane_1 = new JScrollPane();
	tabbedPane.addTab("New tab", null, scrollPane_1, null);
}
 
開發者ID:FlyArts,項目名稱:NovelJ,代碼行數:19,代碼來源:SettingsWindow_Windows.java

示例9: testTextualDiffContent

import javax.swing.JTabbedPane; //導入依賴的package包/類
public void testTextualDiffContent () throws Exception {
    File diffFile = new File(getDataDir(), "enhancedview/diff");
    String goldenText = getFileContents(diffFile);
    goldenText = MessageFormat.format(goldenText, new Object[] {"a/", "b/"});

    final JTabbedPane tabbedPane = findTabbedPane(enhanced.getJComponent());
    JPanel p = (JPanel) tabbedPane.getComponentAt(1);
    tabbedPane.setSelectedIndex(1);
    JEditorPane pane = findEditorPane(p);
    assertFalse(pane == null);
    String text = pane.getText();
    for (int i = 0; i < 100; ++i) {
        if (!text.isEmpty()) {
            break;
        }
        Thread.sleep(100);
        text = pane.getText();
    }
    assertEquals(goldenText, text);
    EventQueue.invokeAndWait(new Runnable() {
        @Override
        public void run () {
            tabbedPane.setSelectedIndex(0);
        }
    });
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:27,代碼來源:DefaultDiffControllerProviderTest.java

示例10: tpTabsStateChanged

import javax.swing.JTabbedPane; //導入依賴的package包/類
private void tpTabsStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_tpTabsStateChanged
    Component component = ((JTabbedPane) evt.getSource ()).getSelectedComponent ();
    if (component instanceof SettingsTab) {
        int i = ((SettingsTab)component).getSelectedRow();
        ((SettingsTab)component).getSettingsTableModel ().refreshModel ();
        if (i > -1) {
            ((SettingsTab)component).setSelectedRow(i);
        }
        wasSettings = true;
    } else {
        if (wasSettings) {
            final UnitCategoryTableModel availableModel = (UnitCategoryTableModel) (availableTable).getModel ();
            final Map<String, Boolean> availableState = UnitCategoryTableModel.captureState (availableModel.getUnits ());
            ((SettingsTab) tpTabs.getComponentAt (INDEX_OF_SETTINGS_TAB)).doLazyRefresh (new Runnable () { // get SettingsTab
                @Override
                public void run () {
                    UnitCategoryTableModel.restoreState (availableModel.getUnits (), availableState, false);
                }
            });
        }
        wasSettings = false;
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:24,代碼來源:PluginManagerUI.java

示例11: computeOptionsWords

import javax.swing.JTabbedPane; //導入依賴的package包/類
private void computeOptionsWords() {
    Set<Map.Entry<String, CategoryModel.Category>> categories = categoryModel.getCategories();
    categoryid2tabs = new HashMap<String, HashMap<Integer, TabInfo>>();
    for (Map.Entry<String, CategoryModel.Category> set : categories) {
        JComponent jcomp = set.getValue().getComponent();
        String id = set.getValue().getID();
        if(jcomp instanceof JTabbedPane) {
            categoryid2tabbedpane.put(id, (JTabbedPane)jcomp);
        } else if(jcomp instanceof AdvancedPanel) {
            categoryid2tabbedpane.put(id, (JTabbedPane)jcomp.getComponent(0));
        } else if (jcomp instanceof Container) {
            handleAllComponents((Container) jcomp, id, null, -1);
        }
    }

    FileObject keywordsFOs = FileUtil.getConfigRoot().getFileObject(CategoryModel.OD_LAYER_KEYWORDS_FOLDER_NAME);

    for(FileObject keywordsFO : keywordsFOs.getChildren()) {
        handlePanel(keywordsFO);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:22,代碼來源:OptionsPanel.java

示例12: handleAllComponents

import javax.swing.JTabbedPane; //導入依賴的package包/類
private void handleAllComponents(Container container, String categoryID, JTabbedPane tabbedPane, int index) {
    Component[] components = container.getComponents();
    Component component;
    for (int i = 0; i < components.length; i++) {
        component = components[i];
        String text;
        
        if(component instanceof JTabbedPane) {
            if(categoryid2tabbedpane.get(categoryID) == null) {
                categoryid2tabbedpane.put(categoryID, (JTabbedPane)component);
            }
        } else {
            handleAllComponents((Container)component, categoryID, tabbedPane, index);
        }
    }
    
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:18,代碼來源:OptionsPanel.java

示例13: loc

import javax.swing.JTabbedPane; //導入依賴的package包/類
private static void loc(JTabbedPane p, int tabIdx, String key, JEditorPane ep) {
    JLabel label = new JLabel(); // Only for setting tab names

    String tabName = loc("CTL_" + key); //NOI18N
    Mnemonics.setLocalizedText(label, tabName);
    p.setTitleAt(tabIdx, label.getText());

    int idx = Mnemonics.findMnemonicAmpersand(tabName);
    if (idx != -1 && idx + 1 < tabName.length()) {
        char ch = Character.toUpperCase(tabName.charAt(idx + 1));
        p.setMnemonicAt(tabIdx, ch);
        if (ep != null) {
            ep.setFocusAccelerator(ch);
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:17,代碼來源:CodeTemplatesPanel.java

示例14: init

import javax.swing.JTabbedPane; //導入依賴的package包/類
@Override
@SuppressWarnings("nls")
public void init()
{
	setShowScripting(true);

	configTab = new DRMConfigTab();
	rightsTab = new DRMRightsTab();
	accessControlTab = new DRMAccessControlTab(getClientService().getService(RemoteUserService.class));
	requireAcceptanceFromTab = new DRMRequireAcceptanceFromTab();

	JTabbedPane tabs = new JTabbedPane();
	tabs.addTab(CurrentLocale.get("com.dytech.edge.admin.wizard.editor.drmpageeditor.config"), configTab);
	tabs.addTab(CurrentLocale.get("com.dytech.edge.admin.wizard.editor.drmpageeditor.rights"), rightsTab);
	tabs.addTab(CurrentLocale.get("com.dytech.edge.admin.wizard.editor.drmpageeditor.access"), accessControlTab);
	tabs.addTab(CurrentLocale.get("com.dytech.edge.admin.wizard.editor.drmpageeditor.requires"),
		requireAcceptanceFromTab);

	addSection(tabs);
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:21,代碼來源:DrmPageEditor.java

示例15: init

import javax.swing.JTabbedPane; //導入依賴的package包/類
/**
 * Initialize this visualizer
 * @throws ClassNotFoundException 
 * @throws IllegalAccessException 
 * @throws InstantiationException 
 */
private void init() {  // WARNING: called from ctor so must not be overridden (i.e. must be private or final)
    log.debug("init() - pass");
    setLayout(new BorderLayout(0, 5));
    setBorder(makeBorder());
    add(makeTitlePanel(), BorderLayout.NORTH);

    leftSide = createLeftPanel();
    // Prepare the common tab
    rightSide = new JTabbedPane();

    // Create the split pane
    mainSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftSide, rightSide);
    mainSplit.setOneTouchExpandable(true);

    JSplitPane searchAndMainSP = new JSplitPane(JSplitPane.VERTICAL_SPLIT, 
            new SearchTreePanel(root), mainSplit);
    searchAndMainSP.setOneTouchExpandable(true);
    add(searchAndMainSP, BorderLayout.CENTER);
    // init right side with first render
    resultsRender.setRightSide(rightSide);
    resultsRender.init();
}
 
開發者ID:Blazemeter,項目名稱:jmeter-bzm-plugins,代碼行數:29,代碼來源:ViewResultsFullVisualizer.java


注:本文中的javax.swing.JTabbedPane類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。