Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package g1;
- //import com.sun.pisces.Surface;
- import java.awt.Graphics;
- import java.awt.Graphics2D;
- import java.awt.EventQueue;
- import javax.swing.JPanel;
- import javax.swing.JFrame;
- class Surface extends JPanel{
- private void drawLine1(Graphics g){
- Graphics2D g2d = (Graphics2D)g.create();
- g2d.drawLine(100, 100, 500, 100);
- }
- @Override
- public void paintComponent(Graphics g){
- super.paintComponent(g);
- drawLine1(g);
- }
- }
- public class G1 extends JFrame{
- public G1(){
- initUI();
- }
- private void initUI(){
- add (new Surface());
- setTitle("testline1");
- setSize(480, 640);
- setLocationRelativeTo(null);
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- }
- public static void main(String[] args) {
- EventQueue.invokeLater(new Runnable() {
- @Override
- public void run() {
- //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- G1 gl = new G1();
- gl.setVisible(true);
- }
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement