//Simple NotHelloWorld with text and Buttons
import javax.swing.*;
import java.awt.*;
public class NotHelloWorld {
public static void main(String[] args) {
NotHelloWorldFrame
frame = new NotHelloWorldFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
//new class
mport javax.swing.*;
import java.awt.*;
public class NotHelloWorldFrame extends JFrame{
public NotHelloWorldFrame()
{
setTitle("NotHelloWorld");
setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);
//add panel to frame
NotHelloWorldPanel
panel = new NotHelloWorldPanel();
add(panel);
}
public static final int DEFAULT_WIDTH = 400;
public static final int DEFAULT_HEIGHT = 300;
}
//new class
public class NotHelloWorldPanel extends JPanel implements ActionListener{
private JButton clearButton;
public NotHelloWorldPanel(){
clearButton= new JButton("Clear");
setLayout(new BorderLayout());
add(clearButton, BorderLayout.SOUTH);
clearButton.addActionListener(this);
}
public void actionPerformed(ActionEvent event){
setForeground(Color.red);
//setBackground(Color.red);
}
public void paintComponent(Graphics g){
super.paintComponent(g);
//Think about where drawingString could be helpful
g.drawString("Not a
Hello World Program ", MESSAGE_X, MESSAGE_Y);
// Try different sizes both big and
small
public static final int MESSAGE_X = 75;
public static final int MESSAGE_Y = 100;
}