Java Code Examples for javax.swing.JTabbedPane#addMouseListener()
The following examples show how to use
javax.swing.JTabbedPane#addMouseListener() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestDataComponent.java From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 | 6 votes |
private JTabbedPane createNewTestDataTab(TestData sTestData) { JTabbedPane testdataTab = new JTabbedPane(); testdataTab.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); testdataTab.setTabPlacement(JTabbedPane.BOTTOM); addToTab(testdataTab, sTestData.getGlobalData(), true); for (AbstractDataModel std : sTestData.getTestDataList()) { addToTab(testdataTab, std, false); } JLabel label = new JLabel("Click + to Add New TestData"); testdataTab.addTab("", ADD_NEW_TAB_ICON, label); label.setHorizontalAlignment(JLabel.CENTER); TabTitleEditListener l = new TabTitleEditListener(testdataTab, onTestDataRenameAction(), 0); l.setOnMiddleClickAction(onCloseAction()); testdataTab.addChangeListener(l); testdataTab.addMouseListener(l); testdataTab.addChangeListener(this); testdataTab.addMouseListener(onAddNewTDTab()); testdataTab.setComponentPopupMenu(testDataTabPopup); return testdataTab; }
Example 2
Source File: JTabbedPaneCloseIcon.java From wpcleaner with Apache License 2.0 | 6 votes |
/** * @param pane Pane component. * @param component Page. */ public JTabbedPaneCloseIcon(final JTabbedPane pane, final Component component) { MouseAdapter adapter = new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (!e.isConsumed() && (position != null) && (e.getButton() == MouseEvent.BUTTON1)) { if ((e.getClickCount() == 1) && (position.contains(e.getX(), e.getY()))) { for (int i = pane.getComponentCount(); i > 0; i--) { if (pane.getComponent(i - 1) == component) { pane.remove(i - 1); pane.removeMouseListener(this); e.consume(); return; } } } } } }; pane.addMouseListener(adapter); }
Example 3
Source File: RefactoringPanelContainer.java From netbeans with Apache License 2.0 | 5 votes |
void addPanel(JPanel panel) { RefactoringPanel.checkEventThread(); if (getComponentCount() == 0) { add(panel, BorderLayout.CENTER); } else { Component comp = getComponent(0); if (comp instanceof JTabbedPane) { ((JTabbedPane) comp).addTab(panel.getName(), null, panel, panel.getToolTipText()); ((JTabbedPane) comp).setSelectedComponent(panel); comp.validate(); } else if (comp instanceof JLabel) { remove(comp); add(panel, BorderLayout.CENTER); } else { remove(comp); JTabbedPane pane = TabbedPaneFactory.createCloseButtonTabbedPane(); pane.addMouseListener(listener); pane.addPropertyChangeListener(closeL); add(pane, BorderLayout.CENTER); pane.addTab(comp.getName(), null, comp, ((JPanel) comp).getToolTipText()); pane.addTab(panel.getName(), null, panel, panel.getToolTipText()); pane.setSelectedComponent(panel); pane.validate(); } } if (!isVisible) { isVisible = true; open(); } validate(); requestActive(); }
Example 4
Source File: CourseTabFactory.java From tmc-intellij with MIT License | 5 votes |
public void createCourseSpecificTab( ObjectFinder finder, ProjectOpener opener, String course, JTabbedPane tabbedPaneBase, CourseAndExerciseManager courseAndExerciseManager) { logger.info("Creating course specific tab. @CourseTabFactory"); final JBScrollPane panel = new JBScrollPane(); final JBList list = new JBList(); list.setCellRenderer(new ProjectListRenderer()); DefaultListModel defaultListModel = new DefaultListModel(); panel.setBorder(BorderFactory.createTitledBorder("")); ProjectListManagerHolder.get() .addExercisesToList(finder, course, defaultListModel, courseAndExerciseManager); if (defaultListModel.getSize() <= 0) { return; } list.setName(course); list.setModel(defaultListModel); MouseListener mouseListener = createMouseListenerForWindow(opener, panel, list); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list.addMouseListener(mouseListener); panel.setName(course); panel.setViewportView(list); ProjectListManagerHolder.get().addList(list); tabbedPaneBase.addTab(course, panel); tabbedPaneBase.addMouseListener(tabMouseListener(tabbedPaneBase)); setScrollBarToBottom(course, tabbedPaneBase, panel); }