import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import java.awt.Panel;
import java.awt.Canvas;
import java.awt.Color;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class Frame1 {
int x=0,y=0;
private JFrame frame;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Frame1 window = new Frame1();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the application.
*/
public Frame1() {
initialize();
}
/**
* Initialize the contents of the frame.
*/
private void initialize() {
frame = new JFrame();
frame.setBounds(0, 0, 1024, 720);
frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null);
JButton opcja1 = new JButton("opcja1");
opcja1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
x=34;
y=41;
Canvas oznaczenie = new Canvas();
oznaczenie.setEnabled(true);
oznaczenie.setBackground(Color.ORANGE);
oznaczenie.setBounds(x, y, 357, 111);
frame.getContentPane().add(oznaczenie);
}
});
opcja1.setBounds(34, 41, 201, 81);
frame.getContentPane().add(opcja1);
Canvas canvas = new Canvas();
canvas.setBackground(Color.PINK);
canvas.setBounds(10, 10, 239, 817);
frame.getContentPane().add(canvas);
Canvas canvas_1 = new Canvas();
canvas_1.setBackground(Color.GREEN);
canvas_1.setBounds(262, 10, 583, 817);
frame.getContentPane().add(canvas_1);
Canvas canvas_2 = new Canvas();
canvas_2.setBackground(Color.CYAN);
canvas_2.setBounds(884, 10, 702, 817);
frame.getContentPane().add(canvas_2);
}
}
Sorry zapomniałem dodać :P