Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package projekt;
- import java.awt.*;
- import javax.swing.JFrame;
- import javax.swing.JPanel;
- import javax.swing.JLabel;
- import java.io.File;
- import java.io.IOException;
- import javax.swing.JButton;
- import javax.swing.JComponent;
- import javax.imageio.ImageIO;
- import javax.swing.ImageIcon;
- /**
- * Klasa wczytująca ekran główny
- * @author Damian Kołakowski Dawid Nastaj
- */
- public class ramka extends JFrame {
- /**
- * Launch the application.
- * @param args command arguments
- */
- public static void main(String[] args) {
- new parsujaca();
- EventQueue.invokeLater(new Runnable() {
- public void run() {
- try {
- ramka frame = new ramka();
- frame.setVisible(true);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- }
- /**
- * Create the frame.
- */
- public ramka() {
- setSize(parsujaca.getPoczatkowaSzerokoscPlanszy(), parsujaca.getPoczatkowaWysokoscPlanszy());
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- JPanel panel = new JPanel();
- getContentPane().add(panel, BorderLayout.EAST);
- GridBagLayout gbl_panel = new GridBagLayout();
- gbl_panel.columnWidths = new int[]{53, 0};
- gbl_panel.rowHeights = new int[]{14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- gbl_panel.columnWeights = new double[]{0.0, Double.MIN_VALUE};
- 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};
- panel.setLayout(gbl_panel);
- JLabel lblNewLabel = new JLabel("ilość paliwa");
- GridBagConstraints gbc_lblNewLabel = new GridBagConstraints();
- gbc_lblNewLabel.insets = new Insets(0, 0, 5, 0);
- gbc_lblNewLabel.anchor = GridBagConstraints.NORTH;
- gbc_lblNewLabel.gridx = 0;
- gbc_lblNewLabel.gridy = 0;
- panel.add(lblNewLabel, gbc_lblNewLabel);
- JLabel lblCo = new JLabel("cos");
- GridBagConstraints gbc_lblCo = new GridBagConstraints();
- gbc_lblCo.insets = new Insets(0, 0, 5, 0);
- gbc_lblCo.gridx = 0;
- gbc_lblCo.gridy = 1;
- panel.add(lblCo, gbc_lblCo);
- JLabel lblPoziom = new JLabel("poziom");
- GridBagConstraints gbc_lblPoziom = new GridBagConstraints();
- gbc_lblPoziom.insets = new Insets(0, 0, 5, 0);
- gbc_lblPoziom.gridx = 0;
- gbc_lblPoziom.gridy = 2;
- panel.add(lblPoziom, gbc_lblPoziom);
- JLabel lblTrudno = new JLabel("trudno");
- GridBagConstraints gbc_lblTrudno = new GridBagConstraints();
- gbc_lblTrudno.insets = new Insets(0, 0, 5, 0);
- gbc_lblTrudno.gridx = 0;
- gbc_lblTrudno.gridy = 3;
- panel.add(lblTrudno, gbc_lblTrudno);
- JLabel lblWynik = new JLabel("wynik:");
- GridBagConstraints gbc_lblWynik = new GridBagConstraints();
- gbc_lblWynik.insets = new Insets(0, 0, 5, 0);
- gbc_lblWynik.gridx = 0;
- gbc_lblWynik.gridy = 4;
- panel.add(lblWynik, gbc_lblWynik);
- JLabel label = new JLabel("12454");
- GridBagConstraints gbc_label = new GridBagConstraints();
- gbc_label.insets = new Insets(0, 0, 5, 0);
- gbc_label.gridx = 0;
- gbc_label.gridy = 5;
- panel.add(label, gbc_label);
- JButton btnGra = new JButton("GRA");
- GridBagConstraints gbc_btnGra = new GridBagConstraints();
- gbc_btnGra.fill = GridBagConstraints.HORIZONTAL;
- gbc_btnGra.insets = new Insets(0, 0, 5, 0);
- gbc_btnGra.gridx = 0;
- gbc_btnGra.gridy = 7;
- panel.add(btnGra, gbc_btnGra);
- JButton btnPomoc = new JButton("POMOC");
- GridBagConstraints gbc_btnPomoc = new GridBagConstraints();
- gbc_btnPomoc.fill = GridBagConstraints.HORIZONTAL;
- gbc_btnPomoc.insets = new Insets(0, 0, 5, 0);
- gbc_btnPomoc.gridx = 0;
- gbc_btnPomoc.gridy = 8;
- panel.add(btnPomoc, gbc_btnPomoc);
- JButton btnRanking = new JButton("RANKING");
- GridBagConstraints gbc_btnRanking = new GridBagConstraints();
- gbc_btnRanking.fill = GridBagConstraints.HORIZONTAL;
- gbc_btnRanking.insets = new Insets(0, 0, 5, 0);
- gbc_btnRanking.gridx = 0;
- gbc_btnRanking.gridy = 9;
- panel.add(btnRanking, gbc_btnRanking);
- JButton btnKoniec = new JButton("KONIEC");
- GridBagConstraints gbc_btnKoniec = new GridBagConstraints();
- gbc_btnKoniec.fill = GridBagConstraints.HORIZONTAL;
- gbc_btnKoniec.gridx = 0;
- gbc_btnKoniec.gridy = 10;
- panel.add(btnKoniec, gbc_btnKoniec);
- dodatek panel_1 = new dodatek();
- getContentPane().add(panel_1, BorderLayout.CENTER);
- }
- class dodatek extends JPanel{
- Image image;
- private final String pic ="./obrazki/"+ parsujaca.getTlo();
- public dodatek() {
- image = new ImageIcon(pic).getImage();
- }
- @Override
- public void paintComponent(Graphics g) {
- Graphics2D g2 = (Graphics2D) g;
- g2.drawImage(image, 0, 0, getWidth(), getHeight(), this);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement