Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Dimension;
- import java.awt.Toolkit;
- import java.awt.event.*;
- import java.awt.*;
- import javax.swing.*;
- public class pruebalaptop extends JFrame implements ActionListener{
- private JLabel label;
- private JButton boton, boton2;
- private lap2 f = new lap2();
- private lap3 g = new lap3();
- public pruebalaptop (){
- super("Example_Class");
- this.setSize(450, 200);
- centrarventana();
- this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- this.setResizable(true);
- this.setLayout(null);
- creargui();
- }
- private void creargui (){
- label = new JLabel("Bienvenido selecciona un boton");
- boton = new JButton("Crear objetos laptop");
- boton2 = new JButton("Modificar objetos laptop");
- this.add(label);
- label.setBounds(140, 40, 200, 25);
- this.add(boton);
- boton.setBounds(10, 90, 200, 25);
- this.add(boton2);
- boton2.setBounds(230, 90, 200, 25);
- boton.addActionListener(this);
- boton2.addActionListener(this);
- }
- private void centrarventana (){
- Dimension pantalla = Toolkit.getDefaultToolkit().getScreenSize();
- Dimension ventana = getSize();
- setLocation((pantalla.width - ventana.width) /2, (pantalla.height - ventana.height) /2);
- }
- public static void main(String[] args) {
- pruebalaptop vp = new pruebalaptop();
- vp.setVisible(true);
- }
- public void actionPerformed(ActionEvent e) {
- if (e.getSource() == boton)
- f.setVisible(true);
- else if (e.getSource() == boton2)
- g.setVisible(true);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement