Package javax.swing

Examples of javax.swing.JToggleButton


    public void createSendCommandPanel(JPanel parent) {
        cmdTextField = new JFormattedTextField();
        cmdTextField.setText( "" );
        parent.add( cmdTextField,
                    "growx, spanx 3, wrap" );
        JToggleButton sendBtn = new JToggleButton( "send" );
        parent.add( sendBtn );

        sendBtn.addActionListener( new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                //msg.setContent( cmd );
                gameEngine.receiveMessage( session,
                                           cmd );
                cmd = null;
View Full Code Here


        JToolBar toolBar_1 = new JToolBar();
        toolBar_1.setAlignmentX( Component.LEFT_ALIGNMENT );
        contentPane.add( toolBar_1 );

        JToggleButton newFrame = new JToggleButton( "New Window" );
        toolBar_1.add( newFrame );
        newFrame.addActionListener( new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                TextAdventure.createFrame( gameEngine,
                                           JFrame.DISPOSE_ON_CLOSE );
            }
        } );
View Full Code Here

    public void createSendCommandPanel(JPanel parent) {
        cmdTextField = new JFormattedTextField();
        cmdTextField.setText( "" );
        parent.add( cmdTextField,
                    "growx, spanx 3, wrap" );
        JToggleButton sendBtn = new JToggleButton( "send" );
        parent.add( sendBtn );

        sendBtn.addActionListener( new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                //msg.setContent( cmd );
                gameEngine.receiveMessage( session,
                                           cmd );
                cmd = null;
View Full Code Here

  public Class getWidgetClass() {
    return JToggleButton.class;
  }
  @Override
  public IAdapter getParent() {
    JToggleButton jb=(JToggleButton)getWidget();
    ToggleButtonModel dbm=(ToggleButtonModel) jb.getModel();
    ButtonGroup bg=dbm.getGroup();
    if (bg != null) {
      for (InvisibleAdapter invisible : getRootAdapter().getInvisibles()) {
        if (invisible instanceof ButtonGroupAdapter) {
          if (bg == ((ButtonGroupAdapter) invisible).getButtonGroup())
View Full Code Here

    }
    return super.getParent();
  }
  @Override
  public void deleteNotify() {
    JToggleButton jb = (JToggleButton) getWidget();
    DefaultButtonModel dbm = (DefaultButtonModel) jb.getModel();
    ButtonGroup bg = dbm.getGroup();
    if(bg!=null){
      bg.remove(jb);
    }
  }   
View Full Code Here

  public void test(TestHarness harness)
  {
    ButtonGroup g = new ButtonGroup();
   
    // add a button that is not selected
    JToggleButton b1 = new JToggleButton("B1");
    g.add(b1);
    g.remove(b1);
    harness.check(g.getButtonCount(), 0);
    harness.check(g.getSelection(), null);
    harness.check(((DefaultButtonModel) b1.getModel()).getGroup(), null);

    g.add(b1);
    JToggleButton b2 = new JToggleButton("B2");
    b2.setSelected(true);
    g.add(b2);
    g.remove(b2);
    harness.check(g.getButtonCount(), 1);
    harness.check(g.getSelection(), null);
    harness.check(((DefaultButtonModel) b2.getModel()).getGroup(), null);
   
    // try null
    g.remove(null);
    harness.check(g.getButtonCount(), 1);   
    harness.check(g.getSelection(), null);
View Full Code Here

{
  public void test(TestHarness harness)
  {
    ButtonGroup g = new ButtonGroup();
    harness.check(g.getButtonCount(), 0);
    JToggleButton b1 = new JToggleButton("B1");
    g.add(b1);
    harness.check(g.getButtonCount(), 1);
    JToggleButton b2 = new JToggleButton("B2");
    g.add(b2);
    harness.check(g.getButtonCount(), 2);
    g.remove(b2);
    harness.check(g.getButtonCount(), 1);       
    g.remove(b1);
View Full Code Here

  {
    ButtonGroup g = new ButtonGroup();
    Enumeration e = g.getElements();
    harness.check(e.hasMoreElements(), false);
   
    JToggleButton b1 = new JToggleButton("B1");
    g.add(b1);
    e = g.getElements();
    harness.check(e.nextElement(), b1);
    harness.check(e.hasMoreElements(), false);

    JToggleButton b2 = new JToggleButton("B2");
    g.add(b2);
    e = g.getElements();
    harness.check(e.nextElement(), b1);
    harness.check(e.nextElement(), b2);
    harness.check(e.hasMoreElements(), false);
View Full Code Here

  public void test(TestHarness harness)
  {
    ButtonGroup g = new ButtonGroup();
   
    // add a button that is not selected
    JToggleButton b1 = new JToggleButton("B1");
    g.add(b1);
    harness.check(g.getButtonCount(), 1);
    harness.check(g.getSelection(), null);
    harness.check(((DefaultButtonModel) b1.getModel()).getGroup(), g);
   
    // add a button that is selected
    JToggleButton b2 = new JToggleButton("B2");
    b2.setSelected(true);
    g.add(b2);
    harness.check(g.getButtonCount(), 2);
    harness.check(g.getSelection(), b2.getModel());
    harness.check(((DefaultButtonModel) b2.getModel()).getGroup(), g);
   
    // add another button that is selected
    JToggleButton b3 = new JToggleButton("B2");
    b3.setSelected(true);
    g.add(b3);
    harness.check(g.getButtonCount(), 3);
    harness.check(g.getSelection(), b2.getModel());
    harness.check(b2.isSelected(), true);
    harness.check(b3.isSelected(), false);
    harness.check(((DefaultButtonModel) b3.getModel()).getGroup(), g);
   
    // try null
    g.add(null);
    harness.check(g.getButtonCount(), 3);   
    harness.check(g.getSelection(), b2.getModel());
View Full Code Here

{
  public void test(TestHarness harness)
  {
    ButtonGroup g = new ButtonGroup();
    harness.check(g.isSelected(new DefaultButtonModel()), false);
    JToggleButton b1 = new JToggleButton("B1");
    g.add(b1);
    harness.check(g.isSelected(b1.getModel()), false);
    b1.getModel().setSelected(true);
    harness.check(g.isSelected(b1.getModel()), true);
    JToggleButton b2 = new JToggleButton("B2");
    b2.setSelected(true);
    g.add(b2);
    harness.check(g.isSelected(b2.getModel()), false);
    b2.getModel().setSelected(true);
    harness.check(g.isSelected(b1.getModel()), false);
    harness.check(g.isSelected(b2.getModel()), true);
   
    // try null
    harness.check(g.isSelected(null), false);
  }
View Full Code Here

TOP

Related Classes of javax.swing.JToggleButton

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.