Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.*;
- import java.awt.*;
- import java.awt.event.*;
- import java.util.*;
- import java.awt.Dimension;
- import java.io.*;
- public class odtwarzacz {
- public static void main (String[] args) {
- JFrame oknoGlowne = new JFrame("Okno glowne programu");
- oknoGlowne.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- oknoGlowne.setPreferredSize(new Dimension(600, 400));
- oknoGlowne.setResizable(false);
- oknoGlowne.setVisible(true);
- oknoGlowne.pack();
- /*GridBagConstraints layout = new GridBagConstraints();
- layout.insets = new Insets(0,0,0,0);
- layout.gridx = 0;
- layout.gridy = 0;*/
- GridBagConstraints c = new GridBagConstraints();
- oknoGlowne.setLayout(new GridLayout(2, 1));
- JPanel gorny = new JPanel(new GridBagLayout());
- gorny.setBackground(Color.green);
- gorny.setPreferredSize(new Dimension(600, 150));
- oknoGlowne.add(gorny);
- JPanel panel = new JPanel(new GridBagLayout());
- //panel.setPreferredSize(new Dimension(600, 100));
- JButton b1 = new JButton("Przycisk PLAY");
- JButton b2 = new JButton("Przycisk PAUZA");
- JButton b3 = new JButton("Przycisk STOP");
- GridBagConstraints layout = new GridBagConstraints();
- layout.insets = new Insets(0, 10, 5, 0);
- layout.anchor = GridBagConstraints.SOUTH;
- layout.weighty = 1;
- //b1.setBorder(javax.swing.BorderFactory.createLineBorder(Color.BLUE, 1));
- panel.add(b1, layout);
- panel.add(b2, layout);
- panel.add(b3, layout);
- oknoGlowne.add(panel);
- panel.setBackground(Color.blue);
- b1.setBackground(Color.green);
- //b1.setPreferredSize(new Dimension(140, 30));
- b2.setBackground(Color.yellow);
- b2.setVisible(false);
- b3.setBackground(Color.red);
- //b1.setVisible(false);
- b1.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e)
- {
- //Execute when button is pressed
- b1.setVisible(false);
- b2.setVisible(true);
- System.out.println("Nacisnales play");
- }
- });
- b2.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e)
- {
- //Execute when button is pressed
- b1.setVisible(true);
- b2.setVisible(false);
- System.out.println("nacisnales pauza");
- }
- });
- b3.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e)
- {
- //Execute when button is pressed
- b1.setVisible(true);
- b2.setVisible(false);
- System.out.println("nacisnales stop");
- }
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment