@Override public void mousePressed(MouseEvent e) { Point p = e.getPoint(); int i = getLayoutModel().indexOfPoint(p.x, p.y); tabState.setPressed(i); SingleSelectionModel sel = getSelectionModel(); selectionChanged = i != sel.getSelectedIndex(); // invoke possible selection change if ((i != -1) || !selectionChanged) { boolean change = shouldPerformAction(TabDisplayer.COMMAND_SELECT, i, e); if (change) { getSelectionModel().setSelectedIndex(i); tabState.setSelected(i); Component tc = i >= 0 ? getDataModel().getTab(i).getComponent() : null; if( null != tc && tc instanceof TopComponent && !((TopComponent)tc).isAncestorOf( KeyboardFocusManager.getCurrentKeyboardFocusManager().getPermanentFocusOwner() ) ) { ((TopComponent)tc).requestActive(); } } } if (e.isPopupTrigger()) { //Post a popup menu show request shouldPerformAction(TabDisplayer.COMMAND_POPUP_REQUEST, i, e); } }
@Override public void mousePressed( MouseEvent e ) { Point p = e.getPoint(); p = SwingUtilities.convertPoint( e.getComponent(), p, container ); int tabIndex = container.indexAtLocation( p.x, p.y ); SingleSelectionModel sel = container.getModel(); //invoke possible selection change if( tabIndex >= 0 && e.getComponent() != container ) { CloseableTabComponent tab = ( CloseableTabComponent ) container.getTabComponentAt( tabIndex ); if( tab.isInCloseButton( e ) ) { return; } tabIndex = container.indexOf( container.getComponentAt( tabIndex ) ); boolean change = shouldPerformAction( TabDisplayer.COMMAND_SELECT, tabIndex, e ); if( change ) { sel.setSelectedIndex( tabIndex ); Component tc = container.getDataModel().getTab( tabIndex ).getComponent(); if( null != tc && tc instanceof TopComponent && !(( TopComponent ) tc).isAncestorOf( KeyboardFocusManager.getCurrentKeyboardFocusManager().getPermanentFocusOwner() ) ) { (( TopComponent ) tc).requestActive(); } } } if( e.isPopupTrigger() ) { //Post a popup menu show request shouldPerformAction( TabDisplayer.COMMAND_POPUP_REQUEST, tabIndex, e ); } }
/** * Maps {@code JTabbedPane.getModel()} through queue */ public SingleSelectionModel getModel() { return (runMapping(new MapAction<SingleSelectionModel>("getModel") { @Override public SingleSelectionModel map() { return ((JTabbedPane) getSource()).getModel(); } })); }
/** * Maps {@code JTabbedPane.setModel(SingleSelectionModel)} through queue */ public void setModel(final SingleSelectionModel singleSelectionModel) { runMapping(new MapVoidAction("setModel") { @Override public void map() { ((JTabbedPane) getSource()).setModel(singleSelectionModel); } }); }
/** * Maps {@code JMenuBar.getSelectionModel()} through queue */ public SingleSelectionModel getSelectionModel() { return (runMapping(new MapAction<SingleSelectionModel>("getSelectionModel") { @Override public SingleSelectionModel map() { return ((JMenuBar) getSource()).getSelectionModel(); } })); }
/** * Maps {@code JMenuBar.setSelectionModel(SingleSelectionModel)} * through queue */ public void setSelectionModel(final SingleSelectionModel singleSelectionModel) { runMapping(new MapVoidAction("setSelectionModel") { @Override public void map() { ((JMenuBar) getSource()).setSelectionModel(singleSelectionModel); } }); }
/** * Maps {@code JPopupMenu.getSelectionModel()} through queue */ public SingleSelectionModel getSelectionModel() { return (runMapping(new MapAction<SingleSelectionModel>("getSelectionModel") { @Override public SingleSelectionModel map() { return ((JPopupMenu) getSource()).getSelectionModel(); } })); }
/** * Maps {@code JPopupMenu.setSelectionModel(SingleSelectionModel)} * through queue */ public void setSelectionModel(final SingleSelectionModel singleSelectionModel) { runMapping(new MapVoidAction("setSelectionModel") { @Override public void map() { ((JPopupMenu) getSource()).setSelectionModel(singleSelectionModel); } }); }
public void stateChanged(ChangeEvent e) { SingleSelectionModel model = (SingleSelectionModel) e.getSource(); if(model.getSelectedIndex() == 0) { currentControls = buttons; } else if(model.getSelectedIndex() == 1) { currentControls = radiobuttons; } else if(model.getSelectedIndex() == 2) { currentControls = checkboxes; } else { currentControls = togglebuttons; } }
public void stateChanged(ChangeEvent e) { SingleSelectionModel model = (SingleSelectionModel) e.getSource(); boolean srcSelected = model.getSelectedIndex() == 1; if(currentTabDemo != currentDemo && demoSrcPane != null && srcSelected) { demoSrcPane.setText(getString("SourceCode.loading")); repaint(); } if(currentTabDemo != currentDemo && srcSelected) { currentTabDemo = currentDemo; setSourceCode(currentDemo); } }
public SingleSelectionModel getSelectionModel() { return tabDisplayer.getSelectionModel(); }
protected final SingleSelectionModel getSelectionModel() { return selectionModel; }
@Override protected SingleSelectionModel getSelectionModel() { return JTabbedPaneAdapter.this.getModel(); }
SingleSelectionModel getSelectionModel() { return selectionModel; }
@Override protected final SingleSelectionModel getSelectionModel() { return controller.getSelectionModel(); }
public void setSingleSelectionMode(SingleSelectionModel sModel){ this.singleModel = sModel; }
/** * TabbedPaneDemo Constructor. * * @param swingset the swingset */ public TabbedPaneDemo(SwingSet2 swingset) { // Set the title for this demo, and an icon used to represent this // demo inside the SwingSet2 app. super(swingset, "TabbedPaneDemo" , "toolbar/JTabbedPane.gif"); // create tab position controls JPanel tabControls = new JPanel(); tabControls.add(new JLabel(getString("TabbedPaneDemo.label"))); top = (JRadioButton) tabControls.add(new JRadioButton(getString("TabbedPaneDemo.top"))); left = (JRadioButton) tabControls.add(new JRadioButton(getString("TabbedPaneDemo.left"))); bottom = (JRadioButton) tabControls.add(new JRadioButton(getString("TabbedPaneDemo.bottom"))); right = (JRadioButton) tabControls.add(new JRadioButton(getString("TabbedPaneDemo.right"))); getDemoPanel().add(tabControls, BorderLayout.NORTH); group = new ButtonGroup(); group.add(top); group.add(bottom); group.add(left); group.add(right); top.setSelected(true); top.addActionListener(this); bottom.addActionListener(this); left.addActionListener(this); right.addActionListener(this); // create tab tabbedpane = new JTabbedPane(); getDemoPanel().add(tabbedpane, BorderLayout.CENTER); String name = getString("TabbedPaneDemo.laine"); JLabel pix = new JLabel(createImageIcon("tabbedpane/laine.jpg", name)); tabbedpane.add(name, pix); name = getString("TabbedPaneDemo.ewan"); pix = new JLabel(createImageIcon("tabbedpane/ewan.jpg", name)); tabbedpane.add(name, pix); name = getString("TabbedPaneDemo.hania"); pix = new JLabel(createImageIcon("tabbedpane/hania.jpg", name)); tabbedpane.add(name, pix); name = getString("TabbedPaneDemo.bounce"); spin = new HeadSpin(); tabbedpane.add(name, spin); tabbedpane.getModel().addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { SingleSelectionModel model = (SingleSelectionModel) e.getSource(); if(model.getSelectedIndex() == tabbedpane.getTabCount()-1) { spin.go(); } } } ); }
/** * Create the selection model which will handle selection for the * TabDisplayer. SPI method located here because TabDisplayer.setSelectionModel * is package private. */ protected abstract SingleSelectionModel createSelectionModel();
@Override protected final SingleSelectionModel createSelectionModel() { return new DefaultTabSelectionModel (displayer.getModel()); }