import javax.swing.JFrame; import javax.swing.JButton; import javax.swing.border.BevelBorder; import java.awt.Toolkit; import java.awt.Dimension; import java.awt.Color; import java.awt.Cursor; import java.awt.Container; import java.awt.Font; public class TryWindow4 { // The window object static JFrame aWindow = new JFrame("This is the Window Title"); public static void main(String[] args) { Toolkit theKit = aWindow.getToolkit(); // Get the window toolkit Dimension wndSize = theKit.getScreenSize(); // Get screen size // Set the position to screen center & size to half screen size aWindow.setBounds(wndSize.width/4, wndSize.height/4, // Position wndSize.width/2, wndSize.height/2); // Size aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); aWindow.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); Container thePane = aWindow.getContentPane(); // Get content pane // Set color of content pane Color customColor = new Color(25,50,75); thePane.setBackground(customColor); // Add a button JButton button = new JButton("Click Me"); button.setFont(new Font("Blackadder ITC", Font.BOLD, 32)); button.setBorder(new BevelBorder(BevelBorder.RAISED)); thePane.add(button ); aWindow.setVisible(true); // Display the window } }