package jpotter.test;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.concurrent.Semaphore;
import javax.swing.*;
import jpotter.spells.Aguamenti;
/**
* Date: 19 Mar 2011 Time: 10:30:51
*
* @author Thomas Michel
*/
public class TestSpells extends JFrame {
// private JLabel testLabel;
private JButton castButton;
private JPanel container;
public TestSpells() {
super("JPotter");
setDefaultCloseOperation(EXIT_ON_CLOSE);
setSize(300, 300);
setLayout(new BorderLayout());
container = new JPanel();
castButton = new JButton("Cast");
castButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
container.removeAll();
container.setLayout(null);
Aguamenti agua = new Aguamenti();
Component comp = agua.getComponent();
// comp.setSize(agua.getDimension());
container.add(comp);
container.validate();
System.out.println("displayable?"+(comp.getGraphics()!=null)+";"+comp.getWidth()+";"+comp.getHeight());
agua.cast(new Point(20, 20), new Point(100, 100), container);
}
});
setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints(0, 0, 1, 1, 0d, 0d,
GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(2, 2,
2, 2), 0, 0);
gbc.fill = GridBagConstraints.BOTH;
gbc.weightx = 1.0d;
gbc.weighty = 1.0d;
add(container, gbc);
gbc.fill = GridBagConstraints.NONE;
gbc.weightx = 0.0d;
gbc.weighty = 0.0d;
gbc.gridy++;
add(castButton, gbc);
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
TestSpells t = new TestSpells();
t.setVisible(true);
}
});
}
}