Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.*;
- import java.awt.*;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- public class MojeOkno extends JFrame {
- private JButton button;
- private JLabel jLabel;
- private Point point;
- MojeOkno()
- {
- super("Okno");
- this.setLayout(new FlowLayout());
- button = new JButton();
- button.setSize(100,100);
- button.setText("Elo witam");
- point = new Point();
- button.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- System.out.println("elo tutaj po kliknieciu buttona");
- }
- });
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- setSize(800,800);
- this.add(button);
- this.add(point);
- setVisible(true);
- }
- }
- import java.awt.*;
- public class Main {
- public static void main(String[] args) {
- EventQueue.invokeLater(new Runnable() {
- @Override
- public void run() {
- new MojeOkno();
- }
- });
- }
- }
- import java.awt.Color;
- import java.awt.Dimension;
- import java.awt.Graphics;
- import java.awt.Graphics2D;
- import java.util.Random;
- import javax.swing.JPanel;
- public class Point extends JPanel {
- public Point() {
- setPreferredSize(new Dimension(200, 200));
- }
- @Override
- public void paintComponent(Graphics g) {
- super.paintComponent(g);
- Graphics2D g2d = (Graphics2D) g;
- g2d.setColor(Color.red);
- g2d.fillRect(100,100,10,10);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement