Advertisement
Guest User

lineGUI.java

a guest
May 26th, 2012
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.14 KB | None | 0 0
  1. import javax.swing.*;
  2. import java.awt.*;
  3. import java.awt.geom.*;
  4. import java.awt.event.*;
  5.  
  6. public class lineGUI{
  7.     public static void main(String []args){
  8.     Success s=new Success();
  9.     s.setVisible(true);
  10.     }
  11. }
  12.  
  13. class CompFrame extends JFrame{
  14.     public void paint(Graphics g) {
  15.     super.paint(g);
  16.     Graphics2D g2 = (Graphics2D) g;
  17.     Line2D lin = new Line2D.Float(100, 100, 250, 260);
  18.     g2.draw(lin);
  19.     }
  20. }
  21.  
  22. class Success extends JFrame{
  23.  
  24.     JPanel alas =new JPanel();
  25.     JFrame comp =new CompFrame();
  26.     public Success(){
  27.     JPanel panel=new JPanel();
  28.     getContentPane().add(panel);
  29.     setSize(450,450);
  30.  
  31.     final JButton button =new JButton("press");
  32.     panel.add(button);
  33.  
  34.     comp.setSize(650,500);
  35.     comp.setTitle("View Report");
  36.  
  37.     JRootPane compPane=comp.getRootPane();
  38.     Container contePane=compPane.getContentPane();
  39.     contePane.add(alas);
  40.  
  41.  
  42.     ActionListener action =new ActionListener(){
  43.         public void actionPerformed(ActionEvent e){
  44.             if (e.getSource()==button){
  45.             comp.setVisible(true);
  46.             }
  47.         }
  48.         };
  49.     button.addActionListener(action);
  50.  
  51.     JButton button2=new JButton("access");
  52.     alas.add(button2);
  53.     }
  54.  
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement