ButtonFocus.java Source code

Java tutorial

Introduction

Here is the source code for ButtonFocus.java

Source

import java.awt.Container;
import java.awt.FlowLayout;

import javax.swing.JButton;
import javax.swing.JFrame;

public class ButtonFocus {
    public static void main(String args[]) {
        JFrame frame = new JFrame("Action Sample");

        JButton focusButton = new JButton("Focused");
        JButton notFocusButton = new JButton("Not Focused");

        Container contentPane = frame.getContentPane();
        contentPane.setLayout(new FlowLayout());
        contentPane.add(focusButton);
        contentPane.add(notFocusButton);
        frame.setSize(300, 100);
        frame.setVisible(true);
    }
}