List of usage examples for javax.swing JTabbedPane setTabLayoutPolicy
@BeanProperty(preferred = true, visualUpdate = true, enumerationValues = { "JTabbedPane.WRAP_TAB_LAYOUT", "JTabbedPane.SCROLL_TAB_LAYOUT" }, description = "The tabbedpane's policy for laying out the tabs") public void setTabLayoutPolicy(int tabLayoutPolicy)
From source file:Main.java
public Main() { super(new GridLayout(1, 1)); JTabbedPane tabbedPane = new JTabbedPane(); ImageIcon icon = createImageIcon("images/middle.gif"); JComponent panel1 = makeTextPanel("Panel #1"); tabbedPane.addTab("Tab 1", icon, panel1, "Does nothing"); tabbedPane.setMnemonicAt(0, KeyEvent.VK_1); JComponent panel2 = makeTextPanel("Panel #2"); tabbedPane.addTab("Tab 2", icon, panel2, "Does twice as much nothing"); tabbedPane.setMnemonicAt(1, KeyEvent.VK_2); JComponent panel3 = makeTextPanel("Panel #3"); tabbedPane.addTab("Tab 3", icon, panel3, "Still does nothing"); tabbedPane.setMnemonicAt(2, KeyEvent.VK_3); JComponent panel4 = makeTextPanel("Panel #4 (has a preferred size of 410 x 50)."); panel4.setPreferredSize(new Dimension(410, 50)); tabbedPane.addTab("Tab 4", icon, panel4, "Does nothing at all"); tabbedPane.setMnemonicAt(3, KeyEvent.VK_4); add(tabbedPane);/*from w w w.ja va 2 s . c o m*/ tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); }
From source file:components.TabbedPaneDemo.java
public TabbedPaneDemo() { super(new GridLayout(1, 1)); JTabbedPane tabbedPane = new JTabbedPane(); ImageIcon icon = createImageIcon("images/middle.gif"); JComponent panel1 = makeTextPanel("Panel #1"); tabbedPane.addTab("Tab 1", icon, panel1, "Does nothing"); tabbedPane.setMnemonicAt(0, KeyEvent.VK_1); JComponent panel2 = makeTextPanel("Panel #2"); tabbedPane.addTab("Tab 2", icon, panel2, "Does twice as much nothing"); tabbedPane.setMnemonicAt(1, KeyEvent.VK_2); JComponent panel3 = makeTextPanel("Panel #3"); tabbedPane.addTab("Tab 3", icon, panel3, "Still does nothing"); tabbedPane.setMnemonicAt(2, KeyEvent.VK_3); JComponent panel4 = makeTextPanel("Panel #4 (has a preferred size of 410 x 50)."); panel4.setPreferredSize(new Dimension(410, 50)); tabbedPane.addTab("Tab 4", icon, panel4, "Does nothing at all"); tabbedPane.setMnemonicAt(3, KeyEvent.VK_4); //Add the tabbed pane to this panel. add(tabbedPane);// w w w . j a v a 2 s. c o m //The following line enables to use scrolling tabs. tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); }
From source file:org.nebulaframework.ui.swing.cluster.ClusterMainUI.java
/** * Primary UI Setup Operations// w ww .j a va2 s .c o m */ private void setupUI() { setTitle("Nebula Grid - Cluster Manager"); setSize(WIDTH, HEIGHT); /* -- Menu Bar -- */ setJMenuBar(setupMenu()); /* -- Content -- */ setLayout(new BorderLayout()); JPanel centerPanel = new JPanel(); add(centerPanel, BorderLayout.CENTER); /* -- Setup Tabs -- */ centerPanel.setLayout(new BorderLayout()); JTabbedPane tabs = new JTabbedPane(); tabs.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); centerPanel.add(tabs); addUIElement("tabs", tabs); // Add to components map // General Tab tabs.addTab("General", setupGeneralTab()); setupTrayIcon(this); // Create Job Start Hook ServiceEventsSupport.addServiceHook(new ServiceHookCallback() { public void onServiceEvent(final ServiceMessage message) { createJobTab(message.getMessage()); } }, ServiceMessageType.JOB_START); }
From source file:com.openbravo.pos.sales.restaurant.JRetailTicketsBagRestaurantMap.java
/** * Creates new form JTicketsBagRestaurant */// ww w . j a va 2 s .c o m public JRetailTicketsBagRestaurantMap(AppView app, RetailTicketsEditor panelticket, String businessType) { super(app, panelticket); this.m_App = app; dlReceipts = (DataLogicReceipts) app.getBean("com.openbravo.pos.sales.DataLogicReceipts"); dlSales = (DataLogicSales) m_App.getBean("com.openbravo.pos.forms.DataLogicSales"); dlSystem = (DataLogicSystem) m_App.getBean("com.openbravo.pos.forms.DataLogicSystem"); m_restaurantmap = new JRetailTicketsBagRestaurant(app, this); m_PlaceCurrent = null; m_PlaceClipboard = null; customer = null; //Select all the floor details from db for showing the floor name in screen try { SentenceList sent = new StaticSentence(app.getSession(), "SELECT ID, NAME, IMAGE FROM FLOORS ORDER BY NAME", null, new SerializerReadClass(Floor.class)); m_afloors = sent.list(); } catch (BasicException eD) { m_afloors = new ArrayList<Floor>(); } //Select all the tables details from db for showing the table names in screen try { SentenceList sent = new StaticSentence(app.getSession(), "SELECT ID, NAME, X, Y, FLOOR FROM PLACES WHERE NAME NOT LIKE 'takeaway' ORDER BY FLOOR", null, new SerializerReadClass(Place.class)); m_aplaces = sent.list(); } catch (BasicException eD) { m_aplaces = new ArrayList<Place>(); } //Initialise the components initComponents(); // add the Floors containers if (m_afloors.size() > 1) { // A tab container for 2 or more floors JTabbedPane jTabFloors = new JTabbedPane(); jTabFloors.applyComponentOrientation(getComponentOrientation()); jTabFloors.setBorder(new javax.swing.border.EmptyBorder(new Insets(5, 5, 5, 5))); jTabFloors.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); jTabFloors.setFocusable(false); jTabFloors.setRequestFocusEnabled(false); m_jPanelMap.add(jTabFloors, BorderLayout.CENTER); for (Floor f : m_afloors) { f.getContainer().applyComponentOrientation(getComponentOrientation()); JScrollPane jScrCont = new JScrollPane(); jScrCont.applyComponentOrientation(getComponentOrientation()); JPanel jPanCont = new JPanel(); jPanCont.applyComponentOrientation(getComponentOrientation()); jTabFloors.addTab(f.getName(), f.getIcon(), jScrCont); jScrCont.setViewportView(jPanCont); jPanCont.add(f.getContainer()); } } else if (m_afloors.size() == 1) { // Just a frame for 1 floor Floor f = m_afloors.get(0); f.getContainer().applyComponentOrientation(getComponentOrientation()); JPanel jPlaces = new JPanel(); jPlaces.applyComponentOrientation(getComponentOrientation()); jPlaces.setLayout(new BorderLayout()); jPlaces.setBorder(new javax.swing.border.CompoundBorder( new javax.swing.border.EmptyBorder(new Insets(5, 5, 5, 5)), new javax.swing.border.TitledBorder(f.getName()))); JScrollPane jScrCont = new JScrollPane(); jScrCont.applyComponentOrientation(getComponentOrientation()); JPanel jPanCont = new JPanel(); jPanCont.applyComponentOrientation(getComponentOrientation()); m_jPanelMap.add(jPlaces, BorderLayout.CENTER); jPlaces.add(jScrCont, BorderLayout.CENTER); jScrCont.setViewportView(jPanCont); jPanCont.add(f.getContainer()); } // Add all the Table buttons. Floor currfloor = null; for (Place pl : m_aplaces) { int iFloor = 0; if (currfloor == null || !currfloor.getID().equals(pl.getFloor())) { // Look for a new floor do { currfloor = m_afloors.get(iFloor++); } while (!currfloor.getID().equals(pl.getFloor())); } currfloor.getContainer().add(pl.getButton()); pl.setButtonBounds(); pl.getButton().addActionListener(new MyActionListener(pl)); } // Add the reservations panel m_jreservations = new JRetailTicketsBagRestaurantRes(app, this); add(m_jreservations, "res"); }
From source file:org.freeplane.core.resources.components.OptionPanel.java
/** * This method builds the preferences panel. * A list of IPropertyControl is iterated through and * if the IPropertyControl is an instance of TabProperty, * it creates a new "tab" that can be clicked to reveal the appropriate panel. * If the previous selected tab was saved on close, * the appropriate tab is reopened./*from w w w . j a v a 2s. c om*/ * * @param controlsTree This is the data that needs to be built */ public void buildPanel(final DefaultMutableTreeNode controlsTree) { final JPanel centralPanel = new JPanel(); centralPanel.setLayout(new GridLayout(1, 1)); final JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); FormLayout bottomLayout = null; DefaultFormBuilder bottomBuilder = null; initControls(controlsTree); final Iterator<IPropertyControl> iterator = controls.iterator(); int tabIndex = 0; while (iterator.hasNext()) { final IPropertyControl control = iterator.next(); if (control instanceof TabProperty) { final TabProperty newTab = (TabProperty) control; bottomLayout = new FormLayout(newTab.getName(), ""); bottomBuilder = new DefaultFormBuilder(bottomLayout); bottomBuilder.setDefaultDialogBorder(); final JScrollPane bottomComponent = new JScrollPane(bottomBuilder.getPanel()); UITools.setScrollbarIncrement(bottomComponent); final String tabName = TextUtils.getOptionalText(newTab.getLabel()); tabStringToIndexMap.put(tabName, tabIndex); tabIndexToStringMap.put(tabIndex, tabName); tabbedPane.addTab(tabName, bottomComponent); tabIndex++; } else { control.layout(bottomBuilder); } } tabbedPane.addChangeListener(new ChangeListener() { public void stateChanged(final ChangeEvent event) { final JTabbedPane c = (JTabbedPane) event.getSource(); selectedPanel = tabIndexToStringMap.get(c.getSelectedIndex()); } }); centralPanel.add(tabbedPane); if (selectedPanel != null && tabStringToIndexMap.containsKey(selectedPanel)) { // Without the containsKey call the loading of the tab "behaviour"/"behavior" gives a nullpointer exception tabbedPane.setSelectedIndex(tabStringToIndexMap.get(selectedPanel)); } topDialog.getContentPane().add(centralPanel, BorderLayout.CENTER); final JButton cancelButton = new JButton(); MenuBuilder.setLabelAndMnemonic(cancelButton, TextUtils.getRawText("cancel")); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { closeWindow(); } }); final JButton okButton = new JButton(); MenuBuilder.setLabelAndMnemonic(okButton, TextUtils.getRawText("ok")); okButton.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { if (validate()) { closeWindow(); feedback.writeProperties(getOptionProperties()); } } }); topDialog.getRootPane().setDefaultButton(okButton); topDialog.getContentPane().add(ButtonBarFactory.buildOKCancelBar(cancelButton, okButton), BorderLayout.SOUTH); }