martaczaska

inż_str_tytulowa

Nov 10th, 2020
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.00 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.  
  27.         File zdj_menu = new File("zdjecia/str_tytulowa.png");
  28.         try{ tlo_str_tytulowa = ImageIO.read(zdj_menu); }
  29.         catch(IOException e){ System.err.println("Blad odczytu obrazków"); }
  30.  
  31.         tytul1 = new JLabel( "\n Aplikacja do szacowania wpływu interferencji MAI na wartości SINR,", JLabel.CENTER);
  32.         tytul2 = new JLabel(" w kanale z zanikami powolnymi, dla systemu 5G Gigabit LTE.", JLabel.CENTER);
  33.         autor = new JLabel("Autor: Marta Trzaska", JLabel.CENTER);
  34.         promotor = new JLabel("Promotor: dr Sławomir Gajewski", JLabel.CENTER);
  35.         start = new JButton("Start");
  36.         wyjscie = new JButton("Wyjście");
  37.  
  38.         start.addActionListener(this);
  39.         wyjscie.addActionListener(this);
  40.  
  41.         tytul1.setSize(1000, 100);
  42.         tytul1.setLocation(5, 200);
  43.         //tytul.setBounds(200, 250, 1000, 200);
  44.         tytul1.setFont(new Font("Sitka Text", Font.BOLD, 25));
  45.  
  46.         tytul2.setSize(1000, 100);
  47.         tytul2.setLocation(5, 250);
  48.         //tytul.setBounds(200, 250, 1000, 200);
  49.         tytul2.setFont(new Font("Sitka Text", Font.BOLD, 25));
  50.  
  51.         autor.setSize(250, 100);
  52.         autor.setLocation(350, 580);
  53.         autor.setFont(new Font("Sitka Text", Font.BOLD, 20));
  54.  
  55.         promotor.setSize(350, 100);
  56.         promotor.setLocation(290, 600);
  57.         promotor.setFont(new Font("Sitka Text", Font.BOLD, 20));
  58.  
  59.         start.setBounds(320, 400, 300, 80);
  60.         start.setFont(new Font("Sitka Text", Font.BOLD, 35));
  61.         start.setBackground(Color.white);
  62.  
  63.         wyjscie.setBounds(320, 500, 300, 80);
  64.         wyjscie.setFont(new Font("Sitka Text", Font.BOLD, 35));
  65.         wyjscie.setBackground(Color.white);
  66.  
  67.         add(tytul1);
  68.         add(tytul2);
  69.         add(autor);
  70.         add(promotor);
  71.         add(start);
  72.         add(wyjscie);
  73.  
  74.     }
  75.  
  76.     public void actionPerformed(ActionEvent e){
  77.         Object source = e.getSource();
  78.         if(source == start) {
  79.             CardLayout CL =(CardLayout)(Main.noweOkno.karty.getLayout());
  80.             CL.show(Main.noweOkno.karty, "mapa_wybor");
  81.         }
  82.         else if(source == wyjscie){
  83.             System.exit(0);    //DZIAŁA, NAJS
  84.         }
  85.     }
  86.  
  87.     public void paintComponent(Graphics graphic) {
  88.         Graphics2D g2d = (Graphics2D) graphic;
  89.         g2d.drawImage(tlo_str_tytulowa, 0, 0, this);
  90.     }
  91.  
  92. }
Add Comment
Please, Sign In to add comment