Program to demonstrate adding of Button to a Frame
package com.hubberspot.awtSwing.example; import java.awt.FlowLayout; import javax.swing.*; public class AddButtonToFrame { JFrame frame; JButton button; AddButtonToFrame() { frame = new JFrame("Welcome to HubberSpot Frame"); button = new JButton("Click Me!"); frame.setSize(200,100); frame.setLayout(new FlowLayout()); frame.add(button); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } public static void main(String[] args) { new AddButtonToFrame(); } }Output of the program :