SHARE
TWEET

Untitled

a guest Nov 18th, 2019 90 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package projekt;
  2.  
  3. import java.awt.*;
  4.  
  5.  
  6. import javax.swing.JFrame;
  7. import javax.swing.JPanel;
  8. import javax.swing.JLabel;
  9.  
  10. import java.io.File;
  11. import java.io.IOException;
  12.  
  13. import javax.swing.JButton;
  14. import javax.swing.JComponent;
  15. import javax.imageio.ImageIO;
  16. import javax.swing.ImageIcon;
  17. /**
  18.  * Klasa wczytująca ekran główny
  19.  * @author Damian Kołakowski Dawid Nastaj
  20.  */
  21.  
  22. public class ramka extends JFrame {
  23.  
  24.     /**
  25.      * Launch the application.
  26.      * @param args command arguments
  27.      */
  28.     public static void main(String[] args) {
  29.         new parsujaca();
  30.         EventQueue.invokeLater(new Runnable() {
  31.             public void run() {
  32.                 try {
  33.                     ramka frame = new ramka();
  34.                     frame.setVisible(true);
  35.                 } catch (Exception e) {
  36.                     e.printStackTrace();
  37.                 }
  38.             }
  39.         });
  40.     }
  41.  
  42.     /**
  43.      * Create the frame.
  44.      */
  45.  
  46.     public ramka() {
  47.         setSize(parsujaca.getPoczatkowaSzerokoscPlanszy(), parsujaca.getPoczatkowaWysokoscPlanszy());
  48.         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  49.        
  50.         JPanel panel = new JPanel();
  51.         getContentPane().add(panel, BorderLayout.EAST);
  52.         GridBagLayout gbl_panel = new GridBagLayout();
  53.         gbl_panel.columnWidths = new int[]{53, 0};
  54.         gbl_panel.rowHeights = new int[]{14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
  55.         gbl_panel.columnWeights = new double[]{0.0, Double.MIN_VALUE};
  56.         gbl_panel.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
  57.         panel.setLayout(gbl_panel);
  58.        
  59.         JLabel lblNewLabel = new JLabel("ilość paliwa");
  60.         GridBagConstraints gbc_lblNewLabel = new GridBagConstraints();
  61.         gbc_lblNewLabel.insets = new Insets(0, 0, 5, 0);
  62.         gbc_lblNewLabel.anchor = GridBagConstraints.NORTH;
  63.         gbc_lblNewLabel.gridx = 0;
  64.         gbc_lblNewLabel.gridy = 0;
  65.         panel.add(lblNewLabel, gbc_lblNewLabel);
  66.        
  67.         JLabel lblCo = new JLabel("cos");
  68.         GridBagConstraints gbc_lblCo = new GridBagConstraints();
  69.         gbc_lblCo.insets = new Insets(0, 0, 5, 0);
  70.         gbc_lblCo.gridx = 0;
  71.         gbc_lblCo.gridy = 1;
  72.         panel.add(lblCo, gbc_lblCo);
  73.        
  74.         JLabel lblPoziom = new JLabel("poziom");
  75.         GridBagConstraints gbc_lblPoziom = new GridBagConstraints();
  76.         gbc_lblPoziom.insets = new Insets(0, 0, 5, 0);
  77.         gbc_lblPoziom.gridx = 0;
  78.         gbc_lblPoziom.gridy = 2;
  79.         panel.add(lblPoziom, gbc_lblPoziom);
  80.        
  81.         JLabel lblTrudno = new JLabel("trudno");
  82.         GridBagConstraints gbc_lblTrudno = new GridBagConstraints();
  83.         gbc_lblTrudno.insets = new Insets(0, 0, 5, 0);
  84.         gbc_lblTrudno.gridx = 0;
  85.         gbc_lblTrudno.gridy = 3;
  86.         panel.add(lblTrudno, gbc_lblTrudno);
  87.        
  88.         JLabel lblWynik = new JLabel("wynik:");
  89.         GridBagConstraints gbc_lblWynik = new GridBagConstraints();
  90.         gbc_lblWynik.insets = new Insets(0, 0, 5, 0);
  91.         gbc_lblWynik.gridx = 0;
  92.         gbc_lblWynik.gridy = 4;
  93.         panel.add(lblWynik, gbc_lblWynik);
  94.        
  95.         JLabel label = new JLabel("12454");
  96.         GridBagConstraints gbc_label = new GridBagConstraints();
  97.         gbc_label.insets = new Insets(0, 0, 5, 0);
  98.         gbc_label.gridx = 0;
  99.         gbc_label.gridy = 5;
  100.         panel.add(label, gbc_label);
  101.        
  102.         JButton btnGra = new JButton("GRA");
  103.         GridBagConstraints gbc_btnGra = new GridBagConstraints();
  104.         gbc_btnGra.fill = GridBagConstraints.HORIZONTAL;
  105.         gbc_btnGra.insets = new Insets(0, 0, 5, 0);
  106.         gbc_btnGra.gridx = 0;
  107.         gbc_btnGra.gridy = 7;
  108.         panel.add(btnGra, gbc_btnGra);
  109.        
  110.         JButton btnPomoc = new JButton("POMOC");
  111.         GridBagConstraints gbc_btnPomoc = new GridBagConstraints();
  112.         gbc_btnPomoc.fill = GridBagConstraints.HORIZONTAL;
  113.         gbc_btnPomoc.insets = new Insets(0, 0, 5, 0);
  114.         gbc_btnPomoc.gridx = 0;
  115.         gbc_btnPomoc.gridy = 8;
  116.         panel.add(btnPomoc, gbc_btnPomoc);
  117.        
  118.         JButton btnRanking = new JButton("RANKING");
  119.         GridBagConstraints gbc_btnRanking = new GridBagConstraints();
  120.         gbc_btnRanking.fill = GridBagConstraints.HORIZONTAL;
  121.         gbc_btnRanking.insets = new Insets(0, 0, 5, 0);
  122.         gbc_btnRanking.gridx = 0;
  123.         gbc_btnRanking.gridy = 9;
  124.         panel.add(btnRanking, gbc_btnRanking);
  125.        
  126.         JButton btnKoniec = new JButton("KONIEC");
  127.         GridBagConstraints gbc_btnKoniec = new GridBagConstraints();
  128.         gbc_btnKoniec.fill = GridBagConstraints.HORIZONTAL;
  129.         gbc_btnKoniec.gridx = 0;
  130.         gbc_btnKoniec.gridy = 10;
  131.         panel.add(btnKoniec, gbc_btnKoniec);
  132.        
  133.         dodatek panel_1 = new dodatek();
  134.  
  135.                
  136.        
  137.         getContentPane().add(panel_1, BorderLayout.CENTER);
  138.        
  139.                
  140.    
  141.        
  142.        
  143.  
  144.  
  145.  
  146.     }
  147.  
  148.     class dodatek extends JPanel{
  149.        
  150.         Image image;
  151.         private final String pic ="./obrazki/"+ parsujaca.getTlo();
  152.  
  153.         public dodatek() {
  154.             image = new ImageIcon(pic).getImage();
  155.         }
  156.  
  157.         @Override
  158.         public void paintComponent(Graphics g) {
  159.             Graphics2D g2 = (Graphics2D) g;
  160.             g2.drawImage(image, 0, 0, getWidth(), getHeight(), this);
  161.         }
  162.  
  163.  
  164.     }
  165.  
  166.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top