List of usage examples for javax.swing JTabbedPane getComponentAt
public Component getComponentAt(int index)
index
. From source file:Main.java
public static void main(String[] argv) throws Exception { JTabbedPane pane = new JTabbedPane(); int src = pane.getTabCount() - 1; int dst = 0;//from w ww. j a v a2 s.c om Component comp = pane.getComponentAt(src); String label = pane.getTitleAt(src); Icon icon = pane.getIconAt(src); Icon iconDis = pane.getDisabledIconAt(src); String tooltip = pane.getToolTipTextAt(src); boolean enabled = pane.isEnabledAt(src); int keycode = pane.getMnemonicAt(src); int mnemonicLoc = pane.getDisplayedMnemonicIndexAt(src); Color fg = pane.getForegroundAt(src); Color bg = pane.getBackgroundAt(src); pane.remove(src); pane.insertTab(label, icon, comp, tooltip, dst); pane.setDisabledIconAt(dst, iconDis); pane.setEnabledAt(dst, enabled); pane.setMnemonicAt(dst, keycode); pane.setDisplayedMnemonicIndexAt(dst, mnemonicLoc); pane.setForegroundAt(dst, fg); pane.setBackgroundAt(dst, bg); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JTabbedPane pane = new JTabbedPane(); int count = pane.getTabCount(); for (int i = 0; i < count; i++) { String label = pane.getTitleAt(i); Icon icon = pane.getIconAt(i); String tooltip = pane.getToolTipTextAt(i); boolean enabled = pane.isEnabledAt(i); int keycode = pane.getMnemonicAt(i); Component comp = pane.getComponentAt(i); }//from www. j a va2 s . c o m }
From source file:Main.java
public static int getIndexOf(JTabbedPane tabbedPane, Component component) { int result = -1; for (int i = 0; i < tabbedPane.getComponentCount(); i++) { Component comp = tabbedPane.getComponentAt(i); if (comp == component) { result = i;//from w ww . ja v a 2 s .c o m break; } } return result; }
From source file:Main.java
public static void setLocaleRecursively(final Component comp, final Locale l) { comp.setLocale(l);/*w w w. j a v a 2s. c om*/ Component[] children = null; if (comp instanceof JMenu) { children = ((JMenu) comp).getMenuComponents(); } else if (comp instanceof JTabbedPane) { JTabbedPane tabbedPane = (JTabbedPane) comp; children = new Component[tabbedPane.getTabCount()]; for (int i = 0; i < children.length; i++) { children[i] = tabbedPane.getComponentAt(i); } } else if (comp instanceof Container) { children = ((Container) comp).getComponents(); } for (Component child : children) { setLocaleRecursively(child, l); } }
From source file:Main.java
public static void setFont(JComponent component, Font font, ComponentOrientation componentOrientation) { component.setFont(font);/*from ww w . ja va 2 s . co m*/ if (component instanceof JTextField) { component.setComponentOrientation(componentOrientation); } if (component instanceof JTextArea) { component.setComponentOrientation(componentOrientation); } if (component instanceof JTextPane) { component.setComponentOrientation(componentOrientation); } if (component instanceof JScrollPane) { for (Component cmp : component.getComponents()) { setFont((JComponent) cmp, font, componentOrientation); } } if (component instanceof JTree) { component.setComponentOrientation(componentOrientation); } if (component instanceof JComboBox) { component.setComponentOrientation(componentOrientation); JComboBox comboBox = (JComboBox) component; ((BasicComboBoxRenderer) comboBox.getRenderer()).setHorizontalAlignment(SwingConstants.RIGHT); ((BasicComboBoxRenderer) comboBox.getRenderer()).setAutoscrolls(true); comboBox.setMaximumRowCount(20); } /* if(component instanceof JLabel) { ((JLabel)component).setHorizontalTextPosition(SwingConstants.RIGHT); }*/ if (component instanceof JPanel) { JPanel panel = (JPanel) component; if (panel.getBorder() != null && panel.getBorder() instanceof TitledBorder) { ((TitledBorder) panel.getBorder()).setTitleFont(font); panel.setComponentOrientation(componentOrientation); } for (Component cmp : component.getComponents()) { setFont((JComponent) cmp, font, componentOrientation); } } if (component instanceof JTabbedPane) { JTabbedPane tabbedPane = (JTabbedPane) component; int tabCount = tabbedPane.getTabCount(); for (int i = 0; i < tabCount; i++) { setFont((JComponent) tabbedPane.getComponentAt(i), font, componentOrientation); } } }
From source file:de.bfs.radon.omsimulation.gui.OMPanelResults.java
/** * Creates a panel displaying the distribution chart of certain selected * statistical values./*from w w w . j a v a2 s. c om*/ * * @param title * The headline of the chart. Will be hidden if set to null. * @param statistics * The selected statistics of a campaign containing all needed * values. * @param roomType * The room type to determine the colour of the chart. * @param preview * Will hide annotations, labels and headlines if set true. * @param fullscreen * Will correctly adjust the preferred size to screen resolution if * true. * @param mouseEvent * Will enable mouseClickedEvent if set true. Use with care, and only * inside the results panel. Set to false if you are unsure what you * are doing. * @return A chart displaying the distribution of certain selected statistical * values. */ public JPanel createDistributionPanel(String title, DescriptiveStatistics statistics, OMRoomType roomType, boolean preview, boolean fullscreen, boolean mouseEvent) { JFreeChart chart = OMCharts.createDistributionChart(title, statistics, roomType, preview); ChartPanel chartPanel = new ChartPanel(chart); Dimension dim; if (fullscreen) { dim = Toolkit.getDefaultToolkit().getScreenSize(); } else { dim = new Dimension(730, 347); } chartPanel.setPreferredSize(dim); if (mouseEvent) { chartPanel.addChartMouseListener(new ChartMouseListener() { @Override public void chartMouseClicked(ChartMouseEvent e) { OMSimulation simulation = (OMSimulation) comboBoxSimulations.getSelectedItem(); OMCampaign[] campaigns = simulation.getCampaigns(); try { XYItemEntity entity = (XYItemEntity) e.getEntity(); XYDataset dataset = entity.getDataset(); int item = entity.getItem(); double x = dataset.getXValue(0, item); double comparable = 0.0; OMCampaign result = null; OMStatistics selectedType = (OMStatistics) comboBoxStatistics.getSelectedItem(); for (int i = 0; i < campaigns.length; i++) { switch (selectedType) { case RoomArithmeticMeans: comparable = campaigns[i].getRoomAverage(); break; case RoomGeometricMeans: comparable = campaigns[i].getRoomLogAverage(); break; case RoomMedianQ50: comparable = campaigns[i].getRoomMedian(); break; case RoomMaxima: comparable = campaigns[i].getRoomMaximum(); break; case CellarArithmeticMeans: comparable = campaigns[i].getCellarAverage(); break; case CellarGeometricMeans: comparable = campaigns[i].getCellarLogAverage(); break; case CellarMedianQ50: comparable = campaigns[i].getCellarMedian(); break; case CellarMaxima: comparable = campaigns[i].getCellarMaximum(); break; default: comparable = campaigns[i].getRoomAverage(); break; } if (comparable == x) { result = campaigns[i]; } } if (result != null) { try { Thread.sleep(100); } catch (InterruptedException ie) { ie.printStackTrace(); } JTabbedPane tab = (JTabbedPane) getParent(); tab.remove(tab.getComponentAt(4)); JPanel jpanelTesting = new OMPanelTesting(simulation, result); tab.add(jpanelTesting, "Analyse", 4); tab.updateUI(); tab.setSelectedIndex(4); } } catch (Exception x) { x.printStackTrace(); } } @Override public void chartMouseMoved(ChartMouseEvent ignore) { } }); } JPanel distPanel = (JPanel) chartPanel; return distPanel; }
From source file:edu.ku.brc.specify.tasks.subpane.lm.LifeMapperPane.java
/** * @return//from w ww .j a v a 2s . co m */ private int getCurrentSizeSquare() { int maxHeight = MAP_HEIGHT; int maxWidth = MAP_WIDTH; if (SubPaneMgr.getInstance() instanceof JTabbedPane) { Dimension size; JTabbedPane tbPane = (JTabbedPane) SubPaneMgr.getInstance(); if (tbPane.getTabCount() > 0) { size = tbPane.getComponentAt(0).getSize(); } else { size = tbPane.getSize(); size.height -= 30; } int lblHeight = (UIHelper.createLabel(" ").getPreferredSize().height) * 5; maxHeight = size.height - lblHeight - IMG_HEIGHT - 30; maxWidth = size.width - 20; } return Math.min(maxHeight, maxWidth); }
From source file:edu.ku.brc.specify.tasks.subpane.security.SecurityAdminPane.java
/** * //from www . ja v a 2 s .com */ private void createUserPanel() { final EditorPanel infoPanel = new EditorPanel(this); final CellConstraints cc = new CellConstraints(); PermissionEditor prefsEdt = new PermissionEditor("SEC_PREFS", new PrefsPermissionEnumerator(), infoPanel, false, "SEC_NAME_TITLE", "SEC_ENABLE_PREF", null, null, null); JButton selectAllBtn = createI18NButton("SELECTALL"); JButton deselectAllBtn = createI18NButton("DESELECTALL"); final PermissionPanelEditor generalEditor = new PermissionPanelEditor(selectAllBtn, deselectAllBtn); generalEditor.addPanel( new IndvPanelPermEditor("SEC_TOOLS", "SEC_TOOLS_DSC", new TaskPermissionEnumerator(), infoPanel)); generalEditor.addPanel(new PermissionEditor("SEC_TABLES", new TablePermissionEnumerator(), infoPanel)); generalEditor.addPanel(prefsEdt); final PermissionPanelEditor objEditor = new PermissionPanelEditor(selectAllBtn, deselectAllBtn); objEditor.addPanel( new IndvPanelPermEditor("SEC_DOS", "SEC_DOS_DSC", new ObjectPermissionEnumerator(), infoPanel)); // create user form ViewBasedDisplayPanel panel = createViewBasedDisplayPanelForUser(infoPanel); // create tabbed panel for different kinds of permission editing tables final JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.addTab(getResourceString("SEC_GENERAL"), generalEditor); //tabbedPane.addTab("Objects", objEditor); // I18N //final PanelBuilder mainPB = new PanelBuilder(new FormLayout("f:p:g", "t:p,4px,p,5px,f:p:g,2dlu,p"), infoPanel); //setting min size for generalEditor (only px settings work.) final PanelBuilder mainPB = new PanelBuilder(new FormLayout("f:p:g", "t:p,4px,p,5px,f:[400px,p]:g,2dlu,p"), infoPanel); // lay out controls on panel int y = 1; mainPB.add(panel, cc.xy(1, y)); y += 2; mainPB.addSeparator(getResourceString("SEC_PERMS"), cc.xy(1, y)); y += 2; mainPB.add(tabbedPane, cc.xy(1, y)); y += 2; PanelBuilder saveBtnPB = new PanelBuilder(new FormLayout("f:p:g,p,2px,p,2px,p,2px,p", "p")); Viewable viewable = panel.getMultiView().getCurrentView(); JButton valBtn = FormViewObj.createValidationIndicator(viewable.getUIComponent(), viewable.getValidator()); panel.getMultiView().getCurrentValidator().setValidationBtn(valBtn); saveBtnPB.add(selectAllBtn, cc.xy(2, 1)); saveBtnPB.add(deselectAllBtn, cc.xy(4, 1)); saveBtnPB.add(valBtn, cc.xy(6, 1)); saveBtnPB.add(infoPanel.getSaveBtn(), cc.xy(8, 1)); mainPB.add(saveBtnPB.getPanel(), cc.xy(1, y)); y += 2; String className = SpecifyUser.class.getCanonicalName(); infoCards.add(infoPanel, className); AdminInfoSubPanelWrapper subPanel = new AdminInfoSubPanelWrapper(panel); subPanel.addPermissionEditor(generalEditor); subPanel.addPermissionEditor(objEditor); infoSubPanels.put(className, subPanel); editorPanels.put(className, infoPanel); selectAllBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ((PermissionPanelEditor) tabbedPane.getComponentAt(tabbedPane.getSelectedIndex())).selectAll(); } }); deselectAllBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ((PermissionPanelEditor) tabbedPane.getComponentAt(tabbedPane.getSelectedIndex())).deselectAll(); } }); }
From source file:org.nuclos.client.genericobject.GenericObjectCollectController.java
private void selectTabPane(CollectableGenericObjectWithDependants clct) { // select tab in state //Integer iState = (Integer)clct.getField(NuclosEOField.STATENUMBER.getMetaData().getField()).getValueId(); DynamicAttributeVO vo = clct.getGenericObjectCVO() .getAttribute(NuclosEOField.STATENUMBER.getMetaData().getId().intValue()); if (vo == null) return;//from w w w . ja va 2s. co m Integer iState = (Integer) vo.getValue(); String strTabName = getPreferences().get(TABSELECTED, ""); for (StateVO voState : StateDelegate.getInstance().getStatesByModule(getModuleId())) if (voState.getNumeral().equals(iState)) { if (voState.getTabbedPaneName() != null) strTabName = voState.getTabbedPaneName(); break; } JComponent jcomp = layoutrootDetails.getRootComponent(); List<JTabbedPane> lst = new ArrayList<JTabbedPane>(); searchTabbedPanes(jcomp, lst); for (JTabbedPane tabPane : lst) for (int i = 0; i < tabPane.getTabCount(); i++) if (org.apache.commons.lang.StringUtils.equals(tabPane.getComponentAt(i).getName(), strTabName) || org.apache.commons.lang.StringUtils.equals(tabPane.getTitleAt(i), strTabName)) { tabPane.setSelectedIndex(i); break; } adjustTabbedPanes(lst); }
From source file:org.nuclos.client.genericobject.GenericObjectCollectController.java
private void adjustTabbedPanes(List<JTabbedPane> lst) { for (JTabbedPane tabPane : lst) { List<Component> lstTabToRemove = new ArrayList<Component>(tabPane.getTabCount()); for (int i = 0; i < tabPane.getTabCount(); i++) { Component c = tabPane.getComponentAt(i); if (c instanceof JComponent) { List<JComponent> lstComponents = new ArrayList<JComponent>(); collectComponents((JComponent) c, lstComponents); if (lstComponents.size() == 0) { tabPane.setEnabledAt(i, false); lstTabToRemove.add(c); break; }// w ww . j av a 2 s .c o m boolean blnVisible = false; for (JComponent jc : lstComponents) { if (jc instanceof LabeledComponent) { LabeledComponent lc = (LabeledComponent) jc; blnVisible = lc.isVisible(); } else if (jc instanceof JPanel) blnVisible = false; else blnVisible = jc.isVisible(); if (blnVisible) break; } tabPane.setEnabledAt(i, !blnVisible ? blnVisible : blnVisible && tabPane.isEnabledAt(i)); if (!blnVisible) lstTabToRemove.add(c); } } for (Component c : lstTabToRemove) { tabPane.remove(c); } } }