import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class classTest implements ActionListener{
JTextArea area = new JTextArea();
JScrollPane scroll = new JScrollPane();
JPanel pane = new JPanel();
JButton buttonCancel = new JButton();
JButton buttonChannels = new JButton();
JFrame frame = new JFrame("ROCC Client");
// Class config
String lookAndFeel = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
int nrChannels = 10;
void start(int x, int y) {
try{
UIManager.setLookAndFeel(lookAndFeel);
}
catch(Exception e){}
// Button Cancle
buttonCancel = new JButton("Cancel");
buttonCancel.addActionListener(this);
buttonCancel.setMaximumSize(new Dimension(100, 25));
buttonCancel.setSize(new Dimension(200, 25));
// Button Open Chanels
buttonChannels = new JButton("Open Channels");
buttonChannels.addActionListener(this);
buttonChannels.setMaximumSize(new Dimension(100, 25));
buttonChannels.setSize(new Dimension(200, 25));
// Put space between top-level container and its contents
pane = new JPanel();
pane.setBackground(new Color(0, 0, 0));
pane.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));
pane.setLayout(new TableLayout(1, 1));
// pane.setLayout(null);
pane.add(buttonCancel);
pane.add(buttonChannels);
buttonCancel.setLocation(0, 500);
buttonChannels.setLocation(10, 520);
frame.getContentPane().add(pane);
// Location and size options
frame.setSize(new Dimension(450,350));
frame.setLocation(x,y);
scroll.setLocation(0,0);
scroll.setSize(frame.getWidth()-8, frame.getHeight() - 60);
buttonCancel.setLocation(0, frame.getHeight() - buttonCancel.getHeight() * 2 -2);
frame.setVisible(true);
//Create a WindowListener to terminate the program
frame.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
area.append("Beenden-Anforderung...\n");
frame = null;
System.gc();
System.exit(0);
}
}
);
} // end: void start()
void channel(int posX, int posY) {
try{
UIManager.setLookAndFeel(lookAndFeel);
} // end: try
catch(Exception e){} // end: catch
area = new JTextArea(13,50);
scroll.add(area);
scroll.getViewport().setView(area);
pane = new JPanel();
pane.setBackground(new Color(0, 0, 255));
pane.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));
pane.setLayout(new GridLayout(2, 1));
pane.add(scroll);
frame.getContentPane().add(pane);
frame.setSize(new Dimension(450,350));
frame.setLocation(posX,posY);
scroll.setSize(frame.getWidth()-8, frame.getHeight() - 60);
frame.setVisible(true);
}
public void actionPerformed(ActionEvent event)
{
String whichButton = event.getActionCommand();
if (whichButton.equals("Cancel")){
System.exit(0);
}
if (whichButton.equals("Open Channels")){
for (int i=1; i<=nrChannels; i++){
classTest m = new classTest();
m.channel(100+i*30,100+i*30);
System.out.println("Test"+i);
}
}
} // end: public void actionPerformed()
public static void main (String args[]) {
classTest m = new classTest();
m.start(100,100);
} // end: void main
}