当前位置: 首页>>代码示例>>Java>>正文


Java JButton.doClick方法代码示例

本文整理汇总了Java中javax.swing.JButton.doClick方法的典型用法代码示例。如果您正苦于以下问题:Java JButton.doClick方法的具体用法?Java JButton.doClick怎么用?Java JButton.doClick使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JButton的用法示例。


在下文中一共展示了JButton.doClick方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: change

import javax.swing.JButton; //导入方法依赖的package包/类
/**
 * Invokes the change button on the view.
 * 
 * @param stage <code>true</code> to mode files from UnStage to the IDNEX.
 * <code>false</code> to move files out of the INDEX.
 * @param index Index in the table of the file to move.
 */
private void change(boolean stage, String fileToSelect) {
  ChangesPanel changesPanel = null;
  if (stage) {
    changesPanel = stagingPanel.getUnstagedChangesPanel();
  } else {
    changesPanel = stagingPanel.getStagedChangesPanel();
  }
  
  JTree filesTree = changesPanel.getTreeView();
  
  JButton ssButton = changesPanel.getChangeSelectedButton();
  
  expandAll(filesTree);
  
  TreePath treePath = TreeFormatter.getTreePath(filesTree.getModel(), fileToSelect);
  filesTree.getSelectionModel().setSelectionPath(treePath);
  
  assertTrue(ssButton.isEnabled());
  ssButton.doClick();
}
 
开发者ID:oxygenxml,项目名称:oxygen-git-plugin,代码行数:28,代码来源:TreeViewTest.java

示例2: testRedundantActionPerformed

import javax.swing.JButton; //导入方法依赖的package包/类
public void testRedundantActionPerformed () {
    JButton b1 = new JButton ("Do");
    JButton b2 = new JButton ("Don't");
    ActionListener listener = new ActionListener () {
        public void actionPerformed (ActionEvent event) {
            assertFalse ("actionPerformed() only once.", performed);
            performed = true;
        }
    };
    DialogDescriptor dd = new DialogDescriptor (
                        "...",
                        "My Dialog",
                        true,
                        new JButton[] {b1, b2},
                        b2,
                        DialogDescriptor.DEFAULT_ALIGN,
                        null,
                        null
                    );
    dd.setButtonListener (listener);
    Dialog dlg = DialogDisplayer.getDefault ().createDialog (dd);
    b1.doClick ();
    assertTrue ("Button b1 invoked.", performed);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:DialogDisplayer50960Test.java

示例3: init

import javax.swing.JButton; //导入方法依赖的package包/类
void init() {
		JPanel panel = new JPanel();
		imageB = new JButton("Import Image");
		panel.add(imageB);
		imageB.addActionListener( new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				begin();
			}
		});
		
		frame.getContentPane().add( panel, "North");
		frame.getContentPane().add( new JScrollPane(area) );
		frame.pack();
		frame.show();
	
//		GMA 1.4.8: Automatically bring up file chooser to select grid	
		imageB.doClick();
	
	}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:20,代码来源:ImportImage.java

示例4: change

import javax.swing.JButton; //导入方法依赖的package包/类
/**
 * Invokes the change button on the view.
 * 
 * @param stage <code>true</code> to mode files from UnStage to the IDNEX.
 * <code>false</code> to move files out of the INDEX.
 * @param index Index in the table of the file to move.
 */
private void change(boolean stage, int index) {
  if (stage) {
    ChangesPanel unstagedChangesPanel = stagingPanel.getUnstagedChangesPanel();
    JTable filesTable = unstagedChangesPanel.getFilesTable();
    
    JButton ssButton = unstagedChangesPanel.getChangeSelectedButton();
    filesTable.getSelectionModel().setSelectionInterval(index, index);
    
    assertTrue(ssButton.isEnabled());
    ssButton.doClick();
  } else {
    ChangesPanel stagedChangesPanel = stagingPanel.getStagedChangesPanel();
    JTable stFilesTable = stagedChangesPanel.getFilesTable();
    
    JButton usButton = stagedChangesPanel.getChangeSelectedButton();
    stFilesTable.getSelectionModel().setSelectionInterval(index, index);
    assertTrue(usButton.isEnabled());
    usButton.doClick();
  }
}
 
开发者ID:oxygenxml,项目名称:oxygen-git-plugin,代码行数:28,代码来源:FlatViewTest.java

示例5: testActionPerformed

import javax.swing.JButton; //导入方法依赖的package包/类
public void testActionPerformed() {
    instanceContent.add(sqlExecution);
    Component tp = ((Presenter.Toolbar)action).getToolbarPresenter();
    assertTrue("The toolbar presenter should be a JButton", tp instanceof JButton);

    JButton button = (JButton)tp;
    button.doClick();
    assertTrue("Should perform the action when SQLExecution in the context", baseAction.actionPeformedCount == 1);

    instanceContent.remove(sqlExecution);
    button.doClick();
    assertTrue("Should not perform the action when no SQLExecution in the context", baseAction.actionPeformedCount == 1);

    instanceContent.add(sqlExecution);
    button.doClick();
    assertTrue("Should perform the action when SQLExecution in the context", baseAction.actionPeformedCount == 2);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:SQLExecutionBaseActionTest.java

示例6: resetValuesOnSubForm

import javax.swing.JButton; //导入方法依赖的package包/类
/**
 * Reset sub object.
 * @param node the node
 */
private void resetValuesOnSubForm(DefaultMutableTreeNode node) {
	
	// --- Set the value to null ----------------------
	DynType dynType = (DynType) node.getUserObject(); 
	this.setSingleValue(dynType, null);
	
	// --- Is there a multiple button to remove? ------
	JButton multipleButton = dynType.getJButtonMultipleOnDynFormPanel();
	if (multipleButton!=null) {
		if (multipleButton.getText().equals("+")==false) {
			multipleButton.doClick();
		}
	}

	// --- Are there any sub nodes available? ---------
	if (node.getChildCount()>0) {
		for (int i=0; i < node.getChildCount(); i++) {
			DefaultMutableTreeNode subNode = (DefaultMutableTreeNode) node.getChildAt(i);
			this.resetValuesOnSubForm(subNode);
		}
	}
	
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:28,代码来源:DynFormBase.java

示例7: changeAll

import javax.swing.JButton; //导入方法依赖的package包/类
/**
 * Stage/Unstage all files from the model.
 * 
 * @param stage <code>true</code> to stage. <code>false</code> to un-stage.
 */
private void changeAll(boolean stage) {
  if (stage) {
    ChangesPanel unstagedChangesPanel = stagingPanel.getUnstagedChangesPanel();
    
    JButton ssButton = unstagedChangesPanel.getChangeAllButton();
    assertTrue(ssButton.isEnabled());
    ssButton.doClick();
  } else {
    ChangesPanel stagedChangesPanel = stagingPanel.getStagedChangesPanel();
    
    JButton usButton = stagedChangesPanel.getChangeAllButton();
    assertTrue(usButton.isEnabled());
    usButton.doClick();
  }
}
 
开发者ID:oxygenxml,项目名称:oxygen-git-plugin,代码行数:21,代码来源:FlatViewTest.java

示例8: init

import javax.swing.JButton; //导入方法依赖的package包/类
void init() {
	JPanel panel = new JPanel();
	gridB = new JButton("Import Grid");
	panel.add(gridB);
	gridB.addActionListener( new ActionListener() {
		public void actionPerformed(ActionEvent e) {
			begin();
		}
	});

	frame.getContentPane().add( panel, "North");
    JScrollPane scroll = new JScrollPane (area);

	frame.getContentPane().add( scroll );
	frame.pack();
	frame.show();

	// GMA 1.4.8: Automatically bring up file chooser to select grid
	gridB.doClick();
	
	//determine whether logging is selected in Preferences
	MapApp app = (MapApp) suite.map.getApp();
	log = app.logGridImports;
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:25,代码来源:ImportGrid.java

示例9: trySendEnterToDialog

import javax.swing.JButton; //导入方法依赖的package包/类
private void trySendEnterToDialog() {
    //        System.err.println("SendEnterToDialog");
    EventObject ev = EventQueue.getCurrentEvent();

    if (ev instanceof KeyEvent && (((KeyEvent) ev).getKeyCode() == KeyEvent.VK_ENTER)) {
        if (ev.getSource() instanceof JComboBox && ((JComboBox) ev.getSource()).isPopupVisible()) {
            return;
        }

        if (
            ev.getSource() instanceof JTextComponent &&
                ((JTextComponent) ev.getSource()).getParent() instanceof JComboBox &&
                ((JComboBox) ((JTextComponent) ev.getSource()).getParent()).isPopupVisible()
        ) {
            return;
        }

        JRootPane jrp = getRootPane();

        if (jrp != null) {
            JButton b = jrp.getDefaultButton();

            if ((b != null) && b.isEnabled()) {
                b.doClick();
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:EditablePropertyDisplayer.java

示例10: trySendEnterToDialog

import javax.swing.JButton; //导入方法依赖的package包/类
private void trySendEnterToDialog(BaseTable bt) {
    //        System.err.println("SendEnterToDialog");
    EventObject ev = EventQueue.getCurrentEvent();

    if (ev instanceof KeyEvent && (((KeyEvent) ev).getKeyCode() == KeyEvent.VK_ENTER)) {
        if (ev.getSource() instanceof JComboBox && ((JComboBox) ev.getSource()).isPopupVisible()) {
            return;
        }

        if (
            ev.getSource() instanceof JTextComponent &&
                ((JTextComponent) ev.getSource()).getParent() instanceof JComboBox &&
                ((JComboBox) ((JTextComponent) ev.getSource()).getParent()).isPopupVisible()
        ) {
            return;
        }

        JRootPane jrp = bt.getRootPane();

        if (jrp != null) {
            JButton b = jrp.getDefaultButton();

            if ((b != null) && b.isEnabled()) {
                b.doClick();
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:BaseTable.java

示例11: testToolbarPushIsNotified

import javax.swing.JButton; //导入方法依赖的package包/类
public void testToolbarPushIsNotified() throws Exception {
       TestSupport.ChangeableLookup lookup = new TestSupport.ChangeableLookup();
       TestLSA tlsa = new TestLSA( lookup );
assertTrue ("TestLSA action is enabled.", tlsa.isEnabled ());
tlsa.refreshCounter = 0;
       TestPropertyChangeListener tpcl = new TestPropertyChangeListener();
       tlsa.addPropertyChangeListener( tpcl );
       lookup.change(d2);
       assertEquals( "Refresh should be called once", 1, tlsa.refreshCounter );
       assertEquals( "One event should be fired", 1, tpcl.getEvents().size() );
       assertTrue("Action is enabled", tlsa.isEnabled());

       tlsa.setDisplayName("Jarda");
    
       JToolBar bar = new JToolBar();
       JButton item = bar.add(tlsa);
       item.doClick();
       
       assertEquals("One record logged:\n" + my.recs, 1, my.recs.size());
       LogRecord r = my.recs.get(0);
       assertEquals("Menu push", "UI_ACTION_BUTTON_PRESS", r.getMessage());
       assertEquals("four args", 5, r.getParameters().length);
       assertEquals("first is the menu item", item, r.getParameters()[0]);
       assertEquals("second is its class", item.getClass().getName(), r.getParameters()[1]);
       assertEquals("3rd is action", tlsa, r.getParameters()[2]);
       assertEquals("4th its class", tlsa.getClass().getName(), r.getParameters()[3]);
       assertEquals("5th name", "Jarda", r.getParameters()[4]);
       
       tlsa.clear();
       tpcl.clear();
       lookup.change(d3);
       assertEquals( "Refresh should be called once", 1, tlsa.refreshCounter );
       assertEquals( "One event should be fired", 1, tpcl.getEvents().size() );        
   }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:35,代码来源:LookupSensitiveActionUILogTest.java

示例12: actionPerformed

import javax.swing.JButton; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
    JRootPane jrp = getRootPane();
    if (jrp != null) {
        JButton b = getRootPane().getDefaultButton();
        if (b != null && b.isEnabled()) {
            b.doClick();
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:ETable.java

示例13: testAccountLoginValidation

import javax.swing.JButton; //导入方法依赖的package包/类
/**
 * Tests to ensure when a user attempts to log in that it correctly
 * matches the hashed password stored in their account file.
 * Will need to be updated once verifying something other than the label
 * is possible (ie account functionality implemented).
 */
@Test
public void testAccountLoginValidation(){
	JTextField usernameField = dlg.getUsernameField();
	JPasswordField passPrimary = dlg.getPasswordFieldPrimary();
	JPasswordField passVerify = dlg.getPasswordFieldVerify();
	JButton button = dlg.getBtnSignIn();
	
	try {
		AccountManager.createUserAccount("BobTest", "guest");
	} catch (IOException e) {
		assertTrue(false);
		e.printStackTrace();
	}
	
	//Test login to existing account via button
	usernameField.setText("BobTest");
	passPrimary.setText("guest");
	button.doClick();
	if(dlg.getErrorLabel().getText().equals("Successfully logged in.")){
		assertTrue(true);
	}
	else{
		assertTrue(false);
	}		
	AccountManager.removeUserAccount("BobTest");		
}
 
开发者ID:ser316asu,项目名称:Dahlem_SER316,代码行数:33,代码来源:LoginDialogTest.java

示例14: testAccountCreation

import javax.swing.JButton; //导入方法依赖的package包/类
/**
 * Tests to ensure account is not generated when it shouldn't be. For
 * example: Differing passwords or account already exists. This does not
 * validate the account creation process details.
 */
@Test
public void testAccountCreation() {
	JTextField usernameField = dlg.getUsernameField();
	JPasswordField passPrimary = dlg.getPasswordFieldPrimary();
	JPasswordField passVerify = dlg.getPasswordFieldVerify();
	JButton button = dlg.getBtnCreateNewAccount();

	// Test account created no password
	usernameField.setText("HeyTestGuy1");
	passPrimary.setText("");
	passVerify.setText("");
	button.doClick();
	assertTrue(AccountManager.userExists("HeyTestGuy1"));

	// Test account NOT created - mismatched password
	usernameField.setText("HeyTestGuy2");
	passPrimary.setText("ardvark");
	passVerify.setText("");
	button.doClick();
	assertFalse(AccountManager.userExists("HeyTestGuy2"));

	//Test all correct values.
	usernameField.setText("HeyTestGuy3");
	passPrimary.setText("ardvark");
	passVerify.setText("ardvark");
	button.doClick();
	assertTrue(AccountManager.userExists("HeyTestGuy3"));
			
	assertTrue(AccountManager.removeUserAccount("HeyTestGuy1"));
	assertTrue(AccountManager.removeUserAccount("HeyTestGuy3"));
}
 
开发者ID:ser316asu,项目名称:Dahlem_SER316,代码行数:37,代码来源:LoginDialogTest.java

示例15: doTestDialogsOptions

import javax.swing.JButton; //导入方法依赖的package包/类
private void doTestDialogsOptions () {
    boolean modal = false;
    //boolean modal = true;
    JButton erase = new JButton ("Erase all my data");
    JButton rescue = new JButton ("Rescue");
    JButton cancel = new JButton ("Cancel");
    JButton [] options = new JButton [] {erase, rescue, cancel};
    DialogDescriptor dd = new DialogDescriptor (new JLabel ("Something interesting"), "My dialog", modal,
            // options
            options,
            rescue,
            // align
            DialogDescriptor.RIGHT_ALIGN,
            new HelpCtx (NbPresenterTest.class), null);
    

    dd.setClosingOptions (new Object[0]);
            
    NbPresenter presenter = new NbDialog (dd, (JFrame)null);
    presenter.setVisible (true);
    
    erase.doClick ();
    assertEquals ("Erase was invoked.", erase.getText (), ((JButton)dd.getValue ()).getText ());
    erase.doClick ();
    assertEquals ("Erase was invoked again on same dialog.", erase.getText (), ((JButton)dd.getValue ()).getText ());
    presenter.dispose ();

    presenter = new NbDialog (dd, (JFrame)null);
    presenter.setVisible (true);

    erase.doClick ();
    assertEquals ("Erase was invoked of reused dialog.", erase.getText (), ((JButton)dd.getValue ()).getText ());
    erase.doClick ();
    assertEquals ("Erase was invoked again on reused dialog.", erase.getText (), ((JButton)dd.getValue ()).getText ());
    presenter.dispose ();

    presenter = new NbDialog (dd, (JFrame)null);
    presenter.setVisible (true);

    rescue.doClick ();
    assertEquals ("Rescue was invoked of reused dialog.", rescue.getText (), ((JButton)dd.getValue ()).getText ());
    rescue.doClick ();
    assertEquals ("Rescue was invoked again on reused dialog.", rescue.getText (), ((JButton)dd.getValue ()).getText ());
    presenter.dispose ();
    
    presenter = new NbDialog (dd, (JFrame)null);
    presenter.setVisible (true);

    cancel.doClick ();
    assertEquals ("Cancel was invoked of reused dialog.", cancel.getText (), ((JButton)dd.getValue ()).getText ());
    cancel.doClick ();
    assertEquals ("Cancel was invoked again on reused dialog.", cancel.getText (), ((JButton)dd.getValue ()).getText ());
    presenter.dispose ();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:55,代码来源:NbPresenterTest.java


注:本文中的javax.swing.JButton.doClick方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。