Java 8 Button - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 Button class.

This code example shows how to use the following methods:addActionListener, setLabel, setBounds
 
		setLayout(null);
 
		textMessage = new TextField();
		label = new AWTLabel(message);
		button = new Button();
 
		textMessage.setText("");
		textMessage.setFont(GraphicsUtils.getFont("黑体", 0, 25));
		textMessage.setBounds(30, 60, 270, 40);
		add(textMessage);
		textMessage.addActionListener(this);
		 
		label.setBounds(25, 30, 360, 22);
		label.setFont(GraphicsUtils.getFont("黑体", 0, 15));
		add(label);
 
		button.setLabel(" 确定输入 ");
		button.setBounds(310, 60, 80, 40);
		add(button);

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:addActionListener, setFont, setLocation, setSize
 
 
 
public class UserInfoDialog extends Dialog implements ActionListener {
 
    final Button              ok=new Button("OK");
    final Label               l=new Label("Name: ");
    final TextField           name=new TextField("");
    private final Font  default_font=new Font("Helvetica",Font.PLAIN,12);
     
 
    public UserInfoDialog(Frame parent) {
	super(parent, "Input", true);
	setLayout(null);
 
	l.setFont(default_font);
	l.setSize(50, 30);
	l.setLocation(30, 50);
 
	name.setFont(default_font);

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:addActionListener, setActionCommand, setFocusable, setFont
This code example shows how to use the following methods:addActionListener, addKeyListener, requestFocus
 
        add(new Panel());
        add(new Panel());
        add(new Panel());
 
        add(quit = new Button(QUIT_LABEL));
        quit.addActionListener(this);
        quit.addKeyListener(this);
 
        add(cancel = new Button(CANCEL_LABEL));
        cancel.addActionListener(this);
        cancel.addKeyListener(this);
 
        pack();
        final int width = getSize().width; // getWidth();
        final int height = getSize().height; // getHeight();
        final Dimension screen = owner.getSize();
        final Point point = owner.getLocation();
 
        final int x = point.x + (screen.width / 2) - (width / 2);

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:addActionListener, setFont, setForeground
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:addActionListener, addKeyListener
Panel panel = new Panel();
		panel.setLayout(new FlowLayout(FlowLayout.CENTER, 15, 15));
		panel.add(label);
		this.add("Center", panel);
		button = new Button("  确定  ");
		button.addActionListener(this);
		button.addKeyListener(this);
		panel = new Panel();
		panel.setLayout(new FlowLayout());
		panel.add(button);
		this.add("South", panel);
		this.setResizable(false);
		this.pack();
		LSystem.centerOn(this);
		this.addWindowListener(this);
		this.setModal(true);
	} 
 
	public void actionPerformed(ActionEvent e) {
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:addActionListener, setBackground, setForeground
       p.add( new Label( "do you want to", Label.CENTER  ) ) ;
       Panel yesNo = new Panel( new GridLayout(1,2) ) ;
 
       yesNo.add( _acceptButton = new Button( "Accept it" ) ) ;
       _acceptButton.setBackground( Color.green ) ;
       yesNo.add( _rejectButton = new Button( "Reject it" ) ) ;
       _rejectButton.setBackground( Color.red ) ;
       _rejectButton.setForeground( Color.white ) ;
//       p.validateTree() ; 
       p.add( yesNo ) ;
       p.doLayout();
       doLayout(); 
 
       add( new BorderPanel( p ) ) ;
       _acceptButton.addActionListener( this ) ;
       _rejectButton.addActionListener( this ) ;
   } 
   public void setFingerPrint( String host , String fp ){
       _hostLabel.setText( host ) ;
       _fingerprintLabel.setText( fp ) ;
       System.out.println( "Enforcing layout" ) ;
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:addActionListener, setBackground
                System.out.println("Test Passed");
                f.dispose();
            } 
        }); 
        p.add(b);
        b = new Button("Test Failed");
        b.setBackground(Color.red);
        b.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                System.out.println("Test FAILED");
                f.dispose();
                throw new RuntimeException("Test FAILED");
            } 
        }); 
        p.add(b);
        f.add("South", p);
 
        f.pack();
        f.setVisible(true);
    } 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:addActionListener, setFont
     
 
    public MessageDialog(Frame parent, String sender, String msg) {
	super(parent, "Msg from " + sender);
 
	Button ok=new Button("OK");
 
	setLayout(new BorderLayout());
	setBackground(Color.white);
 
	ok.setFont(default_font);
	text.setFont(default_font);
	text.setEditable(false);
	text.setText(msg);
 
	ok.addActionListener(this);
	 
	add("Center", text);
	add("South", ok);
	 
	setSize(300, 150);
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:sleep
 
        final Container c = new Container();
        c.setLayout(new BorderLayout());
        c.add(new Button("north"), BorderLayout.NORTH);
        c.add(new Button("south"), BorderLayout.SOUTH);
        c.add(new Button("east"), BorderLayout.EAST);
        c.add(new Button("west"), BorderLayout.WEST);
        c.add(comp, BorderLayout.CENTER);
 
        f.setLayout(new BorderLayout());
        f.add(new Button("NORTH"), BorderLayout.NORTH);
        f.add(new Button("SOUTH"), BorderLayout.SOUTH);
        f.add(new Button("EAST"), BorderLayout.EAST);
        f.add(new Button("WEST"), BorderLayout.WEST);
        f.add(c, BorderLayout.CENTER);
 
        javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
            public void run() { 
                f.pack();
                f.validate();

5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
See Code Examples for Java 8 Button Methods: