Created
January 4, 2016 19:15
-
-
Save AnnaBoro/4c45080f8a4faeda70af to your computer and use it in GitHub Desktop.
JFrame + text
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package lesson5_8; | |
import javax.swing.*; | |
import java.awt.*; | |
public class JJFrame extends JPanel{ | |
public static void main(String[] args) { | |
new JJFrame(); | |
} | |
public JJFrame() { | |
JFrame f = new JFrame("Day5_8"); | |
f.setMinimumSize(new Dimension(800, 600)); | |
f.setLocation(300, 100); | |
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | |
f.getContentPane().add(this); | |
f.pack(); | |
f.setVisible(true); | |
} | |
@Override | |
protected void paintComponent(Graphics g) { | |
super.paintComponent(g); | |
this.setBackground(Color.CYAN); | |
g.setFont(new Font("SansSerif", Font.BOLD, 14)); | |
g.drawString("Hello", 100, 100); | |
g.setFont(new Font("Dialog", Font.ITALIC, 18)); | |
g.drawString("Hello", 150, 110); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment