Как я могу добавить JButton
к моему Canvas
?
public class mywindow extends Window
{
private static final Canvas canvas = new Canvas();
private JButton button;
public mywindow
{
super(new Frame());
button = new JButton("close");
setLayout (new BorderLayout ());
//Step 1 - failed
add("North", canvas);
canvas.setSize(300,300);
canvas.setLocation(0,0);
// button = new JButton(my, "close"); will not work
// How can I add the button to the canvas?
//Step 2 - works, but it gets the background color, instead of real transparency.
//JPanel p = new JPanel(); p.setOpaque(false);
//p.setSize(300,300); p.setLocation(0,0);
//add("North", p);
//p.add("Left", button);
}
}