Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.*;
- import java.awt.*;
- import java.awt.geom.*;
- import java.awt.event.*;
- public class lineGUI{
- public static void main(String []args){
- Success s=new Success();
- s.setVisible(true);
- }
- }
- class CompFrame extends JFrame{
- public void paint(Graphics g) {
- super.paint(g);
- Graphics2D g2 = (Graphics2D) g;
- Line2D lin = new Line2D.Float(100, 100, 250, 260);
- g2.draw(lin);
- }
- }
- class Success extends JFrame{
- JPanel alas =new JPanel();
- JFrame comp =new CompFrame();
- public Success(){
- JPanel panel=new JPanel();
- getContentPane().add(panel);
- setSize(450,450);
- final JButton button =new JButton("press");
- panel.add(button);
- comp.setSize(650,500);
- comp.setTitle("View Report");
- JRootPane compPane=comp.getRootPane();
- Container contePane=compPane.getContentPane();
- contePane.add(alas);
- ActionListener action =new ActionListener(){
- public void actionPerformed(ActionEvent e){
- if (e.getSource()==button){
- comp.setVisible(true);
- }
- }
- };
- button.addActionListener(action);
- JButton button2=new JButton("access");
- alas.add(button2);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement