Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package missil.command;
- import java.awt.BorderLayout;
- import java.awt.Color;
- import java.awt.Dimension;
- import java.awt.Graphics;
- import java.awt.GridBagConstraints;
- import java.awt.Image;
- import java.awt.Insets;
- import java.awt.event.MouseAdapter;
- import java.awt.event.MouseEvent;
- import java.awt.event.MouseListener;
- import java.io.IOException;
- import java.io.InputStream;
- import java.net.URL;
- import javax.imageio.ImageIO;
- import javax.swing.JButton;
- import javax.swing.JFrame;
- import javax.swing.JPanel;
- import javax.swing.JTextField;
- import missil.command.PantallaDeJuego.PanelDibujo;
- public class Reglas extends JFrame{
- private JButton home;
- private JButton siguiente;
- private String imagenRegla1= "recursos/reglas1.png";
- private String imagenRegla2= "recursos/reglas2.png";
- private boolean ok=false;
- private Image img1;
- private Image img2;
- public Reglas() {
- this.setLayout(new BorderLayout());
- this.setTitle("Reglas Del Juego");
- this.setSize(1024, 700);
- this.setLocationRelativeTo(null);
- home= new JButton("Atras");
- this.home.setVisible(true);
- this.add(this.home, BorderLayout.SOUTH);
- this.home.addMouseListener(new goBack());
- siguiente= new JButton("Siguiente");
- this.siguiente.addMouseListener(new Next());
- this.add(this.siguiente, BorderLayout.EAST);
- siguiente.setVisible(true);
- this.setVisible(true);
- this.setDefaultCloseOperation(EXIT_ON_CLOSE);
- }
- public class Next extends MouseAdapter{
- public void mouseClicked (MouseEvent arg0) {
- ok=true; // ok es para cuando se oprima el boton siguiente se ejecute la segunda parte del paint y se grafique la segunda imagen
- //siguiente.setEnabled(false);
- //siguiente.setVisible(false);
- siguiente.setVisible(false);
- repaint();
- }
- }
- public class goBack extends MouseAdapter {
- public void mouseClicked (MouseEvent arg0) {
- PantallaInicial pantalla = new PantallaInicial();
- dispose();
- }
- }
- URL regla1URL = getClass().getClassLoader().getResource(imagenRegla1);
- URL regla2URL = getClass().getClassLoader().getResource(imagenRegla2);
- public void paint (Graphics gr){
- if (imagenRegla1 == null)
- System.err.println("Couldn't find file: " + imagenRegla1);
- else{
- try {
- img1 = ImageIO.read(regla1URL);
- } catch (IOException ex) {
- ex.printStackTrace();
- }
- }
- gr.drawImage(img1, 50, 50, null);
- if (ok){
- if (imagenRegla2 == null)
- System.err.println("Couldn't find file: " + imagenRegla2);
- else{
- try {
- img2 = ImageIO.read(regla2URL);
- } catch (IOException ex) {
- ex.printStackTrace();
- }
- }
- gr.drawImage(img2, 50, 50, null);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement