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


Java Button类代码示例

本文整理汇总了Java中java.awt.Button的典型用法代码示例。如果您正苦于以下问题:Java Button类的具体用法?Java Button怎么用?Java Button使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: InfrastructureBrowser

import java.awt.Button; //导入依赖的package包/类
public InfrastructureBrowser(final MainFrame frame, final String title) {
	super(frame);
	this.setName(title);
	setLayout(new BorderLayout());

	graphPanel = new InfrastructureGraphPanel(frame);
	add(graphPanel, BorderLayout.CENTER);

	Button refreshButton = new Button("Refresh");
	refreshButton.addActionListener(new ActionListener() {
		@Override
		public void actionPerformed(ActionEvent e) {
			loadInfrastructure();
		}
	});
	add(refreshButton, BorderLayout.SOUTH);

	service = new WebServiceHelper().getMonitoringService();

	SwingUtilities.invokeLater(new Runnable() {
		@Override
		public void run() {
			loadInfrastructure();
		}
	});
}
 
开发者ID:roscisz,项目名称:KernelHive,代码行数:27,代码来源:InfrastructureBrowser.java

示例2: init

import java.awt.Button; //导入依赖的package包/类
private void init(Component parent, String  title, String message,
                  String buttonText) {
    Panel p = new Panel();
    add("Center", new Label(message));
    Button btn = new Button(buttonText);
    btn.addActionListener(this);
    p.add(btn);
    add("South", p);
    pack();

    Dimension dDim = getSize();
    if (parent != null) {
        Rectangle fRect = parent.getBounds();
        setLocation(fRect.x + ((fRect.width - dDim.width) / 2),
                    fRect.y + ((fRect.height - dDim.height) / 2));
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:WPrinterJob.java

示例3: main

import java.awt.Button; //导入依赖的package包/类
public static void main(final String[] args) throws AWTException {
    final bug7097771 frame = new bug7097771();
    frame.setSize(300, 300);
    frame.setLocationRelativeTo(null);
    final Button button = new Button();
    button.addActionListener(frame);
    frame.add(button);
    frame.setVisible(true);
    sleep();
    frame.setEnabled(false);
    button.setEnabled(false);
    button.setEnabled(true);
    sleep();
    Util.clickOnComp(button, new Robot());
    sleep();
    frame.dispose();
    if (action) {
        throw new RuntimeException("Button is not disabled.");
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:21,代码来源:bug7097771.java

示例4: main

import java.awt.Button; //导入依赖的package包/类
public static void main(String args[]) throws Exception {
    Frame frame = new Frame("Frame Minimize Test");
    Button b = new Button("Focus ownder");
    frame.add("South", b);
    frame.pack();
    frame.setVisible(true);
    Util.waitForIdle(null);
    if (!b.hasFocus()) {
        throw new RuntimeException("button is not a focus owner after showing :(");
    }
    frame.setExtendedState(Frame.ICONIFIED);
    Util.waitForIdle(null);
    frame.setExtendedState(Frame.NORMAL);
    Util.waitForIdle(null);
    if (!b.hasFocus()) {
        throw new RuntimeException("button is not a focus owner after restoring :(");
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:19,代码来源:FrameMinimizeTest.java

示例5: init

import java.awt.Button; //导入依赖的package包/类
@Override
public void init() {
    if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) {
        Sysout.createDialogWithInstructions(new String[]{
                "Press PASS, this test is for MacOS X only."});
        return;
    }

    System.setProperty("apple.awt.use-file-dialog-packages", "true");

    setLayout(new GridLayout(1, 1));

    fd = new FileDialog(new Frame(), "Open");
    fd.setDirectory(APPLICATIONS_FOLDER);

    showBtn = new Button("Show File Dialog");
    showBtn.addActionListener(this);
    add(showBtn);
    String[] instructions = {
            "1) Click on 'Show File Dialog' button. A file dialog will come up.",
            "2) Navigate to the Applications folder if not already there",
            "3) Check that the application bundles can be selected and can not be navigated",
            "4) If it's true then the test passed, otherwise it failed."};
    Sysout.createDialogWithInstructions(instructions);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:26,代码来源:FileDialogForPackages.java

示例6: init

import java.awt.Button; //导入依赖的package包/类
private void init()
{
	f = new Frame("Demo");
	bt1 = new Button("SIN");
	bt2 = new Button("COS");
	bt3 = new Button("EXIT");
	mc = new MyCanvas();
	p = new Panel();
	
	
	f.setBounds(100, 100, 500, 500);
	f.setLayout(new BorderLayout());

	p.add(bt1);
	p.add(bt2);
	p.add(bt3);
	f.add(p, BorderLayout.NORTH);
	f.add(mc, BorderLayout.CENTER);
	
	addEvent();
	f.setVisible(true);
}
 
开发者ID:pwn-orz,项目名称:anti-fanmei,代码行数:23,代码来源:FunPlot.java

示例7: TestDialog

import java.awt.Button; //导入依赖的package包/类
public TestDialog(Frame frame, String name)    {
    super(frame, name);
    int scrollBoth = TextArea.SCROLLBARS_BOTH;
    instructionsText = new TextArea("", 15, maxStringLength, scrollBoth);
    add("North", instructionsText);

    messageText = new TextArea("", 5, maxStringLength, scrollBoth);
    add("Center", messageText);

    passB = new Button("pass");
    passB.setActionCommand("pass");
    passB.addActionListener(this);
    buttonP.add("East", passB);

    failB = new Button("fail");
    failB.setActionCommand("fail");
    failB.addActionListener(this);
    buttonP.add("West", failB);

    add("South", buttonP);
    pack();

    show();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:HighResTest.java

示例8: actionPerformed

import java.awt.Button; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent ae) {
    if (ae.getSource() instanceof Button) {
        Button btn = (Button) ae.getSource();
        switch (btn.getName()) {
            case "Pass":
                testPassed = true;
                isInterrupted = true;
                mainThread.interrupt();
                break;

            case "Fail":
                testPassed = false;
                isInterrupted = true;
                mainThread.interrupt();
                break;
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:UpdatePopupMenu.java

示例9: TestDialog

import java.awt.Button; //导入依赖的package包/类
public TestDialog( Frame frame, String name )
{
    super( frame, name );
    int scrollBoth = TextArea.SCROLLBARS_BOTH;
    instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
    add( "North", instructionsText );

    messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
    add("Center", messageText);

    passB = new Button( "pass" );
    passB.setActionCommand( "pass" );
    passB.addActionListener( this );
    buttonP.add( "East", passB );

    failB = new Button( "fail" );
    failB.setActionCommand( "fail" );
    failB.addActionListener( this );
    buttonP.add( "West", failB );

    add( "South", buttonP );
    pack();

    setVisible(true);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:DragEventSource.java

示例10: executeTest

import java.awt.Button; //导入依赖的package包/类
private void executeTest() {

        GraphicsDevice defDev = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
        int x = 0;
        Frame f = null;
        for (x = 0; x < gd.length; x ++) {
            if (gd[x] != defDev) {
                secFrame = new Frame("Screen " + x + " - secondary", gd[x].getDefaultConfiguration());
                f = secFrame;
            } else {
                primaryFrame = new Frame("Screen " + x + " - primary", gd[x].getDefaultConfiguration());
                f = primaryFrame;
            }
            Button b = new Button("Print");
            b.addActionListener(this);
            f.add("South", b);
            f.addWindowListener (new WindowAdapter() {
                public void windowClosing(WindowEvent we) {
                    ((Window) we.getSource()).dispose();
                }
            });
            f.setSize(200, 200);
            f.setVisible(true);
        }
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:MultiMonPrintDlgTest.java

示例11: main

import java.awt.Button; //导入依赖的package包/类
public static void main(final String[] args) throws AWTException {
    final bug7097771 frame = new bug7097771();
    frame.setSize(300, 300);
    frame.setLocationRelativeTo(null);
    final Button button = new Button();
    button.addActionListener(frame);
    frame.add(button);
    frame.setVisible(true);
    Robot robot = new Robot();
    sleep(robot);
    frame.setEnabled(false);
    button.setEnabled(false);
    button.setEnabled(true);
    sleep(robot);
    Util.clickOnComp(button, robot);
    sleep(robot);
    frame.dispose();
    if (action) {
        throw new RuntimeException("Button is not disabled.");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:bug7097771.java

示例12: constructTestUI

import java.awt.Button; //导入依赖的package包/类
private static void constructTestUI() {
    // here, create the items that will be tested for correct behavior
    HeavyComponent = new EventBug();
    Button b = (Button) HeavyComponent.add("Center", new Button("Heavy"));

    LightComponent = new EventBug();
    BorderedLabel b1 = (BorderedLabel) LightComponent.add("Center",
            new BorderedLabel("Lite"));

    HeavyComponent.addListeners(b);
    LightComponent.addListeners(b1);

    LightComponent.setLocation(200, 0);
    HeavyComponent.setVisible(true);
    LightComponent.setVisible(true);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:LightweightEventTest.java

示例13: performTest

import java.awt.Button; //导入依赖的package包/类
public void performTest() {
    int count = 0;
    Component comp = coftp.getFirstComponent(frame);
    String traversal = "";
    do {
        comp = coftp.getComponentAfter(frame, comp);
        if (comp instanceof Button) {
            traversal += ((Button)comp).getLabel();
        } else if (comp instanceof Frame) {
            traversal += ((Frame)comp).getTitle();
        }
        count++;
    } while(count < 3);

    if (!expectedTraversal.equals(traversal)) {
        dispose();
        throw new RuntimeException("Incorrect Traversal. Expected : "
            + expectedTraversal + "Actual : " + traversal);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:ContainerOrderFTPTest.java

示例14: actionPerformed

import java.awt.Button; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent ae) {
    if (ae.getSource() instanceof Button) {
        Button btn = (Button) ae.getSource();
        switch (btn.getName()) {
            case "Pass":
                testPassed = true;
                isInterrupted = true;
                mainThread.interrupt();
                break;

            case "Fail":
                testFailed("Dragging link from web browser Failed");
                break;
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:DragLinkFromBrowser.java

示例15: TestDialog

import java.awt.Button; //导入依赖的package包/类
public TestDialog(Frame frame, String name) {
    super(frame, name);
    int scrollBoth = TextArea.SCROLLBARS_BOTH;
    instructionsText = new TextArea("", 15, maxStringLength, scrollBoth);
    add("North", instructionsText);

    messageText = new TextArea("", 5, maxStringLength, scrollBoth);
    add("Center", messageText);

    buttonP = new Panel();
    passB = new Button("pass");
    passB.setActionCommand("pass");
    passB.addActionListener(this);
    buttonP.add("East", passB);

    failB = new Button("Fail");
    failB.setActionCommand("fail");
    failB.addActionListener(this);
    buttonP.add("West", failB);

    add("South", buttonP);
    pack();
    setVisible(true);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:ScrollSelectionTest.java


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