List of usage examples for javax.swing JTabbedPane SCROLL_TAB_LAYOUT
int SCROLL_TAB_LAYOUT
To view the source code for javax.swing JTabbedPane SCROLL_TAB_LAYOUT.
Click Source Link
From source file:Main.java
public Main(String title) { super(title); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar menuBar = new JMenuBar(); tabComponentsItem = new JCheckBoxMenuItem("Use TabComponents", true); tabComponentsItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, InputEvent.ALT_MASK)); tabComponentsItem.addActionListener(e -> { for (int i = 0; i < pane.getTabCount(); i++) { if (tabComponentsItem.isSelected()) { } else { pane.setTabComponentAt(i, null); }/*from w w w.j a va 2 s . c o m*/ } }); scrollLayoutItem = new JCheckBoxMenuItem("Set ScrollLayout"); scrollLayoutItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.ALT_MASK)); scrollLayoutItem.addActionListener(e -> { if (pane.getTabLayoutPolicy() == JTabbedPane.WRAP_TAB_LAYOUT) { pane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); } else { pane.setTabLayoutPolicy(JTabbedPane.WRAP_TAB_LAYOUT); } }); JMenuItem resetItem = new JMenuItem("Reset JTabbedPane"); resetItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, InputEvent.ALT_MASK)); resetItem.addActionListener(e -> runTest()); JMenu optionsMenu = new JMenu("Options"); optionsMenu.add(tabComponentsItem); optionsMenu.add(scrollLayoutItem); optionsMenu.add(resetItem); menuBar.add(optionsMenu); setJMenuBar(menuBar); add(pane); }
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);// ww w . j a va 2 s. c o m //The following line enables to use scrolling tabs. tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); }
From source file:ee.ioc.cs.vsle.editor.Editor.java
/** * Application initializer.// ww w .j a v a2 s . co m */ private void initialize() { setLocationByPlatform(true); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); addComponentListener(new ComponentResizer(ComponentResizer.CARE_FOR_MINIMUM)); tabbedPane = new DnDTabbedPane(); tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); tabbedPane.addChangeListener(this); undoAction = new UndoAction(); redoAction = new RedoAction(); deleteAction = new DeleteAction(); cloneAction = new CloneAction(); makeMenu(); getContentPane().add(tabbedPane); initActions(); }
From source file:TabbedPaneTest.java
public TabbedPaneFrame() { setTitle("TabbedPaneTest"); setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT); tabbedPane = new JTabbedPane(); // we set the components to null and delay their loading until the tab is shown // for the first time ImageIcon icon = new ImageIcon("yellow-ball.gif"); tabbedPane.addTab("Mercury", icon, null); tabbedPane.addTab("Venus", icon, null); tabbedPane.addTab("Earth", icon, null); tabbedPane.addTab("Mars", icon, null); tabbedPane.addTab("Jupiter", icon, null); tabbedPane.addTab("Saturn", icon, null); tabbedPane.addTab("Uranus", icon, null); tabbedPane.addTab("Neptune", icon, null); tabbedPane.addTab("Pluto", null, null); final int plutoIndex = tabbedPane.indexOfTab("Pluto"); JPanel plutoPanel = new JPanel(); plutoPanel.add(new JLabel("Pluto", icon, SwingConstants.LEADING)); JToggleButton plutoCheckBox = new JCheckBox(); plutoCheckBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { tabbedPane.remove(plutoIndex); }/*from www.jav a 2s. c om*/ }); plutoPanel.add(plutoCheckBox); tabbedPane.setTabComponentAt(plutoIndex, plutoPanel); add(tabbedPane, "Center"); tabbedPane.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent event) { // check if this tab still has a null component if (tabbedPane.getSelectedComponent() == null) { // set the component to the image icon int n = tabbedPane.getSelectedIndex(); loadTab(n); } } }); loadTab(0); JPanel buttonPanel = new JPanel(); ButtonGroup buttonGroup = new ButtonGroup(); JRadioButton wrapButton = new JRadioButton("Wrap tabs"); wrapButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { tabbedPane.setTabLayoutPolicy(JTabbedPane.WRAP_TAB_LAYOUT); } }); buttonPanel.add(wrapButton); buttonGroup.add(wrapButton); wrapButton.setSelected(true); JRadioButton scrollButton = new JRadioButton("Scroll tabs"); scrollButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); } }); buttonPanel.add(scrollButton); buttonGroup.add(scrollButton); add(buttonPanel, BorderLayout.SOUTH); }
From source file:src.gui.ItTabbedPane.java
public ItTabbedPane() { super();/*from w w w . java 2s . c o m*/ //setUI(new ClosingTabbedPaneUI()); createPopupMenu(); addMouseListener(this); addChangeListener(this); // Configure the tabs to scroll setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); }
From source file:fr.pasteque.pos.sales.restaurant.JTicketsBagRestaurantMap.java
/** Creates new form JTicketsBagRestaurant */ public JTicketsBagRestaurantMap(AppView app, TicketsEditor panelticket) { super(app, panelticket); dlReceipts = new DataLogicReceipts(); dlSales = new DataLogicSales(); m_restaurantmap = new JTicketsBagRestaurant(app, this); m_PlaceCurrent = null;/*from w ww.j a va 2 s .c o m*/ m_PlaceClipboard = null; customer = null; this.floors = new ArrayList<Floor>(); this.places = new HashMap<String, List<Place>>(); try { ServerLoader loader = new ServerLoader(); ServerLoader.Response r = loader.read("PlacesAPI", "getAll"); if (r.getStatus().equals(ServerLoader.Response.STATUS_OK)) { JSONArray a = r.getArrayContent(); for (int i = 0; i < a.length(); i++) { JSONObject oFloor = a.getJSONObject(i); Floor f = new Floor(oFloor); this.floors.add(f); this.places.put(f.getID(), new ArrayList<Place>()); JSONArray aPlaces = oFloor.getJSONArray("places"); for (int j = 0; j < aPlaces.length(); j++) { Place p = new Place(aPlaces.getJSONObject(j)); this.places.get(f.getID()).add(p); } } } } catch (Exception e) { e.printStackTrace(); } initComponents(); // add the Floors containers if (this.floors.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 : this.floors) { 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 (this.floors.size() == 1) { // Just a frame for 1 floor Floor f = this.floors.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()); // jPlaces.setLayout(new FlowLayout()); m_jPanelMap.add(jPlaces, BorderLayout.CENTER); jPlaces.add(jScrCont, BorderLayout.CENTER); jScrCont.setViewportView(jPanCont); jPanCont.add(f.getContainer()); } // Add all the Table buttons. for (Floor f : this.floors) { List<Place> places = this.places.get(f.getID()); for (Place pl : places) { f.getContainer().add(pl.getButton()); pl.setButtonBounds(); pl.getButton().addActionListener(new MyActionListener(pl)); } } // Add the reservations panel m_jreservations = new JTicketsBagRestaurantRes(app, this); add(m_jreservations, "res"); }
From source file:components.TabComponentsDemo.java
private void initMenu() { JMenuBar menuBar = new JMenuBar(); //create Options menu tabComponentsItem = new JCheckBoxMenuItem("Use TabComponents", true); tabComponentsItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, InputEvent.ALT_MASK)); tabComponentsItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { for (int i = 0; i < pane.getTabCount(); i++) { if (tabComponentsItem.isSelected()) { initTabComponent(i); } else { pane.setTabComponentAt(i, null); }//from w w w. j av a 2 s .c o m } } }); scrollLayoutItem = new JCheckBoxMenuItem("Set ScrollLayout"); scrollLayoutItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.ALT_MASK)); scrollLayoutItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (pane.getTabLayoutPolicy() == JTabbedPane.WRAP_TAB_LAYOUT) { pane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); } else { pane.setTabLayoutPolicy(JTabbedPane.WRAP_TAB_LAYOUT); } } }); JMenuItem resetItem = new JMenuItem("Reset JTabbedPane"); resetItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, InputEvent.ALT_MASK)); resetItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { runTest(); } }); JMenu optionsMenu = new JMenu("Options"); optionsMenu.add(tabComponentsItem); optionsMenu.add(scrollLayoutItem); optionsMenu.add(resetItem); menuBar.add(optionsMenu); setJMenuBar(menuBar); }
From source file:com.eviware.soapui.impl.wsdl.panels.teststeps.WsdlTestRequestDesktopPanel.java
private Component buildLogPanel() { JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.RIGHT); tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); logArea = new JTextArea(); logArea.setEditable(false);//from ww w . j a v a2s. c o m logArea.setToolTipText("Request Log"); JPanel panel = new JPanel(new BorderLayout()); panel.add(new JScrollPane(logArea), BorderLayout.CENTER); tabbedPane.addTab("Assertions", buildAssertionsPanel()); tabbedPane.addTab("Request Log", panel); return UISupport.createTabPanel(tabbedPane, true); }
From source file:eu.apenet.dpt.standalone.gui.eag2012.Eag2012Frame.java
public void buildPanel(Eag eag, boolean isNew) { mainTabbedPane = new JTabbedPane(); mainTabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); mainTabbedPane.putClientProperty("jgoodies.noContentBorder", Boolean.TRUE); mainTabbedPane.add(labels.getString("eag2012.yourinstitution.institution"), new EagNewRepositoryPanel(eag, null, mainTabbedPane, this, model, labels, 0) .buildInstitutionTabbedPane(isNew, countrycode, mainagencycode)); for (int i = 1; i < eag.getArchguide().getDesc().getRepositories().getRepository().size(); i++) { if (eag.getArchguide().getDesc().getRepositories().getRepository().get(i).getRepositoryName().size() > 0 && StringUtils.isNotEmpty(eag.getArchguide().getDesc().getRepositories().getRepository().get(i) .getRepositoryName().get(0).getContent())) { String name = eag.getArchguide().getDesc().getRepositories().getRepository().get(i) .getRepositoryName().get(0).getContent(); mainTabbedPane.add(name,/*from www . jav a2s . c o m*/ new EagNewRepositoryPanel(eag, null, mainTabbedPane, this, model, labels, i) .buildInstitutionTabbedPane(isNew, countrycode, mainagencycode)); } else { mainTabbedPane.add(labels.getString("eag2012.tab.extraRepository") + " " + i, new EagNewRepositoryPanel(eag, null, mainTabbedPane, this, model, labels, i) .buildInstitutionTabbedPane(isNew, countrycode, mainagencycode)); } mainTabbedPane.setEnabledAt(i, false); } }
From source file:eu.apenet.dpt.standalone.gui.eaccpf.EacCpfFrame.java
public void buildPanel(EacCpf eacCpf, boolean isNew) { this.mainTabbedPane = new JTabbedPane(); this.mainTabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); this.mainTabbedPane.putClientProperty("jgoodies.noContentBorder", Boolean.TRUE); if (isNew) {/* w w w .ja v a2 s. c o m*/ this.mainTabbedPane.add(this.labels.getString("eaccpf.tab.start"), new EacCpfStartPanel(eacCpf, null, this.mainTabbedPane, this, this.model, this.labels, this.eacType, this.firstLanguage, this.firstScript).buildEditorPanel(null)); } else if (this.firstLanguage != null && !this.firstLanguage.isEmpty() && this.firstScript != null && !this.firstScript.isEmpty()) { this.mainTabbedPane.add(this.labels.getString("eaccpf.eacCpfItem"), new EacCpfNewPanel(eacCpf, null, this.mainTabbedPane, this, this.model, this.labels, this.eacType, this.firstLanguage, this.firstScript).buildInstitutionTabbedPane(isNew, this.eacType, this.firstLanguage, this.firstScript, this.mainagencycode)); } else { this.getEntityType(eacCpf); this.mainTabbedPane.add(this.labels.getString("eaccpf.eacCpfItem"), new EacCpfNewPanel(eacCpf, null, this.mainTabbedPane, this, this.model, this.labels, this.eacType, this.firstLanguage, this.firstScript).buildInstitutionTabbedPane(isNew, this.eacType, null, null, this.mainagencycode)); } }