Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.BorderLayout;
- import java.awt.Dimension;
- import java.awt.EventQueue;
- import java.awt.Graphics;
- import java.awt.Graphics2D;
- import java.awt.GraphicsDevice;
- import java.awt.GraphicsEnvironment;
- import java.awt.Image;
- import java.awt.Rectangle;
- import java.awt.RenderingHints;
- import java.awt.Toolkit;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.awt.event.MouseAdapter;
- import java.awt.event.MouseEvent;
- import java.awt.geom.AffineTransform;
- import java.awt.image.BufferedImage;
- import java.io.File;
- import java.io.IOException;
- import java.net.URL;
- import java.sql.Date;
- import java.util.Calendar;
- import java.util.logging.Level;
- import java.util.logging.Logger;
- import javax.imageio.ImageIO;
- import javax.swing.ImageIcon;
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- import javax.swing.JPanel;
- import javax.swing.Timer;
- import javax.swing.border.EmptyBorder;
- public class main extends JFrame {
- private JPanel contentPane;
- public JLabel background;
- public JLabel background2;
- private Timer timer;
- private Timer timer2;
- private int counter = 2;
- private int counter2 = 2;
- private BufferedImage img;
- /**
- * Launch the application.
- */
- public static void main(String[] args) {
- EventQueue.invokeLater(new Runnable() {
- public void run() {
- try {
- main frame = new main();
- frame.setVisible(true);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- }
- /**
- * Create the frame.
- * @throws IOException
- */
- @SuppressWarnings("deprecation")
- public main() throws IOException {
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- contentPane = new JPanel();
- contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
- contentPane.setLayout(new BorderLayout(0, 0));
- final JLabel background = new JLabel(new ImageIcon("C:/Documents and Settings/All Users/Dokumenty/Moje obrazy/Przykładowe obrazy/Zima.jpg"));
- final JLabel background2 = new JLabel(new ImageIcon("C:/Documents and Settings/All Users/Dokumenty/Moje obrazy/Przykładowe obrazy/fds.jpg"));
- contentPane.addMouseListener(new MouseAdapter() {
- @Override
- public void mousePressed(MouseEvent arg0) {
- System.exit(0);
- }
- });
- final ActionListener action2 = new ActionListener()
- {
- public void actionPerformed(ActionEvent event)
- {
- if(counter2 == 0)
- {
- remove(background2);
- contentPane.repaint();
- }
- else
- {
- counter2--;
- System.out.printf("%d", counter2);
- }
- }
- };
- ActionListener action = new ActionListener()
- {
- @Override
- public void actionPerformed(ActionEvent event)
- {
- if(counter == 0)
- {
- remove(background);
- contentPane.repaint();
- getContentPane().add(background2);
- revalidate();
- timer2 = new Timer(1000, action2);
- timer2.setInitialDelay(0);
- timer2.start();
- }
- else
- {
- counter--;
- }
- }
- };
- setUndecorated(true);
- setContentPane(contentPane);
- setTitle("Game");
- GraphicsEnvironment graphicsEnvironment=GraphicsEnvironment.getLocalGraphicsEnvironment();
- Rectangle maximumWindowBounds=graphicsEnvironment.getMaximumWindowBounds();
- setBounds(maximumWindowBounds);
- background.setBounds(maximumWindowBounds);
- background.setSize( maximumWindowBounds.width, maximumWindowBounds.height);
- timer = new Timer(1000, action);
- timer.setInitialDelay(0);
- timer.start();
- getContentPane().add(background);
- revalidate();
- repaint();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement