Skip to content

Instantly share code, notes, and snippets.

@AnnaBoro
Created January 4, 2016 19:15
Show Gist options
  • Save AnnaBoro/4c45080f8a4faeda70af to your computer and use it in GitHub Desktop.
Save AnnaBoro/4c45080f8a4faeda70af to your computer and use it in GitHub Desktop.
JFrame + text
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