Java 类javax.swing.SingleSelectionModel 实例源码

项目:incubator-netbeans    文件:AbstractViewTabDisplayerUI.java   
@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);
    }
}
项目:incubator-netbeans    文件:NBTabbedPaneController.java   
@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 );
    }
}
项目:openjdk-jdk10    文件:JTabbedPaneOperator.java   
/**
 * Maps {@code JTabbedPane.getModel()} through queue
 */
public SingleSelectionModel getModel() {
    return (runMapping(new MapAction<SingleSelectionModel>("getModel") {
        @Override
        public SingleSelectionModel map() {
            return ((JTabbedPane) getSource()).getModel();
        }
    }));
}
项目:openjdk-jdk10    文件:JTabbedPaneOperator.java   
/**
 * 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);
        }
    });
}
项目:openjdk-jdk10    文件:JMenuBarOperator.java   
/**
 * Maps {@code JMenuBar.getSelectionModel()} through queue
 */
public SingleSelectionModel getSelectionModel() {
    return (runMapping(new MapAction<SingleSelectionModel>("getSelectionModel") {
        @Override
        public SingleSelectionModel map() {
            return ((JMenuBar) getSource()).getSelectionModel();
        }
    }));
}
项目:openjdk-jdk10    文件:JMenuBarOperator.java   
/**
 * 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);
        }
    });
}
项目:openjdk-jdk10    文件:JPopupMenuOperator.java   
/**
 * Maps {@code JPopupMenu.getSelectionModel()} through queue
 */
public SingleSelectionModel getSelectionModel() {
    return (runMapping(new MapAction<SingleSelectionModel>("getSelectionModel") {
        @Override
        public SingleSelectionModel map() {
            return ((JPopupMenu) getSource()).getSelectionModel();
        }
    }));
}
项目:openjdk-jdk10    文件:JPopupMenuOperator.java   
/**
 * 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);
        }
    });
}
项目:openjdk9    文件:JTabbedPaneOperator.java   
/**
 * Maps {@code JTabbedPane.getModel()} through queue
 */
public SingleSelectionModel getModel() {
    return (runMapping(new MapAction<SingleSelectionModel>("getModel") {
        @Override
        public SingleSelectionModel map() {
            return ((JTabbedPane) getSource()).getModel();
        }
    }));
}
项目:openjdk9    文件:JTabbedPaneOperator.java   
/**
 * 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);
        }
    });
}
项目:openjdk9    文件:JMenuBarOperator.java   
/**
 * Maps {@code JMenuBar.getSelectionModel()} through queue
 */
public SingleSelectionModel getSelectionModel() {
    return (runMapping(new MapAction<SingleSelectionModel>("getSelectionModel") {
        @Override
        public SingleSelectionModel map() {
            return ((JMenuBar) getSource()).getSelectionModel();
        }
    }));
}
项目:openjdk9    文件:JMenuBarOperator.java   
/**
 * 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);
        }
    });
}
项目:openjdk9    文件:JPopupMenuOperator.java   
/**
 * Maps {@code JPopupMenu.getSelectionModel()} through queue
 */
public SingleSelectionModel getSelectionModel() {
    return (runMapping(new MapAction<SingleSelectionModel>("getSelectionModel") {
        @Override
        public SingleSelectionModel map() {
            return ((JPopupMenu) getSource()).getSelectionModel();
        }
    }));
}
项目:openjdk9    文件:JPopupMenuOperator.java   
/**
 * 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);
        }
    });
}
项目:beautyeye    文件:ButtonDemo.java   
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;
}
   }
项目:beautyeye    文件:SwingSet2.java   
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);
    } 
}
项目:incubator-netbeans    文件:DefaultTabbedContainerUI.java   
public SingleSelectionModel getSelectionModel() {
    return tabDisplayer.getSelectionModel();
}
项目:incubator-netbeans    文件:AbstractViewTabDisplayerUI.java   
protected final SingleSelectionModel getSelectionModel() {
    return selectionModel;
}
项目:incubator-netbeans    文件:JTabbedPaneAdapter.java   
@Override
protected SingleSelectionModel getSelectionModel() {
    return JTabbedPaneAdapter.this.getModel();
}
项目:incubator-netbeans    文件:Controller.java   
SingleSelectionModel getSelectionModel() {
    return selectionModel;
}
项目:incubator-netbeans    文件:TabbedImpl.java   
@Override
protected final SingleSelectionModel getSelectionModel() {
    return controller.getSelectionModel();
}
项目:j2se_for_android    文件:HCTabHost.java   
public void setSingleSelectionMode(SingleSelectionModel sModel){
    this.singleModel = sModel;
}
项目:beautyeye    文件:TabbedPaneDemo.java   
/**
    * 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();
      }
      }
   }
);
   }
项目:incubator-netbeans    文件:TabDisplayerUI.java   
/**
 * 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();
项目:incubator-netbeans    文件:AbstractViewTabDisplayerUI.java   
@Override
protected final SingleSelectionModel createSelectionModel() {
    return new DefaultTabSelectionModel (displayer.getModel());
}