Advertisement
martaczaska

Strona_tytulowa

Dec 14th, 2020
644
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.03 KB | None | 0 0
  1. package eti.radio.pr_inz;
  2.  
  3. import javax.imageio.ImageIO;
  4. import javax.swing.*;
  5. import java.awt.*;
  6. import java.awt.event.ActionEvent;
  7. import java.awt.event.ActionListener;
  8. import java.awt.image.BufferedImage;
  9. import java.io.File;
  10. import java.io.IOException;
  11. import javax.swing.JButton;
  12. import javax.swing.JPanel;
  13.  
  14. public class Strona_tytulowa extends JPanel implements ActionListener {
  15.  
  16.     private JLabel tytul1;
  17.     private JLabel tytul2;
  18.     private JLabel autor;
  19.     private JLabel promotor;
  20.     private JButton start;
  21.     private JButton wyjscie;
  22.     public BufferedImage tlo_str_tytulowa;
  23.  
  24.     public Strona_tytulowa(){
  25.         setLayout(null);
  26.         setVisible(false);
  27.  
  28.         File zdj_menu = new File("zdjecia/str_tytulowa.png");
  29.         try{ tlo_str_tytulowa = ImageIO.read(zdj_menu); }
  30.         catch(IOException e){ System.err.println("Blad odczytu obrazków"); }
  31.  
  32.         tytul1 = new JLabel( "\n Aplikacja do szacowania wpływu interferencji MAI na wartości SINR,", JLabel.CENTER);
  33.         tytul2 = new JLabel(" w kanale z zanikami powolnymi, dla systemu 5G Gigabit LTE.", JLabel.CENTER);
  34.         autor = new JLabel("Autor: Marta Trzaska", JLabel.CENTER);
  35.         promotor = new JLabel("Promotor: dr Sławomir Gajewski", JLabel.CENTER);
  36.         start = new JButton("Start");
  37.         wyjscie = new JButton("Wyjście");
  38.  
  39.         start.addActionListener(this);
  40.         wyjscie.addActionListener(this);
  41.  
  42.         tytul1.setSize(1000, 100);
  43.         tytul1.setLocation(5, 200);
  44.         //tytul.setBounds(200, 250, 1000, 200);
  45.         tytul1.setFont(new Font("Sitka Text", Font.BOLD, 25));
  46.  
  47.         tytul2.setSize(1000, 100);
  48.         tytul2.setLocation(5, 250);
  49.         //tytul.setBounds(200, 250, 1000, 200);
  50.         tytul2.setFont(new Font("Sitka Text", Font.BOLD, 25));
  51.  
  52.         autor.setSize(250, 100);
  53.         autor.setLocation(350, 580);
  54.         autor.setFont(new Font("Sitka Text", Font.BOLD, 20));
  55.  
  56.         promotor.setSize(350, 100);
  57.         promotor.setLocation(290, 600);
  58.         promotor.setFont(new Font("Sitka Text", Font.BOLD, 20));
  59.  
  60.         start.setBounds(320, 400, 300, 80);
  61.         start.setFont(new Font("Sitka Text", Font.BOLD, 35));
  62.         start.setBackground(Color.white);
  63.  
  64.         wyjscie.setBounds(320, 500, 300, 80);
  65.         wyjscie.setFont(new Font("Sitka Text", Font.BOLD, 35));
  66.         wyjscie.setBackground(Color.white);
  67.  
  68.         add(tytul1);
  69.         add(tytul2);
  70.         add(autor);
  71.         add(promotor);
  72.         add(start);
  73.         add(wyjscie);
  74.  
  75.     }
  76.  
  77.     public void actionPerformed(ActionEvent e){
  78.         Object source = e.getSource();
  79.         if(source == start) {
  80.             CardLayout CL =(CardLayout)(Main.noweOkno.karty.getLayout());
  81.             CL.show(Main.noweOkno.karty, "mapa_wybor");
  82.         }
  83.         else if(source == wyjscie){
  84.             System.exit(0);    //DZIAŁA, NAJS
  85.         }
  86.     }
  87.  
  88.     public void paintComponent(Graphics graphic) {
  89.         Graphics2D g2d = (Graphics2D) graphic;
  90.         g2d.drawImage(tlo_str_tytulowa, 0, 0, this);
  91.     }
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement