/*
* Jacareto Copyright (c) 2002-2005
* Applied Computer Science Research Group, Darmstadt University of
* Technology, Institute of Mathematics & Computer Science,
* Ludwigsburg University of Education, and Computer Based
* Learning Research Group, Aachen University. All rights reserved.
*
* Jacareto is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* Jacareto is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with Jacareto; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
package jacareto.examples;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.JTextPane;
/**
* Class for testing some swing components (complex).
*/
public class SwingComplexTest extends JFrame {
JTabbedPane jTabbedPane1 = new JTabbedPane();
JScrollPane jScrollPane1 = new JScrollPane();
JPanel jPanel1 = new JPanel();
JPanel jPanel2 = new JPanel();
JButton jButton1 = new JButton();
JButton jButton2 = new JButton();
JTextField jTextField1 = new JTextField();
JComboBox jComboBox1 = new JComboBox();
JLabel jLabel1 = new JLabel();
JComboBox jComboBox2 = new JComboBox();
JTextArea jTextArea1 = new JTextArea();
JTextPane jTextPane1 = new JTextPane();
JPasswordField jPasswordField1 = new JPasswordField();
JEditorPane jEditorPane1 = new JEditorPane();
JCheckBox jCheckBox1 = new JCheckBox();
JPanel jPanel3 = new JPanel();
JRadioButton jRadioButton1 = new JRadioButton();
JRadioButton jRadioButton2 = new JRadioButton();
JRadioButton jRadioButton3 = new JRadioButton();
JRadioButton jRadioButton4 = new JRadioButton();
JRadioButton jRadioButton5 = new JRadioButton();
JRadioButton jRadioButton6 = new JRadioButton();
ButtonGroup buttonGroup1 = new ButtonGroup();
GridBagLayout gridBagLayout1 = new GridBagLayout();
JRadioButton jRadioButton7 = new JRadioButton();
JRadioButton jRadioButton8 = new JRadioButton();
/**
* Creates a new frame.
*/
public SwingComplexTest () {
try {
jbInit ();
} catch (Exception e) {
e.printStackTrace ();
}
//
// event handler which closes the frame
//
this.addWindowListener (new WindowAdapter() {
public void windowClosing (WindowEvent e) {
dispose ();
//System.exit(1);
}
});
}
/**
* Inits the components.
*
* @throws Exception DOCUMENT ME!
*/
private void jbInit () throws Exception {
jTabbedPane1.setName ("jTabbedPane1");
jScrollPane1.setName ("jScrollPane1");
jPanel1.setName ("jPanel1");
jPanel2.setName ("jPanel2");
jButton1.setName ("jButton1");
jButton2.setName ("jButton2");
jTextField1.setName ("jTextField1");
jComboBox1.setName ("jComboBox1");
jLabel1.setName ("jLabel1");
jComboBox2.setName ("jComboBox2");
jTextArea1.setName ("jTextArea1");
jTextPane1.setName ("jTextPane1");
jPasswordField1.setName ("jPasswordField1");
jEditorPane1.setName ("jEditorPane1");
jCheckBox1.setName ("jCheckBox1");
jPanel3.setName ("jPanel3");
jRadioButton1.setName ("jRadioButton1");
jRadioButton2.setName ("jRadioButton2");
jRadioButton3.setName ("jRadioButton3");
jRadioButton4.setName ("jRadioButton4");
jRadioButton5.setName ("jRadioButton5");
jRadioButton6.setName ("jRadioButton6");
jRadioButton7.setName ("jRadioButton7");
jRadioButton8.setName ("jRadioButton8");
jPanel2.setLayout (null);
jButton1.setText ("jButton1");
jButton1.setBounds (new Rectangle(16, 40, 194, 27));
jButton1.addMouseListener (new java.awt.event.MouseAdapter() {
public void mouseClicked (MouseEvent e) {
jButton1_mouseClicked (e);
}
});
jButton1.addActionListener (new java.awt.event.ActionListener() {
public void actionPerformed (ActionEvent e) {
jButton1_actionPerformed (e);
}
});
jButton2.setText ("jButton2");
jButton2.setBounds (new Rectangle(400, 92, 180, 37));
jButton2.addActionListener (new java.awt.event.ActionListener() {
public void actionPerformed (ActionEvent e) {
jButton2_actionPerformed (e);
}
});
jPanel2.setPreferredSize (new Dimension(1000, 300));
jTextField1.setText ("jTextField1");
jTextField1.setBounds (new Rectangle(25, 201, 227, 25));
jComboBox1.setBounds (new Rectangle(29, 93, 102, 22));
jLabel1.setBorder (BorderFactory.createEtchedBorder ());
jLabel1.setText ("jLabel1");
jLabel1.setBounds (new Rectangle(210, 110, 86, 66));
jLabel1.addMouseListener (new java.awt.event.MouseAdapter() {
public void mouseClicked (MouseEvent e) {
jLabel1_mouseClicked (e);
}
});
jComboBox2.setEditable (true);
jComboBox2.setBounds (new Rectangle(30, 142, 102, 22));
jTextArea1.setText ("jTextArea1");
jTextArea1.setBounds (new Rectangle(9, 12, 127, 109));
jTextPane1.setText ("jTextPane1");
jTextPane1.setBounds (new Rectangle(256, 13, 110, 117));
jPanel1.setLayout (null);
jPasswordField1.setText ("jPasswordField1");
jPasswordField1.setBounds (new Rectangle(69, 180, 255, 47));
jEditorPane1.setText ("jEditorPane1");
jEditorPane1.setBounds (new Rectangle(152, 24, 97, 139));
jCheckBox1.setText ("jCheckBox1");
jCheckBox1.setBounds (new Rectangle(250, 41, 87, 28));
jRadioButton1.setText ("grouped 1");
jRadioButton2.setText ("grouped 2");
jRadioButton2.setToolTipText ("");
jRadioButton2.addActionListener (new java.awt.event.ActionListener() {
public void actionPerformed (ActionEvent e) {
jRadioButton2_actionPerformed (e);
}
});
jPanel3.setLayout (gridBagLayout1);
jRadioButton3.setText ("grouped 3");
jRadioButton4.setText ("grouped 4");
jRadioButton5.setText ("grouped 5");
jRadioButton6.setText ("grouped 6");
jRadioButton7.setText ("nongrouped 1");
jRadioButton8.setText ("nongrouped 2");
this.getContentPane ().add (jTabbedPane1, BorderLayout.CENTER);
jTabbedPane1.add (jScrollPane1, "jScrollPane1");
jScrollPane1.getViewport ().add (jPanel2, null);
jPanel2.add (jButton1, null);
jPanel2.add (jButton2, null);
jPanel2.add (jLabel1, null);
jPanel2.add (jComboBox1, null);
jPanel2.add (jComboBox2, null);
jPanel2.add (jTextField1, null);
jPanel2.add (jCheckBox1, null);
jComboBox1.addItem ("one");
jComboBox1.addItem ("two");
jComboBox1.addItem ("three");
jComboBox2.addItem ("blue");
jComboBox2.addItem ("red");
jComboBox2.addItem ("green");
jTabbedPane1.add (jPanel1, "jPanel1");
jPanel1.add (jPasswordField1, null);
jPanel1.add (jTextArea1, null);
jPanel1.add (jEditorPane1, null);
jPanel1.add (jTextPane1, null);
jTabbedPane1.add (jPanel3, "RadioGroups");
jPanel3.add (jRadioButton1,
new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.WEST,
GridBagConstraints.NONE, new Insets(0, 5, 0, 0), 1, 1));
jPanel3.add (jRadioButton2,
new GridBagConstraints(1, 1, 1, 1, 1.0, 1.0, GridBagConstraints.WEST,
GridBagConstraints.NONE, new Insets(0, 0, 0, 1), 0, 0));
jPanel3.add (jRadioButton3,
new GridBagConstraints(0, 2, 1, 1, 1.0, 1.0, GridBagConstraints.WEST,
GridBagConstraints.NONE, new Insets(0, 5, 0, 0), 1, 1));
jPanel3.add (jRadioButton4,
new GridBagConstraints(1, 2, 1, 1, 1.0, 1.0, GridBagConstraints.WEST,
GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 1, 1));
jPanel3.add (jRadioButton5,
new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0, GridBagConstraints.WEST,
GridBagConstraints.NONE, new Insets(0, 5, 0, 0), 1, 1));
jPanel3.add (jRadioButton6,
new GridBagConstraints(1, 3, 1, 1, 1.0, 1.0, GridBagConstraints.WEST,
GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 1, 1));
jPanel3.add (jRadioButton7,
new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.WEST,
GridBagConstraints.NONE, new Insets(0, 5, 0, 0), 0, 0));
jPanel3.add (jRadioButton8,
new GridBagConstraints(1, 0, 1, 1, 1.0, 1.0, GridBagConstraints.WEST,
GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
buttonGroup1.add (jRadioButton1);
buttonGroup1.add (jRadioButton3);
buttonGroup1.add (jRadioButton5);
buttonGroup1.add (jRadioButton2);
buttonGroup1.add (jRadioButton4);
buttonGroup1.add (jRadioButton6);
jTabbedPane1.setSelectedComponent (jPanel3);
}
void jButton1_actionPerformed (ActionEvent e) {
jTextField1.setText ("Button-1 pressed");
}
void jButton2_actionPerformed (ActionEvent e) {
jTextField1.setText ("Button-2 pressed");
}
void jLabel1_mouseClicked (MouseEvent e) {
if (e.getClickCount () == 2) {
jLabel1.setForeground (new Color((float) Math.random (), (float) Math.random (),
(float) Math.random ()));
}
}
void jButton1_mouseClicked (MouseEvent e) {
}
void jRadioButton2_actionPerformed (ActionEvent e) {
}
/**
* The main method which shows the frame.
*
* @param args DOCUMENT ME!
*/
public static void main (String[] args) {
JFrame f = new SwingComplexTest();
f.setBounds (400, 300, 400, 300);
f.setVisible (true);
}
}
|