mr_potato_head
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | mr_potato_head [2020/01/09 16:42] (current) – created frchris | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | **Mr Potato Head** | ||
+ | [[https:// | ||
+ | |||
+ | {{https:// | ||
+ | |||
+ | |||
+ | < | ||
+ | import java.awt.Color; | ||
+ | import java.awt.Font; | ||
+ | import java.awt.Graphics; | ||
+ | import javax.swing.JFrame; | ||
+ | import javax.swing.JPanel; | ||
+ | |||
+ | public class MyPotatoApplication extends JPanel | ||
+ | { | ||
+ | public static int WIDTH=800; | ||
+ | public static int HEIGHT=600; | ||
+ | private Font titleFont, regularFont; | ||
+ | |||
+ | public MyPotatoApplication() | ||
+ | { | ||
+ | |||
+ | // | ||
+ | titleFont = new Font(" | ||
+ | regularFont = new Font(" | ||
+ | |||
+ | } | ||
+ | |||
+ | public static void main(String[] args) { | ||
+ | MyPotatoApplication app= new MyPotatoApplication(); | ||
+ | JFrame window = new JFrame(" | ||
+ | window.setSize(WIDTH, | ||
+ | window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | ||
+ | window.getContentPane().add(app); | ||
+ | window.setVisible(true); | ||
+ | |||
+ | } | ||
+ | |||
+ | public void paintComponent(Graphics g){ | ||
+ | super.paintComponent(g); | ||
+ | g.setColor(Color.WHITE); | ||
+ | g.fillRect(0, | ||
+ | g.setColor(Color.BLUE); | ||
+ | g.setFont(titleFont); | ||
+ | g.drawString(" | ||
+ | g.setColor(Color.BLACK); | ||
+ | g.setFont(regularFont); | ||
+ | g.drawString(" | ||
+ | Potato p = new MrPotatoHead(g); | ||
+ | } | ||
+ | // update is a workaround to cure Windows screen flicker problem | ||
+ | public void update(Graphics g){ | ||
+ | paint(g); | ||
+ | } | ||
+ | |||
+ | } | ||
+ | </ |
mr_potato_head.txt · Last modified: 2020/01/09 16:42 by frchris