import java.awt.*;
import java.util.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*
/**
* Warning: Do not use this class! You could damage your brain!
*/
public class Hallo extends JFrame
{
int var1 = 23;
private Color color = Color.BLUE;
private Map paintableComponents;
/**
* Creates a new instance of Hello
*/
private Hallo()
{
super("Hello by java-forum.org");
paintableComponents = new HashMap();
setSize(640, 480);
setLocationRelativeTo(null);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
initUI();
}
/**
* Creates a new instance of Hello
* @param color The color
*/
public Hallo(Color color)
{
this(); // Roar: muss andersrum sein
this.color=color;
}
/**
* Initializes the user interface of the the form
*/
public void initUI()
{
//works since 1.5
setLayout(new BorderLayout());
final JToolBar toolBar=new JToolBar();
initToolBar(toolBar);
add(toolBar,BorderLayout.NORTH); //bessa oben
}
/**
* Draws the frame
* @param g The Graphics object to draw on
*/
public void paint(Graphics g)
{
super.paint(g);
g.setColor(color);
g.setFont(g.getFont().deriveFont(var1));
g.drawString("Java is cool ", var1, 100);
}
/**
* Initializes the toolbar of the form
*/
private void initToolBar(JToolBar toolBar)
{
toolBar.setEnabled(false);
toolBar.add(new JLabel("test"));
toolBar.add(new JButton("Click me!"));
}
/**
* The main method of the application - please do not run!
* @param args The arguments passed to the application
*/
public static void main(String[] args)
{
Hallo hallo = new Hallo(Color.RED);
hallo.setVisible(true);
}
/**
* adds a paintable to the map
* @param p the name of the component
*/
public void addPaintable(String name, Paintable p){
if(!paintableComponents.contains(name))
paintableComponents.put(name, p);
}
/**
* get a paintable component
* @param name the name of the component
* return the component named <name>
*/
public Paintable getPaintable(String name){
Object o = null;
if((o = paintableComponents.get(name)) != null)
return (Paintable)o;
else
return o;
}
/**
* draws the paintable components on the form
*/
private void paintPaintables(){
}
public void actionPerformed(ActionEvent e) // ActionListener
{
if ( e.getSource() =="Click me!" )
{
}