aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing
diff options
context:
space:
mode:
Diffstat (limited to 'gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing')
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/BrowserEditorKit.java57
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/ButtonDemo.java319
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/ComboBoxDemo.java386
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/Demo.java629
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/DemoDesktop.java82
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/DemoFactory.java57
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/DocumentFilterDemo.java288
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/FileChooserDemo.java264
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/HtmlDemo.java380
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/ListDemo.java231
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/MetalThemeEditor.java585
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/MiniDemo.java233
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/NavigationFilterDemo.java205
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/ProgressBarDemo.java239
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/ScrollBarDemo.java174
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/SliderDemo.java287
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/SpinnerDemo.java235
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/TabbedPaneDemo.java256
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/TableDemo.java411
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/TextAreaDemo.java620
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/TextFieldDemo.java594
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/TreeDemo.java318
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/forms.html98
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/frame1.html41
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/frame2.html42
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/frame3.html42
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/frame4.html41
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/frames.html44
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/tables.html66
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/textstyles.html78
-rw-r--r--gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/welcome.html63
31 files changed, 7365 insertions, 0 deletions
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/BrowserEditorKit.java b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/BrowserEditorKit.java
new file mode 100644
index 000000000..f61275e57
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/BrowserEditorKit.java
@@ -0,0 +1,57 @@
+/* BrowserEditorKit.java -- A tweaked editor kit for the browser
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath 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, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.examples.swing;
+
+import javax.swing.text.html.HTMLEditorKit;
+
+/**
+ * A tweaked editor kit for out browser.
+ */
+public class BrowserEditorKit
+ extends HTMLEditorKit
+{
+ public BrowserEditorKit()
+ {
+ super();
+ // Turn off automatic form submission so that we can receive notification
+ // instead and can update out location field.
+ setAutoFormSubmission(false);
+ }
+}
+
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/ButtonDemo.java b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/ButtonDemo.java
new file mode 100644
index 000000000..1c6dfa01b
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/ButtonDemo.java
@@ -0,0 +1,319 @@
+/* ButtonDemo.java -- An example showing various buttons in Swing.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath examples.
+
+GNU Classpath 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, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+*/
+
+
+package gnu.classpath.examples.swing;
+
+import java.awt.BorderLayout;
+import java.awt.GridLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.BorderFactory;
+import javax.swing.ButtonGroup;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JComponent;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JRadioButton;
+import javax.swing.JToggleButton;
+import javax.swing.SwingConstants;
+import javax.swing.SwingUtilities;
+import javax.swing.plaf.metal.MetalIconFactory;
+
+/**
+ * A simple button demo showing various buttons in different states.
+ */
+public class ButtonDemo
+ extends JPanel
+ implements ActionListener
+{
+
+ private JCheckBox buttonState;
+ private JButton button1;
+ private JButton button2;
+ private JButton button3;
+ private JButton button4;
+
+ private JCheckBox toggleState;
+ private JToggleButton toggle1;
+ private JToggleButton toggle2;
+ private JToggleButton toggle3;
+ private JToggleButton toggle4;
+
+ private JCheckBox checkBoxState;
+ private JCheckBox checkBox1;
+ private JCheckBox checkBox2;
+ private JCheckBox checkBox3;
+
+ private JCheckBox radioState;
+ private JRadioButton radio1;
+ private JRadioButton radio2;
+ private JRadioButton radio3;
+
+ /**
+ * Creates a new demo instance.
+ */
+ public ButtonDemo()
+ {
+ createContent();
+ // initFrameContent() is only called (from main) when running this app
+ // standalone
+ }
+
+ /**
+ * When the demo is run independently, the frame is displayed, so we should
+ * initialise the content panel (including the demo content and a close
+ * button). But when the demo is run as part of the Swing activity board,
+ * only the demo content panel is used, the frame itself is never displayed,
+ * so we can avoid this step.
+ */
+ void initFrameContent()
+ {
+ JPanel closePanel = new JPanel();
+ JButton closeButton = new JButton("Close");
+ closeButton.setActionCommand("CLOSE");
+ closeButton.addActionListener(this);
+ closePanel.add(closeButton);
+ add(closePanel, BorderLayout.SOUTH);
+ }
+
+ /**
+ * Returns a panel with the demo content. The panel
+ * uses a BorderLayout(), and the BorderLayout.SOUTH area
+ * is empty, to allow callers to add controls to the
+ * bottom of the panel if they want to (a close button is
+ * added if this demo is being run as a standalone demo).
+ */
+ private void createContent()
+ {
+ setLayout(new BorderLayout());
+ JPanel panel = new JPanel(new GridLayout(4, 1));
+ panel.add(createButtonPanel());
+ panel.add(createTogglePanel());
+ panel.add(createCheckBoxPanel());
+ panel.add(createRadioPanel());
+ add(panel);
+ }
+
+ private JPanel createButtonPanel()
+ {
+ JPanel panel = new JPanel(new BorderLayout());
+ this.buttonState = new JCheckBox("Enabled", true);
+ this.buttonState.setActionCommand("BUTTON_STATE");
+ this.buttonState.addActionListener(this);
+ panel.add(this.buttonState, BorderLayout.EAST);
+
+ JPanel buttonPanel = new JPanel();
+ buttonPanel.setBorder(BorderFactory.createTitledBorder("JButton"));
+ this.button1 = new JButton("Button 1");
+
+ this.button2 = new JButton("Button 2");
+ this.button2.setIcon(MetalIconFactory.getInternalFrameDefaultMenuIcon());
+
+ this.button3 = new JButton("Button 3");
+ this.button3.setIcon(MetalIconFactory.getFileChooserHomeFolderIcon());
+ this.button3.setHorizontalTextPosition(SwingConstants.CENTER);
+ this.button3.setVerticalTextPosition(SwingConstants.BOTTOM);
+
+ this.button4 = new JButton("Button 4");
+ this.button4.setIcon(MetalIconFactory.getFileChooserUpFolderIcon());
+ this.button4.setText(null);
+
+ buttonPanel.add(button1);
+ buttonPanel.add(button2);
+ buttonPanel.add(button3);
+ buttonPanel.add(button4);
+
+ panel.add(buttonPanel);
+
+ return panel;
+ }
+
+ private JPanel createTogglePanel()
+ {
+ JPanel panel = new JPanel(new BorderLayout());
+
+ this.toggleState = new JCheckBox("Enabled", true);
+ this.toggleState.setActionCommand("TOGGLE_STATE");
+ this.toggleState.addActionListener(this);
+
+ panel.add(this.toggleState, BorderLayout.EAST);
+
+ JPanel buttonPanel = new JPanel();
+ buttonPanel.setBorder(BorderFactory.createTitledBorder("JToggleButton"));
+
+ this.toggle1 = new JToggleButton("Toggle 1");
+
+ this.toggle2 = new JToggleButton("Toggle 2");
+ this.toggle2.setIcon(MetalIconFactory.getInternalFrameDefaultMenuIcon());
+
+ this.toggle3 = new JToggleButton("Toggle 3");
+ this.toggle3.setIcon(MetalIconFactory.getFileChooserHomeFolderIcon());
+ this.toggle3.setHorizontalTextPosition(SwingConstants.CENTER);
+ this.toggle3.setVerticalTextPosition(SwingConstants.BOTTOM);
+
+ this.toggle4 = new JToggleButton("Toggle 4");
+ this.toggle4.setIcon(MetalIconFactory.getFileChooserUpFolderIcon());
+ this.toggle4.setText(null);
+
+ ButtonGroup toggleGroup = new ButtonGroup();
+ toggleGroup.add(toggle1);
+ toggleGroup.add(toggle2);
+ toggleGroup.add(toggle3);
+ toggleGroup.add(toggle4);
+
+ buttonPanel.add(toggle1);
+ buttonPanel.add(toggle2);
+ buttonPanel.add(toggle3);
+ buttonPanel.add(toggle4);
+
+ panel.add(buttonPanel);
+
+ return panel;
+ }
+
+ private JPanel createCheckBoxPanel()
+ {
+ JPanel panel = new JPanel(new BorderLayout());
+
+ this.checkBoxState = new JCheckBox("Enabled", true);
+ this.checkBoxState.setActionCommand("CHECKBOX_STATE");
+ this.checkBoxState.addActionListener(this);
+
+ panel.add(this.checkBoxState, BorderLayout.EAST);
+
+ JPanel buttonPanel = new JPanel();
+ buttonPanel.setBorder(BorderFactory.createTitledBorder("JCheckBox"));
+ this.checkBox1 = new JCheckBox("CheckBox 1");
+
+ this.checkBox2 = new JCheckBox("CheckBox 2");
+
+ this.checkBox3 = new JCheckBox("CheckBox 3");
+
+ buttonPanel.add(checkBox1);
+ buttonPanel.add(checkBox2);
+ buttonPanel.add(checkBox3);
+
+ panel.add(buttonPanel);
+
+ return panel;
+ }
+
+ private JPanel createRadioPanel()
+ {
+ JPanel panel = new JPanel(new BorderLayout());
+
+ this.radioState = new JCheckBox("Enabled", true);
+ this.radioState.setActionCommand("RADIO_STATE");
+ this.radioState.addActionListener(this);
+ panel.add(this.radioState, BorderLayout.EAST);
+
+ JPanel buttonPanel = new JPanel();
+ buttonPanel.setBorder(BorderFactory.createTitledBorder("JRadioButton"));
+ this.radio1 = new JRadioButton("Radio 1");
+
+ this.radio2 = new JRadioButton("Radio 2");
+
+ this.radio3 = new JRadioButton("Radio 3");
+
+ ButtonGroup radioGroup = new ButtonGroup();
+ radioGroup.add(radio1);
+ radioGroup.add(radio2);
+ radioGroup.add(radio3);
+
+ buttonPanel.add(radio1);
+ buttonPanel.add(radio2);
+ buttonPanel.add(radio3);
+
+ panel.add(buttonPanel);
+
+ return panel;
+ }
+
+ public void actionPerformed(ActionEvent e)
+ {
+ if (e.getActionCommand().equals("BUTTON_STATE"))
+ {
+ button1.setEnabled(buttonState.isSelected());
+ button2.setEnabled(buttonState.isSelected());
+ button3.setEnabled(buttonState.isSelected());
+ button4.setEnabled(buttonState.isSelected());
+ }
+ else if (e.getActionCommand().equals("TOGGLE_STATE"))
+ {
+ toggle1.setEnabled(toggleState.isSelected());
+ toggle2.setEnabled(toggleState.isSelected());
+ toggle3.setEnabled(toggleState.isSelected());
+ toggle4.setEnabled(toggleState.isSelected());
+ }
+ else if (e.getActionCommand().equals("CHECKBOX_STATE"))
+ {
+ checkBox1.setEnabled(checkBoxState.isSelected());
+ checkBox2.setEnabled(checkBoxState.isSelected());
+ checkBox3.setEnabled(checkBoxState.isSelected());
+ }
+ else if (e.getActionCommand().equals("RADIO_STATE"))
+ {
+ radio1.setEnabled(radioState.isSelected());
+ radio2.setEnabled(radioState.isSelected());
+ radio3.setEnabled(radioState.isSelected());
+ }
+ else if (e.getActionCommand().equals("CLOSE"))
+ {
+ System.exit(0);
+ }
+ }
+
+ public static void main(String[] args)
+ {
+ SwingUtilities.invokeLater
+ (new Runnable()
+ {
+ public void run()
+ {
+ ButtonDemo app = new ButtonDemo();
+ app.initFrameContent();
+ JFrame frame = new JFrame("ButtonDemo");
+ frame.getContentPane().add(app);
+ frame.pack();
+ frame.setVisible(true);
+ }
+ });
+ }
+
+ /**
+ * Returns a DemoFactory that creates a ButtonDemo.
+ *
+ * @return a DemoFactory that creates a ButtonDemo
+ */
+ public static DemoFactory createDemoFactory()
+ {
+ return new DemoFactory()
+ {
+ public JComponent createDemo()
+ {
+ return new ButtonDemo();
+ }
+ };
+ }
+}
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/ComboBoxDemo.java b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/ComboBoxDemo.java
new file mode 100644
index 000000000..61dee06f2
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/ComboBoxDemo.java
@@ -0,0 +1,386 @@
+/* ComboBoxDemo.java -- An example showing various combo boxes in Swing.
+ Copyright (C) 2005, 2006, Free Software Foundation, Inc.
+
+This file is part of GNU Classpath examples.
+
+GNU Classpath 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, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+*/
+
+
+package gnu.classpath.examples.swing;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.GridLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.BorderFactory;
+import javax.swing.DefaultListCellRenderer;
+import javax.swing.Icon;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JComboBox;
+import javax.swing.JComponent;
+import javax.swing.JFrame;
+import javax.swing.JList;
+import javax.swing.JPanel;
+import javax.swing.SwingUtilities;
+import javax.swing.plaf.metal.MetalIconFactory;
+
+/**
+ * A simple demo showing various combo boxes in different states.
+ */
+public class ComboBoxDemo
+ extends JPanel
+ implements ActionListener
+{
+
+ class CustomCellRenderer extends DefaultListCellRenderer
+ {
+ public Component getListCellRendererComponent(JList list,
+ Object value,
+ int index,
+ boolean isSelected,
+ boolean cellHasFocus)
+ {
+ DefaultListCellRenderer result = (DefaultListCellRenderer)
+ super.getListCellRendererComponent(list, value, index, isSelected,
+ cellHasFocus);
+ Icon icon = (Icon) value;
+ result.setIcon(icon);
+ result.setText("Index = " + index);
+ return result;
+ }
+ }
+
+ private JCheckBox comboState1;
+ private JComboBox combo1;
+ private JComboBox combo2;
+
+ private JCheckBox comboState2;
+ private JComboBox combo3;
+ private JComboBox combo4;
+
+ private JCheckBox comboState3;
+ private JComboBox combo5;
+ private JComboBox combo6;
+
+ private JCheckBox comboState4;
+ private JComboBox combo7;
+ private JComboBox combo8;
+
+ private JCheckBox comboState5;
+ private JComboBox combo9;
+ private JComboBox combo10;
+
+ private JCheckBox comboState6;
+ private JComboBox combo11;
+ private JComboBox combo12;
+
+ /**
+ * Creates a new demo instance.
+ */
+ public ComboBoxDemo()
+ {
+ super();
+ createContent();
+ }
+
+ /**
+ * When the demo is run independently, the frame is displayed, so we should
+ * initialise the content panel (including the demo content and a close
+ * button). But when the demo is run as part of the Swing activity board,
+ * only the demo content panel is used, the frame itself is never displayed,
+ * so we can avoid this step.
+ */
+ void initFrameContent()
+ {
+ JPanel closePanel = new JPanel();
+ JButton closeButton = new JButton("Close");
+ closeButton.setActionCommand("CLOSE");
+ closeButton.addActionListener(this);
+ closePanel.add(closeButton);
+ add(closePanel, BorderLayout.SOUTH);
+ }
+
+ /**
+ * Returns a panel with the demo content. The panel
+ * uses a BorderLayout(), and the BorderLayout.SOUTH area
+ * is empty, to allow callers to add controls to the
+ * bottom of the panel if they want to (a close button is
+ * added if this demo is being run as a standalone demo).
+ */
+ private void createContent()
+ {
+ setLayout(new BorderLayout());
+ JPanel panel = new JPanel(new GridLayout(6, 1));
+ panel.add(createPanel1());
+ panel.add(createPanel2());
+ panel.add(createPanel3());
+ panel.add(createPanel4());
+ panel.add(createPanel5());
+ panel.add(createPanel6());
+ add(panel);
+ }
+
+ private JPanel createPanel1()
+ {
+ JPanel panel = new JPanel(new BorderLayout());
+ this.comboState1 = new JCheckBox("Enabled", true);
+ this.comboState1.setActionCommand("COMBO_STATE1");
+ this.comboState1.addActionListener(this);
+ panel.add(this.comboState1, BorderLayout.EAST);
+
+ JPanel controlPanel = new JPanel();
+ controlPanel.setBorder(BorderFactory.createTitledBorder("Regular: "));
+ this.combo1 = new JComboBox(new Object[] {"Australia", "New Zealand",
+ "England"});
+
+ this.combo2 = new JComboBox(new Object[] {"Australia", "New Zealand",
+ "England"});
+ this.combo2.setEditable(true);
+
+ controlPanel.add(combo1);
+ controlPanel.add(combo2);
+
+ panel.add(controlPanel);
+
+ return panel;
+ }
+
+ private JPanel createPanel2()
+ {
+ JPanel panel = new JPanel(new BorderLayout());
+ this.comboState2 = new JCheckBox("Enabled", true);
+ this.comboState2.setActionCommand("COMBO_STATE2");
+ this.comboState2.addActionListener(this);
+ panel.add(this.comboState2, BorderLayout.EAST);
+
+ JPanel controlPanel = new JPanel();
+ controlPanel.setBorder(BorderFactory.createTitledBorder("Large Font: "));
+ this.combo3 = new JComboBox(new Object[] {"Australia", "New Zealand",
+ "England"});
+ this.combo3.setFont(new Font("Dialog", Font.PLAIN, 20));
+
+ this.combo4 = new JComboBox(new Object[] {"Australia", "New Zealand",
+ "England"});
+ this.combo4.setEditable(true);
+ this.combo4.setFont(new Font("Dialog", Font.PLAIN, 20));
+
+ controlPanel.add(combo3);
+ controlPanel.add(combo4);
+
+ panel.add(controlPanel);
+
+ return panel;
+ }
+
+ private JPanel createPanel3()
+ {
+ JPanel panel = new JPanel(new BorderLayout());
+ this.comboState3 = new JCheckBox("Enabled", true);
+ this.comboState3.setActionCommand("COMBO_STATE3");
+ this.comboState3.addActionListener(this);
+ panel.add(this.comboState3, BorderLayout.EAST);
+
+ JPanel controlPanel = new JPanel();
+ controlPanel.setBorder(BorderFactory.createTitledBorder("Colored Background: "));
+ this.combo5 = new JComboBox(new Object[] {"Australia", "New Zealand",
+ "England"});
+ this.combo5.setBackground(Color.yellow);
+
+ this.combo6 = new JComboBox(new Object[] {"Australia", "New Zealand",
+ "England"});
+ this.combo6.setEditable(true);
+ this.combo6.setBackground(Color.yellow);
+
+ controlPanel.add(combo5);
+ controlPanel.add(combo6);
+
+ panel.add(controlPanel);
+
+ return panel;
+ }
+
+ /**
+ * This panel contains combo boxes that are empty.
+ *
+ * @return A panel.
+ */
+ private JPanel createPanel4()
+ {
+ JPanel panel = new JPanel(new BorderLayout());
+ this.comboState4 = new JCheckBox("Enabled", true);
+ this.comboState4.setActionCommand("COMBO_STATE4");
+ this.comboState4.addActionListener(this);
+ panel.add(this.comboState4, BorderLayout.EAST);
+
+ JPanel controlPanel = new JPanel();
+ controlPanel.setBorder(BorderFactory.createTitledBorder("Empty: "));
+ this.combo7 = new JComboBox();
+ this.combo8 = new JComboBox();
+ this.combo8.setEditable(true);
+
+ controlPanel.add(combo7);
+ controlPanel.add(combo8);
+
+ panel.add(controlPanel);
+
+ return panel;
+ }
+
+ /**
+ * This panel contains combo boxes that are narrow but contain long text
+ * items.
+ *
+ * @return A panel.
+ */
+ private JPanel createPanel5()
+ {
+ JPanel panel = new JPanel(new BorderLayout());
+ this.comboState5 = new JCheckBox("Enabled", true);
+ this.comboState5.setActionCommand("COMBO_STATE5");
+ this.comboState5.addActionListener(this);
+ panel.add(this.comboState5, BorderLayout.EAST);
+
+ JPanel controlPanel = new JPanel();
+ controlPanel.setBorder(BorderFactory.createTitledBorder("Narrow: "));
+ this.combo9 = new JComboBox(new Object[] {
+ "A really long item that will be truncated when displayed"});
+ this.combo9.setPreferredSize(new Dimension(100, 30));
+ this.combo10 = new JComboBox(new Object[] {
+ "A really long item that will be truncated when displayed"});
+ this.combo10.setPreferredSize(new Dimension(100, 30));
+ this.combo10.setEditable(true);
+
+ controlPanel.add(combo9);
+ controlPanel.add(combo10);
+
+ panel.add(controlPanel);
+
+ return panel;
+ }
+
+ /**
+ * This panel contains combo boxes with a custom renderer.
+ *
+ * @return A panel.
+ */
+ private JPanel createPanel6()
+ {
+ JPanel panel = new JPanel(new BorderLayout());
+ this.comboState6 = new JCheckBox("Enabled", true);
+ this.comboState6.setActionCommand("COMBO_STATE6");
+ this.comboState6.addActionListener(this);
+ panel.add(this.comboState6, BorderLayout.EAST);
+
+ JPanel controlPanel = new JPanel();
+ controlPanel.setBorder(BorderFactory.createTitledBorder("Custom Renderer: "));
+ this.combo11 = new JComboBox(new Object[] {
+ MetalIconFactory.getFileChooserHomeFolderIcon(),
+ MetalIconFactory.getFileChooserNewFolderIcon()});
+ this.combo11.setPreferredSize(new Dimension(100, 30));
+ this.combo11.setRenderer(new CustomCellRenderer());
+ this.combo12 = new JComboBox(new Object[] {
+ MetalIconFactory.getFileChooserHomeFolderIcon(),
+ MetalIconFactory.getFileChooserNewFolderIcon()});
+ this.combo12.setPreferredSize(new Dimension(100, 30));
+ this.combo12.setRenderer(new CustomCellRenderer());
+ this.combo12.setEditable(true);
+
+ controlPanel.add(combo11);
+ controlPanel.add(combo12);
+
+ panel.add(controlPanel);
+
+ return panel;
+ }
+
+ public void actionPerformed(ActionEvent e)
+ {
+ if (e.getActionCommand().equals("COMBO_STATE1"))
+ {
+ combo1.setEnabled(comboState1.isSelected());
+ combo2.setEnabled(comboState1.isSelected());
+ }
+ else if (e.getActionCommand().equals("COMBO_STATE2"))
+ {
+ combo3.setEnabled(comboState2.isSelected());
+ combo4.setEnabled(comboState2.isSelected());
+ }
+ else if (e.getActionCommand().equals("COMBO_STATE3"))
+ {
+ combo5.setEnabled(comboState3.isSelected());
+ combo6.setEnabled(comboState3.isSelected());
+ }
+ else if (e.getActionCommand().equals("COMBO_STATE4"))
+ {
+ combo7.setEnabled(comboState4.isSelected());
+ combo8.setEnabled(comboState4.isSelected());
+ }
+ else if (e.getActionCommand().equals("COMBO_STATE5"))
+ {
+ combo9.setEnabled(comboState5.isSelected());
+ combo10.setEnabled(comboState5.isSelected());
+ }
+ else if (e.getActionCommand().equals("COMBO_STATE6"))
+ {
+ combo11.setEnabled(comboState6.isSelected());
+ combo12.setEnabled(comboState6.isSelected());
+ }
+ else if (e.getActionCommand().equals("CLOSE"))
+ {
+ System.exit(0);
+ }
+ }
+
+ public static void main(String[] args)
+ {
+ SwingUtilities.invokeLater
+ (new Runnable()
+ {
+ public void run()
+ {
+ ComboBoxDemo app = new ComboBoxDemo();
+ app.initFrameContent();
+ JFrame frame = new JFrame();
+ frame.getContentPane().add(app);
+ frame.pack();
+ frame.setVisible(true);
+ }
+ });
+ }
+
+ /**
+ * Returns a DemoFactory that creates a ComboBoxDemo.
+ *
+ * @return a DemoFactory that creates a ComboBoxDemo
+ */
+ public static DemoFactory createDemoFactory()
+ {
+ return new DemoFactory()
+ {
+ public JComponent createDemo()
+ {
+ return new ComboBoxDemo();
+ }
+ };
+ }
+}
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/Demo.java b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/Demo.java
new file mode 100644
index 000000000..3c7f0b887
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/Demo.java
@@ -0,0 +1,629 @@
+/* SwingDemo.java -- An example of using the javax.swing UI.
+ Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath examples.
+
+GNU Classpath 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, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+*/
+
+
+package gnu.classpath.examples.swing;
+
+import gnu.classpath.examples.java2d.JNIOverhead;
+
+import java.awt.*;
+import java.awt.event.*;
+
+import javax.swing.*;
+
+import javax.swing.plaf.basic.BasicLookAndFeel;
+import javax.swing.plaf.metal.DefaultMetalTheme;
+import javax.swing.plaf.metal.MetalLookAndFeel;
+import javax.swing.plaf.metal.MetalTheme;
+import javax.swing.plaf.metal.OceanTheme;
+
+import java.lang.reflect.Method;
+import java.net.URL;
+
+public class Demo
+{
+ JFrame frame;
+
+ /**
+ * The main desktop. This is package private to avoid synthetic accessor
+ * method.
+ */
+ JDesktopPane desktop;
+
+ /**
+ * The themes menu. This is implemented as a field so that the L&F switcher
+ * can disable the menu when a non-Metal L&F is selected.
+ */
+ JMenu themesMenu;
+
+ static Color blueGray = new Color(0xdc, 0xda, 0xd5);
+
+ private static Icon stockIcon(String s)
+ {
+ return getIcon("/gnu/classpath/examples/icons/stock-" + s + ".png", s);
+ }
+
+ static Icon bigStockIcon(String s)
+ {
+ return getIcon("/gnu/classpath/examples/icons/big-" + s + ".png", s);
+ }
+
+ static Icon getIcon(String location, String name)
+ {
+ URL url = Demo.class.getResource(location);
+ if (url == null) System.err.println("WARNING " + location + " not found.");
+ return new ImageIcon(url, name);
+ }
+
+ private JMenuBar mkMenuBar()
+ {
+ JMenuBar bar = new JMenuBar();
+
+ JMenu file = new JMenu("File");
+ JMenu edit = new JMenu("Edit");
+ JMenu help = new JMenu("Help");
+
+ file.setMnemonic(KeyEvent.VK_F);
+ edit.setMnemonic(KeyEvent.VK_E);
+ help.setMnemonic(KeyEvent.VK_H);
+
+ file.add(new JMenuItem("New", stockIcon("new")));
+ file.add(new JMenuItem("Open", stockIcon("open")));
+
+ JMenu recent = new JMenu("Recent Files...");
+ recent.add(new JMenuItem("war-and-peace.txt"));
+ recent.add(new JMenuItem("taming-of-shrew.txt"));
+ recent.add(new JMenuItem("sun-also-rises.txt"));
+ file.add(recent);
+ file.add(new JMenuItem("Save", stockIcon("save")));
+ file.add(new JMenuItem("Save as...", stockIcon("save-as")));
+
+ JMenuItem exit = new JMenuItem("Exit", stockIcon("quit"));
+ exit.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ System.exit(1);
+ }
+ });
+
+ file.add(exit);
+
+ edit.add(new JMenuItem("Cut", stockIcon("cut")));
+ edit.add(new JMenuItem("Copy", stockIcon("copy")));
+ edit.add(new JMenuItem("Paste", stockIcon("paste")));
+
+ JMenu preferences = new JMenu("Preferences...");
+ preferences.add(new JCheckBoxMenuItem("Microphone Active",
+ stockIcon("mic")));
+ preferences.add(new JCheckBoxMenuItem("Check Spelling",
+ stockIcon("spell-check")));
+ preferences.add(new JCheckBoxMenuItem("World Peace"));
+ preferences.add(new JSeparator());
+ preferences.add(new JRadioButtonMenuItem("Radio Button"));
+ edit.add(preferences);
+
+ JMenu examples = new JMenu("Examples");
+ examples.add(new JMenuItem(new PopupAction("Buttons",
+ ButtonDemo.createDemoFactory())));
+ examples.add(new JMenuItem(new PopupAction("Slider",
+ SliderDemo.createDemoFactory())));
+ examples.add(new JMenuItem(new PopupAction("ProgressBar",
+ ProgressBarDemo.createDemoFactory())));
+ examples.add(new JMenuItem(new PopupAction("Scrollbar",
+ ScrollBarDemo.createDemoFactory())));
+ examples.add(new JMenuItem(new PopupAction("Spinner",
+ SpinnerDemo.createDemoFactory())));
+ examples.add(new JMenuItem(new PopupAction("TextField",
+ TextFieldDemo.createDemoFactory())));
+ examples.add(new JMenuItem(new PopupAction("TextArea",
+ TextAreaDemo.createDemoFactory())));
+ examples.add(new JMenuItem(new PopupAction("FileChooser",
+ FileChooserDemo.createDemoFactory())));
+
+ examples.add(new JMenuItem(new PopupAction("ComboBox",
+ ComboBoxDemo.createDemoFactory())));
+
+ examples.add(new JMenuItem(new PopupAction("Table",
+ TableDemo.createDemoFactory())));
+ examples.add(new JMenuItem(new PopupAction("List",
+ ListDemo.createDemoFactory())));
+ examples.add(new JMenuItem(new PopupAction("TabbedPane",
+ TabbedPaneDemo.createDemoFactory())));
+ examples.add(new JMenuItem(new PopupAction("Tree",
+ TreeDemo.createDemoFactory())));
+ examples.add(new JMenuItem(new PopupAction("Theme Editor",
+ MetalThemeEditor.createDemoFactory())));
+
+ examples.add(new JMenuItem(new PopupAction("DocumentFilter",
+ DocumentFilterDemo.createDemoFactory())));
+
+ examples.add(new JMenuItem(new PopupAction("NavigationFilter",
+ NavigationFilterDemo.createDemoFactory())));
+ examples.add(new JMenuItem(new PopupAction("JNI Overhead",
+ JNIOverhead.createDemoFactory())));
+ examples.add(new JMenuItem(new PopupAction("HTML Demo",
+ HtmlDemo.createDemoFactory())));
+
+
+ final JMenuItem vmMenu;
+
+ help.add(new JMenuItem("just play with the widgets"));
+ help.add(new JMenuItem("and enjoy the sensation of"));
+ help.add(new JMenuItem("your neural connections growing"));
+ help.add(new JSeparator());
+ help.add(vmMenu = new JMenuItem("Really, which VM is this running on?"));
+ vmMenu.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent ae)
+ {
+ String message = "This is "
+ + System.getProperty("java.vm.name")
+ + " Version "
+ + System.getProperty("java.vm.version")
+ + " distributed by "
+ + System.getProperty("java.vm.vendor")
+ + ".";
+
+ String gnuClasspath = System.getProperty("gnu.classpath.version");
+ if(gnuClasspath != null)
+ message += "\nThe runtime's libraries are "
+ + "kindly provided by the "
+ + "members of GNU Classpath and are in version "
+ + gnuClasspath + ".";
+
+ JOptionPane.showMessageDialog(vmMenu, message);
+ }
+ });
+
+ // Installs the BasicLookAndFeel.
+ UIManager.installLookAndFeel("(Basic Look And Feel)",
+ InstantiableBasicLookAndFeel.class.getName());
+
+ // Create L&F menu.
+ JMenu lafMenu = new JMenu("Look and Feel");
+ ButtonGroup lafGroup = new ButtonGroup();
+ UIManager.LookAndFeelInfo[] lafs = UIManager.getInstalledLookAndFeels();
+ String currentLaf = UIManager.getLookAndFeel().getClass().getName();
+ for (int i = 0; i < lafs.length; ++i)
+ {
+ UIManager.LookAndFeelInfo laf = lafs[i];
+ ChangeLAFAction action = new ChangeLAFAction(laf);
+ JRadioButtonMenuItem lafItem = new JRadioButtonMenuItem(action);
+ boolean selected = laf.getClassName().equals(currentLaf);
+ lafItem.setSelected(selected);
+ lafMenu.add(lafItem);
+
+ lafGroup.add(lafItem);
+ }
+
+ // Create themes menu.
+ themesMenu = new JMenu("Themes");
+ ButtonGroup themesGroup = new ButtonGroup();
+
+ // In order to make the demo runable on a 1.4 type VM we have to avoid calling
+ // MetalLookAndFeel.getCurrentTheme(). We simply check whether this method exists
+ // and is public.
+ Method m = null;
+ try
+ {
+ m = MetalLookAndFeel.class.getMethod("getCurrentTheme", null);
+ }
+ catch (NoSuchMethodException nsme)
+ {
+ // Ignore it.
+ }
+
+ if (m != null)
+ {
+ JRadioButtonMenuItem ocean =
+ new JRadioButtonMenuItem(new ChangeThemeAction(new OceanTheme()));
+ ocean.setSelected(MetalLookAndFeel.getCurrentTheme() instanceof OceanTheme);
+ themesMenu.add(ocean);
+ themesGroup.add(ocean);
+
+ JRadioButtonMenuItem steel =
+ new JRadioButtonMenuItem(new ChangeThemeAction(new DefaultMetalTheme()));
+ ocean.setSelected(MetalLookAndFeel.getCurrentTheme()
+ instanceof DefaultMetalTheme);
+ themesMenu.add(steel);
+ themesGroup.add(steel);
+ }
+ else
+ {
+ themesMenu.setEnabled(false);
+ }
+
+ bar.add(file);
+ bar.add(edit);
+ bar.add(examples);
+ bar.add(lafMenu);
+ bar.add(themesMenu);
+ bar.add(help);
+ return bar;
+ }
+
+ private static void triggerDialog(final JButton but, final String dir)
+ {
+ but.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ JOptionPane.showConfirmDialog(but,
+ "Sure you want to go " + dir + "?",
+ "Confirm",
+ JOptionPane.OK_CANCEL_OPTION,
+ JOptionPane.QUESTION_MESSAGE,
+ bigStockIcon("warning"));
+ }
+ });
+ }
+
+ static JToolBar mkToolBar()
+ {
+ JToolBar bar = new JToolBar();
+
+ JButton b = mkButton(stockIcon("go-back"));
+ triggerDialog(b, "back");
+ bar.add(b);
+
+ b = mkButton(stockIcon("go-down"));
+ triggerDialog(b, "down");
+ bar.add(b);
+
+ b = mkButton(stockIcon("go-forward"));
+ triggerDialog(b, "forward");
+ bar.add(b);
+ return bar;
+ }
+
+ static String halign2str(int a)
+ {
+ switch (a)
+ {
+ case SwingConstants.CENTER:
+ return "Center";
+ case SwingConstants.RIGHT:
+ return "Right";
+ case SwingConstants.LEFT:
+ return "Left";
+ default:
+ return "Unknown";
+ }
+ }
+
+ private static JButton mkButton(String title, Icon icon,
+ int hAlign, int vAlign,
+ int hPos, int vPos)
+ {
+ JButton b;
+ if (icon == null)
+ b = new JButton(title);
+ else if (title == null)
+ b = new JButton(icon);
+ else
+ b = new JButton(title, icon);
+
+ b.setToolTipText(title);
+ if (hAlign != -1) b.setHorizontalAlignment(hAlign);
+ if (vAlign != -1) b.setVerticalAlignment(vAlign);
+ if (hPos != -1) b.setHorizontalTextPosition(hPos);
+ if (vPos != -1) b.setVerticalTextPosition(vPos);
+ return b;
+ }
+
+ static JButton mkButton(String title)
+ {
+ return mkButton(title, null, -1, -1, -1, -1);
+ }
+
+ static JButton mkButton(Icon i)
+ {
+ return mkButton(null, i, -1, -1, -1, -1);
+ }
+
+ public Demo()
+ {
+ frame = new JFrame("Swing Activity Board");
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ frame.setJMenuBar(mkMenuBar());
+ JComponent component = (JComponent) frame.getContentPane();
+ component.setLayout(new BorderLayout());
+ component.add(mkToolBar(), BorderLayout.NORTH);
+ JPanel main = new JPanel();
+ main.setLayout(new BoxLayout(main, BoxLayout.Y_AXIS));
+ desktop = createDesktop();
+ main.add(desktop);
+ main.add(mkButtonBar());
+ component.add(main, BorderLayout.CENTER);
+ frame.pack();
+ frame.show();
+ }
+
+ public static class LaterMain
+ implements Runnable
+ {
+ public void run()
+ {
+ new Demo();
+ }
+ }
+
+ public static void main(String args[])
+ {
+ SwingUtilities.invokeLater(new LaterMain());
+ }
+
+ private static JButton mkBigButton(String title)
+ {
+ JButton b = new JButton(title);
+ b.setMargin(new Insets(5,5,5,5));
+ return b;
+ }
+
+ static JButton mkDisposerButton(final JFrame c)
+ {
+ JButton close = mkBigButton("Close");
+ close.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ c.dispose();
+ }
+ });
+ return close;
+ }
+
+ public static JColorChooser mkColorChooser()
+ {
+ return new JColorChooser();
+ }
+
+ /**
+ * This action brings up a new Window with the specified content.
+ */
+ private class PopupAction
+ extends AbstractAction
+ {
+ /**
+ * The component to be shown.
+ */
+ private DemoFactory demoFactory;
+
+ /**
+ * Creates a new PopupAction with the specified name and showing the
+ * component created by the specified DemoFactory when activated.
+ *
+ * @param n the name of the action
+ * @param factory the demo factory
+ */
+ PopupAction(String n, DemoFactory factory)
+ {
+ putValue(NAME, n);
+ demoFactory = factory;
+ }
+
+ /**
+ * Brings up the new window showing the component stored in the
+ * constructor.
+ *
+ * @param e the action event that triggered the action
+ */
+ public void actionPerformed(ActionEvent e)
+ {
+ JInternalFrame frame = new JInternalFrame((String) getValue(NAME));
+ frame.setClosable(true);
+ frame.setIconifiable(true);
+ frame.setMaximizable(true);
+ frame.setResizable(true);
+ frame.setContentPane(demoFactory.createDemo());
+ frame.pack();
+ desktop.add(frame);
+ frame.setVisible(true);
+ }
+ }
+
+ private JPanel mkButtonBar()
+ {
+ JPanel panel = new JPanel(new GridLayout(3, 1, 5, 5));
+ panel.add(new JButton(new PopupAction("Buttons",
+ ButtonDemo.createDemoFactory())));
+ panel.add(new JButton(new PopupAction("Slider",
+ SliderDemo.createDemoFactory())));
+ panel.add(new JButton(new PopupAction("ProgressBar",
+ ProgressBarDemo.createDemoFactory())));
+ panel.add(new JButton(new PopupAction("ScrollBar",
+ ScrollBarDemo.createDemoFactory())));
+ panel.add(new JButton(new PopupAction("Spinner",
+ SpinnerDemo.createDemoFactory())));
+ panel.add(new JButton(new PopupAction("TextField",
+ TextFieldDemo.createDemoFactory())));
+ panel.add(new JButton(new PopupAction("TextArea",
+ TextAreaDemo.createDemoFactory())));
+ panel.add(new JButton(new PopupAction("FileChooser",
+ FileChooserDemo.createDemoFactory())));
+ panel.add(new JButton(new PopupAction("ComboBox",
+ ComboBoxDemo.createDemoFactory())));
+ panel.add(new JButton(new PopupAction("Table",
+ TableDemo.createDemoFactory())));
+ panel.add(new JButton(new PopupAction("List",
+ ListDemo.createDemoFactory())));
+ panel.add(new JButton(new PopupAction("TabbedPane",
+ TabbedPaneDemo.createDemoFactory())));
+ panel.add(new JButton(new PopupAction("Tree",
+ TreeDemo.createDemoFactory())));
+ panel.add(new JButton(new PopupAction("Theme Editor",
+ MetalThemeEditor.createDemoFactory())));
+ panel.add(new JButton(new PopupAction("JNI Overhead",
+ JNIOverhead.createDemoFactory())));
+ panel.add(new JButton(new PopupAction("HTML",
+ HtmlDemo.createDemoFactory())));
+
+ JButton exitDisposer = mkDisposerButton(frame);
+ panel.add(exitDisposer);
+
+ panel.setMaximumSize(new Dimension(Integer.MAX_VALUE,
+ panel.getPreferredSize().height));
+ exitDisposer.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ System.exit(1);
+ }
+ });
+ return panel;
+ }
+
+ /**
+ * Creates and returns the main desktop.
+ *
+ * @return the main desktop
+ */
+ private JDesktopPane createDesktop()
+ {
+ JDesktopPane d = new DemoDesktop();
+ d.setPreferredSize(new Dimension(900, 500));
+ return d;
+ }
+
+ /**
+ * This Action is used to switch Metal themes.
+ */
+ class ChangeThemeAction extends AbstractAction
+ {
+ /**
+ * The theme to switch to.
+ */
+ MetalTheme theme;
+
+ /**
+ * Creates a new ChangeThemeAction for the specified theme.
+ *
+ * @param t the theme to switch to
+ */
+ ChangeThemeAction(MetalTheme t)
+ {
+ theme = t;
+ putValue(NAME, t.getName());
+ }
+
+ /**
+ * Changes the theme to the one specified in the constructor.
+ *
+ * @param event the action event that triggered this action
+ */
+ public void actionPerformed(ActionEvent event)
+ {
+ MetalLookAndFeel.setCurrentTheme(theme);
+ try
+ {
+ // Only switch theme if we have a metal L&F. It is still necessary
+ // to install a new MetalLookAndFeel instance.
+ if (UIManager.getLookAndFeel() instanceof MetalLookAndFeel)
+ UIManager.setLookAndFeel(new MetalLookAndFeel());
+ }
+ catch (UnsupportedLookAndFeelException ex)
+ {
+ ex.printStackTrace();
+ }
+ SwingUtilities.updateComponentTreeUI(frame);
+ }
+
+ }
+
+ /**
+ * This Action is used to switch Metal themes.
+ */
+ class ChangeLAFAction extends AbstractAction
+ {
+ /**
+ * The theme to switch to.
+ */
+ private UIManager.LookAndFeelInfo laf;
+
+ /**
+ * Creates a new ChangeLAFAction for the specified L&F.
+ *
+ * @param l the L&F to switch to
+ */
+ ChangeLAFAction(UIManager.LookAndFeelInfo l)
+ {
+ laf = l;
+ putValue(NAME, laf.getName());
+ }
+
+ /**
+ * Changes the theme to the one specified in the constructor.
+ *
+ * @param event the action event that triggered this action
+ */
+ public void actionPerformed(ActionEvent event)
+ {
+ try
+ {
+ UIManager.setLookAndFeel(laf.getClassName());
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+
+ SwingUtilities.updateComponentTreeUI(frame);
+ themesMenu.setEnabled(laf.getClassName()
+ .equals("javax.swing.plaf.metal.MetalLookAndFeel"));
+ }
+ }
+
+ /**
+ * An implementation of BasicLookAndFeel which can be instantiated.
+ *
+ * @author Robert Schuster (robertschuster@fsfe.org)
+ *
+ */
+ public static class InstantiableBasicLookAndFeel extends BasicLookAndFeel
+ {
+ public String getDescription()
+ {
+ return "An instantiable implementation of BasicLookAndFeel";
+ }
+
+ public String getID()
+ {
+ return "instantiableBasicLookAndFeel";
+ }
+
+ public String getName()
+ {
+ return "Instantiable Basic Look And Feel";
+ }
+
+ public boolean isNativeLookAndFeel()
+ {
+ return false;
+ }
+
+ public boolean isSupportedLookAndFeel()
+ {
+ return true;
+ }
+ }
+
+}
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/DemoDesktop.java b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/DemoDesktop.java
new file mode 100644
index 000000000..edfaf36b2
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/DemoDesktop.java
@@ -0,0 +1,82 @@
+/* DemoDesktop.java -- A custom desktop for the demo
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath 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, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.examples.swing;
+
+import java.awt.Graphics;
+
+import javax.swing.ImageIcon;
+import javax.swing.JDesktopPane;
+
+/**
+ * A customized Desktop for the GNU Classpath Swing demo that paints the
+ * GNU Classpath Icon in the middle of the desktop.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ */
+public class DemoDesktop
+ extends JDesktopPane
+{
+
+ /**
+ * The icon that's painted centered on the desktop.
+ */
+ private ImageIcon image;
+
+ /**
+ * Creates a new desktop.
+ */
+ DemoDesktop()
+ {
+ super();
+ String badge = "/gnu/classpath/examples/icons/badge.png";
+ image = new ImageIcon(getClass().getResource(badge));
+ }
+
+ /**
+ * Paints the desktop including the icon.
+ *
+ * @param g the graphics to use for painting
+ */
+ protected void paintComponent(Graphics g)
+ {
+ super.paintComponent(g);
+ image.paintIcon(this, g, (getWidth() - image.getIconWidth()) / 2,
+ (getHeight() - image.getIconHeight()) / 2);
+ }
+}
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/DemoFactory.java b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/DemoFactory.java
new file mode 100644
index 000000000..0320f31e3
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/DemoFactory.java
@@ -0,0 +1,57 @@
+/* DemoFactory.java -- Creates components used as separate Swing demos
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath 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, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.examples.swing;
+
+import javax.swing.JComponent;
+
+/**
+ * Creates components used in the Swing demo as separate demos.
+ *
+ * @author Roman Kennke (kennke@aicas.de)
+ */
+public interface DemoFactory
+{
+
+ /**
+ * Creates the component that should be as demo application.
+ *
+ * @return the component that should be as demo application
+ */
+ JComponent createDemo();
+}
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/DocumentFilterDemo.java b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/DocumentFilterDemo.java
new file mode 100644
index 000000000..b338e4380
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/DocumentFilterDemo.java
@@ -0,0 +1,288 @@
+/* DpocumentFilterDemo.java -- An example for the DocumentFilter class.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath examples.
+
+GNU Classpath 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, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+*/
+
+
+package gnu.classpath.examples.swing;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.GridLayout;
+import java.awt.Toolkit;
+import java.awt.datatransfer.Clipboard;
+import java.awt.datatransfer.StringSelection;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JComponent;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+import javax.swing.SwingUtilities;
+import javax.swing.text.AbstractDocument;
+import javax.swing.text.AttributeSet;
+import javax.swing.text.BadLocationException;
+import javax.swing.text.DocumentFilter;
+
+/**
+ * A demonstration of the <code>javax.swing.text.DocumentFilter</code> class.
+ *
+ * <p>Similar to a dialog in a popular programming IDE the user can insert
+ * a CVS URL into a textfield and the filter will split the components apart
+ * and will put them into the right textfields saving the user a lot of
+ * typing time.</p>
+ *
+ * @author Robert Schuster
+ */
+public class DocumentFilterDemo
+ extends JPanel
+ implements ActionListener
+{
+ JTextField target;
+
+ JTextField host;
+ JTextField repositoryPath;
+ JTextField user;
+ JTextField password;
+ JComboBox connectionType;
+
+ /**
+ * Creates a new demo instance.
+ */
+ public DocumentFilterDemo()
+ {
+ createContent();
+ // initFrameContent() is only called (from main) when running this app
+ // standalone
+ }
+
+ /**
+ * When the demo is run independently, the frame is displayed, so we should
+ * initialise the content panel (including the demo content and a close
+ * button). But when the demo is run as part of the Swing activity board,
+ * only the demo content panel is used, the frame itself is never displayed,
+ * so we can avoid this step.
+ */
+ void initFrameContent()
+ {
+ JPanel closePanel = new JPanel();
+ JButton closeButton = new JButton("Close");
+ closeButton.setActionCommand("CLOSE");
+ closeButton.addActionListener(this);
+ closePanel.add(closeButton);
+ add(closePanel, BorderLayout.SOUTH);
+ }
+
+ private void createContent()
+ {
+ setLayout(new BorderLayout());
+
+ JPanel panel = new JPanel(new GridLayout(7, 2));
+ panel.add(new JLabel("CVS URL:"));
+ panel.add(target = new JTextField(20));
+ target.setBackground(Color.RED);
+
+ panel.add(new JLabel("Host:"));
+ panel.add(host = new JTextField(20));
+
+ panel.add(new JLabel("Repository Path:"));
+ panel.add(repositoryPath = new JTextField(20));
+
+ panel.add(new JLabel("Username:"));
+ panel.add(user = new JTextField(20));
+
+ panel.add(new JLabel("Password:"));
+ panel.add(password = new JTextField(20));
+
+ panel.add(new JLabel("Connection Type:"));
+ panel.add(connectionType = new JComboBox());
+
+ JButton helpButton = new JButton("Help");
+ panel.add(helpButton);
+
+ helpButton.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent ae)
+ {
+ JOptionPane.showMessageDialog(DocumentFilterDemo.this,
+ "Paste a CVS URL into the red " +
+ "textfield.\nIf you do not want to " +
+ "look up a CVS URL yourself click " +
+ "on the 'provide me an example' " +
+ "button.\nThis will paste a proper " +
+ "string into your clipboard.");
+ }
+ });
+
+ JButton exampleButton = new JButton("Provide me an example!");
+ panel.add(exampleButton);
+ exampleButton.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent ae)
+ {
+ try
+ {
+ Toolkit tk = Toolkit.getDefaultToolkit();
+ Clipboard cb = tk.getSystemSelection();
+ StringSelection selection
+ = new StringSelection(":extssh:gnu@cvs.savannah.gnu.org:" +
+ "/cvs/example/project");
+
+ cb.setContents(selection, selection);
+
+ // Confirm success with a beep.
+ tk.beep();
+ }
+ catch (IllegalStateException ise)
+ {
+ JOptionPane.showMessageDialog(DocumentFilterDemo.this,
+ "Clipboard is currently" +
+ " unavailable.",
+ "Error",
+ JOptionPane.ERROR_MESSAGE);
+ }
+ }
+ });
+
+ connectionType.addItem("pserver");
+ connectionType.addItem("ext");
+ connectionType.addItem("extssh");
+
+ add(panel);
+
+ AbstractDocument doc = (AbstractDocument) target.getDocument();
+ doc.setDocumentFilter(new CVSFilter());
+ }
+
+ public void actionPerformed(ActionEvent e)
+ {
+ if (e.getActionCommand().equals("CLOSE"))
+ System.exit(0);
+
+ }
+
+ public static void main(String[] args)
+ {
+ SwingUtilities.invokeLater
+ (new Runnable()
+ {
+ public void run()
+ {
+ DocumentFilterDemo app = new DocumentFilterDemo();
+ app.initFrameContent();
+ JFrame frame = new JFrame("DocumentFilterDemo");
+ frame.getContentPane().add(app);
+ frame.pack();
+ frame.setVisible(true);
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ }
+ });
+ }
+
+ /**
+ * Returns a DemoFactory that creates a DocumentFilterDemo.
+ *
+ * @return a DemoFactory that creates a DocumentFilterDemo
+ */
+ public static DemoFactory createDemoFactory()
+ {
+ return new DemoFactory()
+ {
+ public JComponent createDemo()
+ {
+ return new DocumentFilterDemo();
+ }
+ };
+ }
+
+ class CVSFilter extends DocumentFilter
+ {
+ // example: pserver:anonymous@cvs.sourceforge.net:/cvsroot/fmj
+ String cvsPattern = ":?(pserver|ext|extssh):(\\w)+(:(\\w)+)?@(\\w|\\.)+:/(\\w|/)*";
+
+ public void insertString(DocumentFilter.FilterBypass fb,
+ int offset, String string,
+ AttributeSet attr)
+ throws BadLocationException
+ {
+ filterString(fb, offset, 0, string, attr, true);
+ }
+
+ public void replace(DocumentFilter.FilterBypass fb,
+ int offset, int length,
+ String string,
+ AttributeSet attr)
+ throws BadLocationException
+ {
+ filterString(fb, offset, length, string, attr, false);
+ }
+
+ public void filterString(DocumentFilter.FilterBypass fb,
+ int offset, int length, String string,
+ AttributeSet attr, boolean insertion)
+ throws BadLocationException
+ {
+ if(string.matches(cvsPattern))
+ {
+ // Split off the connection type part.
+ String[] result = string.split(":", 2);
+
+ // If the string contained a leading colon, result[0]
+ // will be empty at that point. We simply repeat the split
+ // operation on the remaining string and continue.
+ if(result[0].equals(""))
+ result = result[1].split(":", 2);
+
+ connectionType.setSelectedItem(result[0]);
+
+ // Split off the username and password part
+ result = result[1].split("@", 2);
+
+ // Break username and password in half
+ String[] userCredentials = result[0].split(":");
+ user.setText(userCredentials[0]);
+
+ // If the result has two entries the second one will
+ // be the password.
+ if (userCredentials.length == 2)
+ password.setText(userCredentials[1]);
+
+ // Now break the host part apart.
+ result = result[1].split(":");
+
+ host.setText(result[0]);
+
+ repositoryPath.setText(result[1]);
+ }
+
+ // The unmodified string is put into the document.
+ if (insertion)
+ fb.insertString(offset, string, attr);
+ else
+ fb.replace(offset, length, string, attr);
+ }
+
+ }
+
+}
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/FileChooserDemo.java b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/FileChooserDemo.java
new file mode 100644
index 000000000..86cc015d9
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/FileChooserDemo.java
@@ -0,0 +1,264 @@
+/* FileChooserDemo.java -- An example showing file choosers in Swing.
+ Copyright (C) 2005, 2006, Free Software Foundation, Inc.
+
+This file is part of GNU Classpath examples.
+
+GNU Classpath 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, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+*/
+
+package gnu.classpath.examples.swing;
+
+import java.awt.BorderLayout;
+import java.awt.GridLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.io.File;
+
+import javax.swing.BorderFactory;
+import javax.swing.DefaultListModel;
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.JFileChooser;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JList;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.SwingUtilities;
+import javax.swing.filechooser.FileFilter;
+
+/**
+ * A simple demo showing the {@link JFileChooser} component used in different
+ * ways.
+ */
+public class FileChooserDemo
+ extends JPanel
+ implements ActionListener
+{
+ /**
+ * A file filter for Java source files.
+ */
+ static class JavaFileFilter extends FileFilter
+ {
+ public String getDescription()
+ {
+ return "Java Source Files (.java)";
+ }
+ public boolean accept(File f)
+ {
+ if (f != null)
+ {
+ return f.getName().endsWith(".java") || f.isDirectory();
+ }
+ else
+ return false;
+ }
+ }
+
+ /** A label to display the selected file. */
+ JLabel selectedFileLabel;
+
+ /**
+ * A list showing the selected files (where multi selections are
+ * allowed).
+ */
+ JList selectedFilesList;
+
+ /** A label to display the return code for the JFileChooser. */
+ JLabel returnCodeLabel;
+
+ /**
+ * Creates a new demo instance.
+ */
+ public FileChooserDemo()
+ {
+ super();
+ createContent();
+ }
+
+ /**
+ * When the demo is run independently, the frame is displayed, so we should
+ * initialise the content panel (including the demo content and a close
+ * button). But when the demo is run as part of the Swing activity board,
+ * only the demo content panel is used, the frame itself is never displayed,
+ * so we can avoid this step.
+ */
+ void initFrameContent()
+ {
+ JPanel closePanel = new JPanel();
+ JButton closeButton = new JButton("Close");
+ closeButton.setActionCommand("CLOSE");
+ closeButton.addActionListener(this);
+ closePanel.add(closeButton);
+ add(closePanel, BorderLayout.SOUTH);
+ }
+
+ /**
+ * Returns a panel with the demo content. The panel
+ * uses a BorderLayout(), and the BorderLayout.SOUTH area
+ * is empty, to allow callers to add controls to the
+ * bottom of the panel if they want to (a close button is
+ * added if this demo is being run as a standalone demo).
+ */
+ private void createContent()
+ {
+ setLayout(new BorderLayout());
+
+ // create a panel of buttons to select the different styles of file
+ // chooser...
+ JPanel buttonPanel = new JPanel(new GridLayout(5, 1));
+ JButton openButton = new JButton("Open...");
+ openButton.setActionCommand("OPEN");
+ openButton.addActionListener(this);
+ buttonPanel.add(openButton);
+ JButton saveButton = new JButton("Save...");
+ saveButton.setActionCommand("SAVE");
+ saveButton.addActionListener(this);
+ buttonPanel.add(saveButton);
+ JButton queryButton = new JButton("Select Directory...");
+ queryButton.setActionCommand("SELECT_DIRECTORY");
+ queryButton.addActionListener(this);
+ buttonPanel.add(queryButton);
+ JButton openJavaButton = new JButton("Open Java file...");
+ openJavaButton.setActionCommand("OPEN_JAVA");
+ openJavaButton.addActionListener(this);
+ buttonPanel.add(openJavaButton);
+ JButton openMultiButton = new JButton("Open multiple files...");
+ openMultiButton.setActionCommand("OPEN_MULTI");
+ openMultiButton.addActionListener(this);
+ buttonPanel.add(openMultiButton);
+ add(buttonPanel, BorderLayout.WEST);
+
+ // create a panel to display the selected file(s) and the return code
+ JPanel displayPanel = new JPanel(new BorderLayout());
+
+ selectedFileLabel = new JLabel("-");
+ selectedFileLabel.setBorder(BorderFactory.createTitledBorder("Selected File/Directory: "));
+ displayPanel.add(selectedFileLabel, BorderLayout.NORTH);
+
+ selectedFilesList = new JList();
+ JScrollPane sp = new JScrollPane(selectedFilesList);
+ sp.setBorder(BorderFactory.createTitledBorder("Selected Files: "));
+ displayPanel.add(sp);
+
+ returnCodeLabel = new JLabel("0");
+ returnCodeLabel.setBorder(BorderFactory.createTitledBorder("Return Code:"));
+ displayPanel.add(returnCodeLabel, BorderLayout.SOUTH);
+
+ add(displayPanel);
+ }
+
+ /**
+ * When the user clicks on a button, launch the appropriate file chooser
+ * and report the results.
+ *
+ * @param e the event.
+ */
+ public void actionPerformed(ActionEvent e)
+ {
+ int option = 0;
+ File selectedFile = null;
+ File[] selectedFiles = new File[0];
+
+ if (e.getActionCommand().equals("CLOSE"))
+ {
+ System.exit(0);
+ }
+ else if (e.getActionCommand().equals("OPEN"))
+ {
+ JFileChooser chooser = new JFileChooser();
+ option = chooser.showOpenDialog(this);
+ selectedFile = chooser.getSelectedFile();
+ selectedFiles = chooser.getSelectedFiles();
+ }
+ else if (e.getActionCommand().equals("OPEN_MULTI"))
+ {
+ JFileChooser chooser = new JFileChooser();
+ chooser.setMultiSelectionEnabled(true);
+ option = chooser.showOpenDialog(this);
+ selectedFile = chooser.getSelectedFile();
+ selectedFiles = chooser.getSelectedFiles();
+ }
+ else if (e.getActionCommand().equals("OPEN_JAVA"))
+ {
+ JFileChooser chooser = new JFileChooser();
+ chooser.setAcceptAllFileFilterUsed(false);
+ chooser.setFileFilter(new JavaFileFilter());
+ option = chooser.showOpenDialog(this);
+ selectedFile = chooser.getSelectedFile();
+ selectedFiles = chooser.getSelectedFiles();
+ }
+ else if (e.getActionCommand().equals("SAVE"))
+ {
+ JFileChooser chooser = new JFileChooser();
+ option = chooser.showSaveDialog(this);
+ selectedFile = chooser.getSelectedFile();
+ selectedFiles = chooser.getSelectedFiles();
+ }
+ else if (e.getActionCommand().equals("SELECT_DIRECTORY"))
+ {
+ JFileChooser chooser = new JFileChooser();
+ chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
+ option = chooser.showDialog(this, "Select");
+ selectedFile = chooser.getSelectedFile();
+ selectedFiles = chooser.getSelectedFiles();
+ }
+
+ // display the selection and return code
+ if (selectedFile != null)
+ selectedFileLabel.setText(selectedFile.toString());
+ else
+ selectedFileLabel.setText("null");
+ DefaultListModel listModel = new DefaultListModel();
+ for (int i = 0; i < selectedFiles.length; i++)
+ listModel.addElement(selectedFiles[i]);
+ selectedFilesList.setModel(listModel);
+ returnCodeLabel.setText(Integer.toString(option));
+ }
+
+ public static void main(String[] args)
+ {
+ SwingUtilities.invokeLater
+ (new Runnable()
+ {
+ public void run()
+ {
+ FileChooserDemo app = new FileChooserDemo();
+ app.initFrameContent();
+ JFrame frame = new JFrame("FileChooser Demo");
+ frame.getContentPane().add(app);
+ frame.pack();
+ frame.setVisible(true);
+ }
+ });
+ }
+
+ /**
+ * Returns a DemoFactory that creates a FileChooserDemo.
+ *
+ * @return a DemoFactory that creates a FileChooserDemo
+ */
+ public static DemoFactory createDemoFactory()
+ {
+ return new DemoFactory()
+ {
+ public JComponent createDemo()
+ {
+ return new FileChooserDemo();
+ }
+ };
+ }
+}
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/HtmlDemo.java b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/HtmlDemo.java
new file mode 100644
index 000000000..1a24ae276
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/HtmlDemo.java
@@ -0,0 +1,380 @@
+/* HtmlDemo.java -- HTML viewer demo
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath 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, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.examples.swing;
+
+import java.awt.BorderLayout;
+import java.awt.Dimension;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.LinkedList;
+
+import javax.swing.BoxLayout;
+import javax.swing.Icon;
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.JEditorPane;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextField;
+import javax.swing.JTextPane;
+import javax.swing.JToolBar;
+import javax.swing.SwingUtilities;
+import javax.swing.event.HyperlinkEvent;
+import javax.swing.event.HyperlinkListener;
+import javax.swing.text.html.FormSubmitEvent;
+
+/**
+ * Parses and displays HTML content.
+ *
+ * @author Audrius Meskauskas (audriusa@bioinformatics.org)
+ */
+public class HtmlDemo extends JPanel
+{
+
+ private class LoadActionListener
+ implements ActionListener
+ {
+
+ public void actionPerformed(ActionEvent event)
+ {
+ String urlStr = url.getText();
+ try
+ {
+ setPage(new URL(url.getText()));
+ }
+ catch (MalformedURLException ex)
+ {
+ // Do something more useful here.
+ ex.printStackTrace();
+ }
+ }
+ }
+
+ /**
+ * Setting this to true causes the parsed element structure to be dumped.
+ */
+ private static final boolean DEBUG = true;
+
+ /**
+ * The URL entry field.
+ */
+ JTextField url = new JTextField();
+
+ JTextPane html = new JTextPane();
+
+ int n;
+
+ /**
+ * The browsing history.
+ *
+ * Package private to avoid accessor method.
+ */
+ LinkedList history;
+
+ public HtmlDemo()
+ {
+ super();
+ history = new LinkedList();
+ createContent();
+ }
+
+ /**
+ * Returns a panel with the demo content. The panel uses a BorderLayout(), and
+ * the BorderLayout.SOUTH area is empty, to allow callers to add controls to
+ * the bottom of the panel if they want to (a close button is added if this
+ * demo is being run as a standalone demo).
+ */
+ private void createContent()
+ {
+ setLayout(new BorderLayout());
+
+ JEditorPane.registerEditorKitForContentType("text/html",
+ BrowserEditorKit.class.getName());
+ html.setEditable(false);
+ html.addHyperlinkListener(new HyperlinkListener()
+ {
+
+ public void hyperlinkUpdate(HyperlinkEvent event)
+ {
+ if (event instanceof FormSubmitEvent)
+ {
+ submitForm((FormSubmitEvent) event);
+ }
+ else
+ {
+ URL u = event.getURL();
+ if (u != null)
+ {
+ setPage(u);
+ }
+ }
+ }
+
+ });
+
+ JScrollPane scroller = new JScrollPane(html);
+ JPanel urlPanel = new JPanel();
+ urlPanel.setLayout(new BoxLayout(urlPanel, BoxLayout.X_AXIS));
+ url.setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
+ LoadActionListener action = new LoadActionListener();
+ url.addActionListener(action);
+ urlPanel.add(url);
+ JButton loadButton = new JButton("go");
+ urlPanel.add(loadButton);
+ loadButton.addActionListener(action);
+
+ // Setup control panel.
+ JToolBar controlPanel = createToolBar();
+ JPanel browserPanel = new JPanel();
+ browserPanel.setLayout(new BorderLayout());
+ browserPanel.add(urlPanel, BorderLayout.NORTH);
+ browserPanel.add(scroller, BorderLayout.CENTER);
+ add(controlPanel, BorderLayout.NORTH);
+ add(browserPanel, BorderLayout.CENTER);
+
+ // Load start page.
+ try
+ {
+ URL startpage = getClass().getResource("welcome.html");
+ html.setPage(startpage);
+ url.setText(startpage.toString());
+ history.addLast(startpage);
+ }
+ catch (Exception ex)
+ {
+ System.err.println("couldn't load page: "/* + startpage*/);
+ ex.printStackTrace();
+ }
+ setPreferredSize(new Dimension(800, 600));
+ }
+
+
+ /**
+ * Creates the toolbar with the control buttons.
+ *
+ * @return the toolbar with the control buttons
+ */
+ JToolBar createToolBar()
+ {
+ JToolBar tb = new JToolBar();
+ Icon backIcon = Demo.getIcon("/gnu/classpath/examples/icons/back.png",
+ "back");
+ JButton back = new JButton(backIcon);
+ back.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent ev)
+ {
+ if (history.size() > 1)
+ {
+ URL last = (URL) history.removeLast();
+ last = (URL) history.getLast();
+ url.setText(last.toString());
+ try
+ {
+ html.setPage(last);
+ }
+ catch (IOException ex)
+ {
+ // Do something more useful.
+ ex.printStackTrace();
+ }
+ }
+ }
+ });
+ tb.add(back);
+ Icon reloadIcon = Demo.getIcon("/gnu/classpath/examples/icons/reload.png",
+ "reload");
+ JButton reload = new JButton(reloadIcon);
+ reload.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent ev)
+ {
+ if (history.size() > 0)
+ {
+ URL last = (URL) history.getLast();
+ url.setText(last.toString());
+ try
+ {
+ html.setPage(last);
+ }
+ catch (IOException ex)
+ {
+ // Do something more useful.
+ ex.printStackTrace();
+ }
+ }
+ }
+ });
+ tb.add(reload);
+ return tb;
+ }
+
+ /**
+ * The executable method to display the editable table.
+ *
+ * @param args
+ * unused.
+ */
+ public static void main(String[] args)
+ {
+ SwingUtilities.invokeLater
+ (new Runnable()
+ {
+ public void run()
+ {
+ HtmlDemo demo = new HtmlDemo();
+ JFrame frame = new JFrame();
+ frame.getContentPane().add(demo);
+ frame.setSize(new Dimension(750, 480));
+ frame.setVisible(true);
+ }
+ });
+ }
+
+ /**
+ * Helper method to navigate to a new URL.
+ *
+ * @param u the new URL to navigate to
+ */
+ void setPage(URL u)
+ {
+ try
+ {
+ url.setText(u.toString());
+ html.setPage(u);
+ history.addLast(u);
+ }
+ catch (IOException ex)
+ {
+ // Do something more useful here.
+ ex.printStackTrace();
+ }
+ }
+
+ /**
+ * Submits a form when a FormSubmitEvent is received. The HTML API
+ * provides automatic form submit but when this is enabled we don't
+ * receive any notification and can't update our location field.
+ *
+ * @param ev the form submit event
+ */
+ void submitForm(FormSubmitEvent ev)
+ {
+ URL url = ev.getURL();
+ String data = ev.getData();
+ FormSubmitEvent.MethodType method = ev.getMethod();
+ if (method == FormSubmitEvent.MethodType.POST)
+ {
+ try
+ {
+ URLConnection conn = url.openConnection();
+ postData(conn, data);
+ }
+ catch (IOException ex)
+ {
+ // Deal with this.
+ ex.printStackTrace();
+ }
+ }
+ else
+ {
+ try
+ {
+ url = new URL(url.toString() + "?" + data);
+ }
+ catch (MalformedURLException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+ setPage(url);
+ }
+
+ /**
+ * Posts the form data for forms with HTTP POST method.
+ *
+ * @param conn the connection
+ * @param data the form data
+ */
+ private void postData(URLConnection conn, String data)
+ {
+ conn.setDoOutput(true);
+ PrintWriter out = null;
+ try
+ {
+ out = new PrintWriter(new OutputStreamWriter(conn.getOutputStream()));
+ out.print(data);
+ out.flush();
+ }
+ catch (IOException ex)
+ {
+ // Deal with this!
+ ex.printStackTrace();
+ }
+ finally
+ {
+ if (out != null)
+ out.close();
+ }
+ }
+
+ /**
+ * Returns a DemoFactory that creates a HtmlDemo.
+ *
+ * @return a DemoFactory that creates a HtmlDemo
+ */
+ public static DemoFactory createDemoFactory()
+ {
+ return new DemoFactory()
+ {
+ public JComponent createDemo()
+ {
+ return new HtmlDemo();
+ }
+ };
+ }
+}
+
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/ListDemo.java b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/ListDemo.java
new file mode 100644
index 000000000..7ed15beff
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/ListDemo.java
@@ -0,0 +1,231 @@
+/* ListDemo.java -- Demostrates JList
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath 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, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.examples.swing;
+
+import java.awt.BorderLayout;
+import java.awt.Component;
+import java.awt.GridLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.DefaultListCellRenderer;
+import javax.swing.DefaultListModel;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JComponent;
+import javax.swing.JFrame;
+import javax.swing.JList;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JSplitPane;
+import javax.swing.ListCellRenderer;
+import javax.swing.SwingUtilities;
+
+public class ListDemo
+ extends JPanel
+ implements ActionListener
+{
+
+ private static class LabelCellRenderer
+ extends DefaultListCellRenderer
+ {
+ public Component getListCellRendererComponent(JList list,
+ Object value,
+ int index,
+ boolean isSelected,
+ boolean cellHasFocus)
+ {
+ Component c = super.getListCellRendererComponent(list, value, index,
+ isSelected,
+ cellHasFocus);
+ return c;
+ }
+ }
+
+ private static class CheckCellRenderer
+ extends JCheckBox
+ implements ListCellRenderer
+ {
+ public Component getListCellRendererComponent(JList list,
+ Object value,
+ int index,
+ boolean isSelected,
+ boolean cellHasFocus)
+ {
+ setSelected(isSelected);
+ setText(value.toString());
+
+ return this;
+ }
+ }
+
+ ListDemo()
+ {
+ super();
+ createContent();
+ }
+
+ private void createContent()
+ {
+
+ String foo[] = new String[] {
+ "non alcoholic ",
+ "carbonated ",
+ "malted ",
+ "fresh squeezed ",
+ "imported ",
+ "high fructose ",
+ "enriched "
+ };
+
+ String bar[] = new String[] {
+ "orange juice",
+ "ginger beer",
+ "yak milk",
+ "corn syrup",
+ "herbal remedy"
+ };
+
+ final DefaultListModel mod = new DefaultListModel();
+ final JList list1 = new JList(mod);
+ final JList list2 = new JList(mod);
+
+ list2.setSelectionModel(list1.getSelectionModel());
+ for (int i = 0; i < bar.length; ++i)
+ for (int j = 0; j < foo.length; ++j)
+ mod.addElement(foo[j] + bar[i]);
+
+ list1.setCellRenderer(new LabelCellRenderer());
+ list2.setCellRenderer(new CheckCellRenderer());
+
+ JButton add = new JButton("add element");
+ add.addActionListener(new ActionListener()
+ {
+ int i = 0;
+ public void actionPerformed(ActionEvent e)
+ {
+ mod.addElement("new element " + i);
+ ++i;
+ }
+ });
+
+ JButton del = new JButton("delete selected");
+ del.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ for (int i = 0; i < mod.getSize(); ++i)
+ if (list1.isSelectedIndex(i))
+ mod.remove(i);
+ }
+ });
+
+
+ JSplitPane splitter = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
+ splitter.add(new JScrollPane(list1), JSplitPane.LEFT);
+ splitter.add(new JScrollPane(list2), JSplitPane.RIGHT);
+
+ setLayout(new BorderLayout());
+ JPanel p2 = new JPanel();
+ p2.setLayout(new GridLayout(1, 2));
+ p2.add(add);
+ p2.add(del);
+
+ add(p2, BorderLayout.NORTH);
+ add(splitter, BorderLayout.CENTER);
+ }
+
+ public void actionPerformed(ActionEvent e)
+ {
+ if (e.getActionCommand().equals("CLOSE"))
+ {
+ System.exit(0);
+ }
+ }
+
+ /**
+ * When the demo is run independently, the frame is displayed, so we should
+ * initialise the content panel (including the demo content and a close
+ * button). But when the demo is run as part of the Swing activity board,
+ * only the demo content panel is used, the frame itself is never displayed,
+ * so we can avoid this step.
+ */
+ void initFrameContent()
+ {
+ JPanel closePanel = new JPanel();
+ JButton closeButton = new JButton("Close");
+ closeButton.setActionCommand("CLOSE");
+ closeButton.addActionListener(this);
+ closePanel.add(closeButton);
+ add(closePanel, BorderLayout.SOUTH);
+ }
+
+ public static void main(String[] args)
+ {
+ SwingUtilities.invokeLater
+ (new Runnable()
+ {
+ public void run()
+ {
+ ListDemo app = new ListDemo();
+ app.initFrameContent();
+ JFrame frame = new JFrame("List Demo");
+ frame.getContentPane().add(app);
+ frame.pack();
+ frame.setVisible(true);
+ }
+ });
+ }
+
+ /**
+ * Returns a DemoFactory that creates a ListDemo.
+ *
+ * @return a DemoFactory that creates a ListDemo
+ */
+ public static DemoFactory createDemoFactory()
+ {
+ return new DemoFactory()
+ {
+ public JComponent createDemo()
+ {
+ return new ListDemo();
+ }
+ };
+ }
+}
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/MetalThemeEditor.java b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/MetalThemeEditor.java
new file mode 100644
index 000000000..d3be0b85d
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/MetalThemeEditor.java
@@ -0,0 +1,585 @@
+/* MetalThemeEditor.java -- Edit themes using this application
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath 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, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.examples.swing;
+
+import gnu.javax.swing.plaf.metal.CustomizableTheme;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Graphics;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+import java.awt.Window;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+
+import javax.swing.BorderFactory;
+import javax.swing.Box;
+import javax.swing.BoxLayout;
+import javax.swing.Icon;
+import javax.swing.JButton;
+import javax.swing.JColorChooser;
+import javax.swing.JComponent;
+import javax.swing.JFileChooser;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+import javax.swing.plaf.metal.MetalLookAndFeel;
+
+/**
+ * This application serves two purposes: 1. demonstrate the color chooser
+ * component, 2. make creating new Metal themes as easy as possible.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ */
+public class MetalThemeEditor
+ extends JPanel
+{
+ /**
+ * An icon to display a chosen color in a button.
+ */
+ private class ColorIcon implements Icon
+ {
+ /**
+ * The color to be shown on the icon.
+ */
+ Color color;
+
+ /**
+ * Creates a new ColorIcon.
+ *
+ * @param c the color to be displayed
+ */
+ ColorIcon(Color c)
+ {
+ color = c;
+ }
+
+ /**
+ * Returns the icon height, which is 10.
+ *
+ * @return 10
+ */
+ public int getIconHeight()
+ {
+ return 10;
+ }
+
+ /**
+ * Returns the icon width, which is 30.
+ *
+ * @return 30
+ */
+ public int getIconWidth()
+ {
+ return 30;
+ }
+
+ /**
+ * Paints the icon.
+ *
+ * @param c the component to paint on
+ * @param g the graphics to use
+ * @param x the x location
+ * @param y the y location
+ */
+ public void paintIcon(Component c, Graphics g, int x, int y)
+ {
+ g.setColor(color);
+ g.fillRect(x, y, 30, 10);
+ }
+
+ }
+
+ /**
+ * Opens up a color chooser and lets the user select a color for the theme.
+ */
+ private class ChooseColorAction implements ActionListener
+ {
+
+ /**
+ * The button that will get updated when a new color is selected.
+ */
+ private JButton button;
+
+ /**
+ * Specifies which color of the theme should be updated. See constants in
+ * the MetalThemeEditor class.
+ */
+ private int colorType;
+
+ /**
+ * Creates a new ChooseColorAction. The specified button will have its
+ * icon updated to the new color if appropriate.
+ *
+ * @param b the button to update
+ * @param type the color type to update
+ */
+ ChooseColorAction(JButton b, int type)
+ {
+ button = b;
+ colorType = type;
+ }
+
+ /**
+ * Opens a color chooser and lets the user select a color.
+ */
+ public void actionPerformed(ActionEvent event)
+ {
+ Color c = JColorChooser.showDialog(button, "Choose a color",
+ getColor(colorType));
+ if (c != null)
+ {
+ setColor(colorType, c);
+ button.setIcon(new ColorIcon(c));
+ }
+ }
+ }
+
+ /**
+ * Denotes the primary1 color of the theme.
+ */
+ private static final int PRIMARY1 = 0;
+
+ /**
+ * Denotes the primary2 color of the theme.
+ */
+ private static final int PRIMARY2 = 1;
+
+ /**
+ * Denotes the primary3 color of the theme.
+ */
+ private static final int PRIMARY3 = 2;
+
+ /**
+ * Denotes the secondary1 color of the theme.
+ */
+ private static final int SECONDARY1 = 3;
+
+ /**
+ * Denotes the secondary2 color of the theme.
+ */
+ private static final int SECONDARY2 = 4;
+
+ /**
+ * Denotes the secondary3 color of the theme.
+ */
+ private static final int SECONDARY3 = 5;
+
+ /**
+ * The theme that is edited.
+ */
+ CustomizableTheme theme;
+
+ /**
+ * Creates a new instance of the MetalThemeEditor.
+ */
+ MetalThemeEditor()
+ {
+ theme = new CustomizableTheme();
+ setBorder(BorderFactory.createEmptyBorder(12, 12, 11, 11));
+ setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
+ add(createConfigurationPanel());
+ add(Box.createVerticalStrut(17));
+ add(createButtonPanel());
+ }
+
+ /**
+ * Creates the main panel of the MetalThemeEditor. This is the upper
+ * area where the colors can be selected.
+ *
+ * @return the main panel
+ */
+ private JPanel createConfigurationPanel()
+ {
+ JPanel p = new JPanel();
+ p.setLayout(new GridBagLayout());
+ GridBagConstraints c = new GridBagConstraints();
+ c.weightx = 1;
+ c.weighty = 0;
+ c.fill = GridBagConstraints.HORIZONTAL;
+ Insets labelInsets = new Insets(0, 0, 11, 6);
+ Insets buttonInsets = new Insets(0, 0, 11, 0);
+
+ // Primary 1
+ JLabel primary1Label = new JLabel("Primary 1:");
+ c.gridx = 0;
+ c.gridy = 0;
+ c.insets = labelInsets;
+ p.add(primary1Label, c);
+
+ Icon p1Icon = new ColorIcon(theme.getPrimary1());
+ JButton primary1Button = new JButton(p1Icon);
+ primary1Button.addActionListener(new ChooseColorAction(primary1Button,
+ PRIMARY1));
+ //c.weightx = 0;
+ c.gridx = 1;
+ c.insets = buttonInsets;
+ p.add(primary1Button, c);
+ primary1Label.setLabelFor(primary1Button);
+
+ // Primary 2
+ JLabel primary2Label = new JLabel("Primary 2:");
+ c.gridx = 0;
+ c.gridy = 1;
+ c.insets = labelInsets;
+ p.add(primary2Label, c);
+
+ Icon p2Icon = new ColorIcon(theme.getPrimary2());
+ JButton primary2Button = new JButton(p2Icon);
+ primary2Button.addActionListener(new ChooseColorAction(primary2Button,
+ PRIMARY2));
+ c.gridx = 1;
+ c.insets = buttonInsets;
+ p.add(primary2Button, c);
+ primary2Label.setLabelFor(primary2Button);
+
+ // Primary 3
+ JLabel primary3Label = new JLabel("Primary 3:");
+ c.gridx = 0;
+ c.gridy = 2;
+ c.insets = labelInsets;
+ p.add(primary3Label, c);
+
+ Icon p3Icon = new ColorIcon(theme.getPrimary3());
+ JButton primary3Button = new JButton(p3Icon);
+ primary3Button.addActionListener(new ChooseColorAction(primary3Button,
+ PRIMARY3));
+ c.gridx = 1;
+ c.insets = buttonInsets;
+ p.add(primary3Button, c);
+ primary3Label.setLabelFor(primary3Button);
+
+ // Secondary 1
+ JLabel secondary1Label = new JLabel("Secondary 1:");
+ c.gridx = 0;
+ c.gridy = 3;
+ c.insets = labelInsets;
+ p.add(secondary1Label, c);
+
+ Icon s1Icon = new ColorIcon(theme.getSecondary1());
+ JButton secondary1Button = new JButton(s1Icon);
+ secondary1Button.addActionListener(new ChooseColorAction(secondary1Button,
+ SECONDARY1));
+ c.gridx = 1;
+ c.insets = buttonInsets;
+ p.add(secondary1Button, c);
+ secondary1Label.setLabelFor(secondary1Button);
+
+ // Secondary 2
+ JLabel secondary2Label = new JLabel("Secondary 2:");
+ c.gridx = 0;
+ c.gridy = 4;
+ c.insets = labelInsets;
+ p.add(secondary2Label, c);
+
+ Icon s2Icon = new ColorIcon(theme.getSecondary2());
+ JButton secondary2Button = new JButton(s2Icon);
+ secondary2Button.addActionListener(new ChooseColorAction(secondary2Button,
+ SECONDARY2));
+ c.gridx = 1;
+ c.insets = buttonInsets;
+ p.add(secondary2Button, c);
+ secondary2Label.setLabelFor(secondary2Button);
+
+ // Secondary 3
+ JLabel secondary3Label = new JLabel("Secondary 3:");
+ c.gridx = 0;
+ c.gridy = 5;
+ c.insets = labelInsets;
+ p.add(secondary3Label, c);
+
+ Icon s3Icon = new ColorIcon(theme.getSecondary3());
+ JButton secondary3Button = new JButton(s3Icon);
+ secondary3Button.addActionListener(new ChooseColorAction(secondary3Button,
+ SECONDARY3));
+ c.gridx = 1;
+ c.insets = buttonInsets;
+ p.add(secondary3Button, c);
+ secondary3Label.setLabelFor(secondary3Button);
+
+ return p;
+ }
+
+ /**
+ * Creates the button panel at the bottom of the MetalThemeEditor.
+ *
+ * @return the button panel
+ */
+ private JPanel createButtonPanel()
+ {
+ JPanel p = new JPanel();
+ p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
+ p.add(Box.createHorizontalGlue());
+
+ JButton applyButton = new JButton("Apply");
+ applyButton.addActionListener
+ (new ActionListener()
+ {
+ public void actionPerformed(ActionEvent ev)
+ {
+ try
+ {
+ CustomizableTheme copy = (CustomizableTheme) theme.clone();
+ MetalLookAndFeel.setCurrentTheme(copy);
+ UIManager.setLookAndFeel(new MetalLookAndFeel());
+ Window w = SwingUtilities.getWindowAncestor(MetalThemeEditor.this);
+ SwingUtilities.updateComponentTreeUI(w);
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+ });
+ p.add(applyButton);
+
+ p.add(Box.createHorizontalStrut(5));
+
+ JButton exportButton = new JButton("Export as Java File");
+ exportButton.addActionListener
+ (new ActionListener()
+ {
+ public void actionPerformed(ActionEvent ev)
+ {
+ export();
+ }
+ });
+ p.add(exportButton);
+
+ return p;
+ }
+
+ /**
+ * Exports the current theme as Java source file. This will prompt the user
+ * to choose a filename.
+ */
+ void export()
+ {
+ JFileChooser chooser = new JFileChooser();
+ int confirm = chooser.showSaveDialog(this);
+ if (confirm == JFileChooser.APPROVE_OPTION)
+ exportToFile(chooser.getSelectedFile());
+ }
+
+ /**
+ * Writes out the current configured Metal theme as Java source file.
+ *
+ * @param file the file to write into
+ */
+ void exportToFile(File file)
+ {
+ String fileName = file.getName();
+ if (! fileName.endsWith(".java"))
+ {
+ JOptionPane.showMessageDialog(this,
+ "Filename does not denote a Java source file",
+ "Invalid filename",
+ JOptionPane.ERROR_MESSAGE);
+ return;
+ }
+
+ String className = fileName.substring(0, fileName.length() - 5);
+ Color p1 = theme.getPrimary1();
+ Color p2 = theme.getPrimary2();
+ Color p3 = theme.getPrimary3();
+ Color s1 = theme.getSecondary1();
+ Color s2 = theme.getSecondary2();
+ Color s3 = theme.getSecondary3();
+
+ try
+ {
+ FileOutputStream out = new FileOutputStream(file);
+ Writer writer = new OutputStreamWriter(out);
+ writer.write("import javax.swing.plaf.ColorUIResource;\n");
+ writer.write("import javax.swing.plaf.metal.DefaultMetalTheme;\n");
+ writer.write("public class " + className + " extends DefaultMetalTheme\n");
+ writer.write("{\n");
+ writer.write(" protected ColorUIResource getPrimary1()\n");
+ writer.write(" {\n");
+ writer.write(" return new ColorUIResource(" + p1.getRGB() + ");\n");
+ writer.write(" }\n");
+ writer.write(" protected ColorUIResource getPrimary2()\n");
+ writer.write(" {\n");
+ writer.write(" return new ColorUIResource(" + p2.getRGB() + ");\n");
+ writer.write(" }\n");
+ writer.write(" protected ColorUIResource getPrimary3()\n");
+ writer.write(" {\n");
+ writer.write(" return new ColorUIResource(" + p3.getRGB() + ");\n");
+ writer.write(" }\n");
+ writer.write(" protected ColorUIResource getSecondary1()\n");
+ writer.write(" {\n");
+ writer.write(" return new ColorUIResource(" + s1.getRGB() + ");\n");
+ writer.write(" }\n");
+ writer.write(" protected ColorUIResource getSecondary2()\n");
+ writer.write(" {\n");
+ writer.write(" return new ColorUIResource(" + s2.getRGB() + ");\n");
+ writer.write(" }\n");
+ writer.write(" protected ColorUIResource getSecondary3()\n");
+ writer.write(" {\n");
+ writer.write(" return new ColorUIResource(" + s3.getRGB() + ");\n");
+ writer.write(" }\n");
+ writer.write("}\n");
+ writer.close();
+ out.close();
+ }
+ catch (FileNotFoundException ex)
+ {
+ ex.printStackTrace();
+ }
+ catch (IOException ex)
+ {
+ ex.printStackTrace();
+ }
+
+ }
+
+ /**
+ * Returns the color of the theme with the specified type. For the possible
+ * types see the constants of this class.
+ *
+ * @param colorType the color type to fetch from the theme
+ *
+ * @return the current color of the specified type
+ *
+ * @throws IllegalArgumentException for illegal color types
+ */
+ Color getColor(int colorType)
+ {
+ Color color = null;
+ switch (colorType)
+ {
+ case PRIMARY1:
+ color = theme.getPrimary1();
+ break;
+ case PRIMARY2:
+ color = theme.getPrimary2();
+ break;
+ case PRIMARY3:
+ color = theme.getPrimary3();
+ break;
+ case SECONDARY1:
+ color = theme.getSecondary1();
+ break;
+ case SECONDARY2:
+ color = theme.getSecondary2();
+ break;
+ case SECONDARY3:
+ color = theme.getSecondary3();
+ break;
+ default:
+ throw new IllegalArgumentException("Unknown color type: " + colorType);
+ }
+ return color;
+ }
+
+ /**
+ * Sets the color of the specified type in the current theme.
+ *
+ * @param colorType the color type
+ * @param color the color to set
+ *
+ * @throws IllegalArgumentException for illegal color types
+ */
+ void setColor(int colorType, Color color)
+ {
+ switch (colorType)
+ {
+ case PRIMARY1:
+ theme.setPrimary1(color);
+ break;
+ case PRIMARY2:
+ theme.setPrimary2(color);
+ break;
+ case PRIMARY3:
+ theme.setPrimary3(color);
+ break;
+ case SECONDARY1:
+ theme.setSecondary1(color);
+ break;
+ case SECONDARY2:
+ theme.setSecondary2(color);
+ break;
+ case SECONDARY3:
+ theme.setSecondary3(color);
+ break;
+ default:
+ throw new IllegalArgumentException("Illegal color type: " + colorType);
+ }
+ }
+
+ /**
+ * The entry point to the application.
+ *
+ * @param args ignored
+ */
+ public static void main(String[] args)
+ {
+ JFrame f = new JFrame("MetalThemeEditor");
+ f.setContentPane(new MetalThemeEditor());
+ f.pack();
+ f.setVisible(true);
+ }
+
+ /**
+ * Returns a DemoFactory that creates a MetalThemeEditor.
+ *
+ * @return a DemoFactory that creates a MetalThemeEditor
+ */
+ public static DemoFactory createDemoFactory()
+ {
+ return new DemoFactory()
+ {
+ public JComponent createDemo()
+ {
+ return new MetalThemeEditor();
+ }
+ };
+ }
+}
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/MiniDemo.java b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/MiniDemo.java
new file mode 100644
index 000000000..aa8424804
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/MiniDemo.java
@@ -0,0 +1,233 @@
+/* MiniDemo.java -- A Swing demo suitable for embedded environments
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath 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, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.examples.swing;
+
+import java.awt.BorderLayout;
+import java.awt.Font;
+import java.awt.GridLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.Box;
+import javax.swing.BoxLayout;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JComboBox;
+import javax.swing.JFrame;
+import javax.swing.JList;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTabbedPane;
+import javax.swing.JTextField;
+import javax.swing.SwingUtilities;
+import javax.swing.plaf.metal.DefaultMetalTheme;
+import javax.swing.plaf.metal.MetalIconFactory;
+import javax.swing.plaf.metal.MetalLookAndFeel;
+
+/**
+ * A Swing demo suitable for embedded environments (e.g. small display,
+ * b/w graphics etc).
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ */
+public class MiniDemo extends JFrame
+{
+
+ /**
+ * Creates a new MiniDemo instance.
+ */
+ MiniDemo()
+ {
+ createGUI();
+ }
+
+ private void createGUI()
+ {
+ JTabbedPane tabPane = new JTabbedPane(JTabbedPane.TOP,
+ JTabbedPane.SCROLL_TAB_LAYOUT);
+
+ // Setup scrolling list in first tab.
+ Object[] listData = new Object[]{"Milk", "Beer", "Wine", "Water",
+ "Orange juice", "Tea", "Coffee", "Whiskey",
+ "Lemonade", "Apple juice", "Gin Tonic",
+ "Pangalactic Garleblaster", "Coke"};
+ JList list = new JList(listData);
+ JScrollPane sp = new JScrollPane(list);
+ tabPane.addTab("List", sp);
+
+ // Setup some buttons in the second tab.
+ JPanel buttonPanel = new JPanel();
+ buttonPanel.setLayout(new GridLayout(4, 1));
+ // JButtons
+ JPanel jButtonPanel = new JPanel();
+ jButtonPanel.setLayout(new BorderLayout());
+ final JCheckBox buttonState1 = new JCheckBox("Enabled", true);
+ jButtonPanel.add(buttonState1, BorderLayout.EAST);
+ JPanel jButtonContainer = new JPanel();
+ final JButton jButton1 = new JButton("JButton");
+ final JButton jButton2 =
+ new JButton(MetalIconFactory.getInternalFrameDefaultMenuIcon());
+ jButtonContainer.add(jButton1);
+ jButtonContainer.add(jButton2);
+ jButtonPanel.add(jButtonContainer, BorderLayout.CENTER);
+ buttonState1.addActionListener(
+ new ActionListener()
+ {
+ public void actionPerformed(ActionEvent ev)
+ {
+ boolean enabled = buttonState1.isSelected();
+ jButton1.setEnabled(enabled);
+ jButton2.setEnabled(enabled);
+ }
+ });
+ buttonPanel.add(jButtonPanel);
+ // JToggleButtons
+ JPanel jToggleButtonPanel = new JPanel();
+ jToggleButtonPanel.setLayout(new BorderLayout());
+ final JCheckBox buttonState2 = new JCheckBox("Enabled", true);
+ jToggleButtonPanel.add(buttonState2, BorderLayout.EAST);
+ JPanel jToggleButtonContainer = new JPanel();
+ final JButton jToggleButton1 = new JButton("JToggleButton");
+ final JButton jToggleButton2 =
+ new JButton(MetalIconFactory.getInternalFrameDefaultMenuIcon());
+ jToggleButtonContainer.add(jToggleButton1);
+ jToggleButtonContainer.add(jToggleButton2);
+ jToggleButtonPanel.add(jToggleButtonContainer, BorderLayout.CENTER);
+ buttonState2.addActionListener(
+ new ActionListener()
+ {
+ public void actionPerformed(ActionEvent ev)
+ {
+ boolean enabled = buttonState2.isSelected();
+ jToggleButton1.setEnabled(enabled);
+ jToggleButton2.setEnabled(enabled);
+ }
+ });
+ buttonPanel.add(jToggleButtonPanel);
+ tabPane.addTab("Buttons", buttonPanel);
+
+ // ComboBoxes
+ JPanel comboBoxPanel = new JPanel();
+ JComboBox comboBox = new JComboBox(listData);
+ comboBoxPanel.add(comboBox);
+ tabPane.add("ComboBox", comboBoxPanel);
+
+ // TextFields
+ JPanel textFieldPanel = new JPanel();
+ textFieldPanel.setLayout(new BoxLayout(textFieldPanel, BoxLayout.Y_AXIS));
+ textFieldPanel.add(Box.createVerticalStrut(70));
+ JPanel leftAlignedPanel = new JPanel(new BorderLayout());
+ JPanel textFieldPanel1 = new JPanel();
+ textFieldPanel1.setLayout(new BoxLayout(textFieldPanel1,
+ BoxLayout.X_AXIS));
+ final JTextField textfield1 = new JTextField("Hello World!");
+ textfield1.setHorizontalAlignment(JTextField.LEFT);
+ textfield1.setFont(new Font("Dialog", Font.PLAIN, 8));
+ textFieldPanel1.add(textfield1);
+ final JTextField textfield2 = new JTextField("Hello World!");
+ textfield2.setHorizontalAlignment(JTextField.LEFT);
+ textfield2.setFont(new Font("Dialog", Font.ITALIC, 12));
+ textFieldPanel1.add(textfield2);
+ final JTextField textfield3 = new JTextField("Hello World!");
+ textfield3.setHorizontalAlignment(JTextField.LEFT);
+ textfield3.setFont(new Font("Dialog", Font.BOLD, 14));
+ textFieldPanel1.add(textfield3);
+ leftAlignedPanel.add(textFieldPanel1);
+ JPanel statePanel = new JPanel();
+ statePanel.setLayout(new BoxLayout(statePanel, BoxLayout.Y_AXIS));
+ statePanel.add(Box.createVerticalGlue());
+ final JCheckBox enabled1 = new JCheckBox("enabled");
+ enabled1.setSelected(true);
+ enabled1.addActionListener(
+ new ActionListener()
+ {
+ public void actionPerformed(ActionEvent ev)
+ {
+ boolean enabled = enabled1.isSelected();
+ textfield1.setEnabled(enabled);
+ textfield2.setEnabled(enabled);
+ textfield3.setEnabled(enabled);
+ }
+ });
+ statePanel.add(enabled1);
+ final JCheckBox editable1 = new JCheckBox("editable");
+ editable1.setSelected(true);
+ editable1.addActionListener(
+ new ActionListener()
+ {
+ public void actionPerformed(ActionEvent ev)
+ {
+ boolean editable = editable1.isSelected();
+ textfield1.setEditable(editable);
+ textfield2.setEditable(editable);
+ textfield3.setEditable(editable);
+ }
+ });
+ statePanel.add(editable1);
+ statePanel.add(Box.createVerticalGlue());
+ leftAlignedPanel.add(statePanel, BorderLayout.EAST);
+ textFieldPanel.add(leftAlignedPanel);
+ System.err.println(leftAlignedPanel.getPreferredSize());
+ textFieldPanel.add(Box.createVerticalStrut(70));
+ //panel.add(rightAlignedPanel);
+ tabPane.add("TextField", textFieldPanel);
+ setContentPane(tabPane);
+ }
+
+ /**
+ * Starts the demo application.
+ *
+ * @param args the command line arguments (ignored)
+ */
+ public static void main(String[] args)
+ {
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run()
+ {
+ MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());
+ MiniDemo demo = new MiniDemo();
+ demo.setSize(320, 200);
+ demo.setUndecorated(true);
+ demo.setVisible(true);
+ demo.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ }
+ });
+ }
+
+}
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/NavigationFilterDemo.java b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/NavigationFilterDemo.java
new file mode 100644
index 000000000..a7472dfb5
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/NavigationFilterDemo.java
@@ -0,0 +1,205 @@
+/* NavigationFilterDemo.java -- An example for the NavigationFilter class.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath examples.
+
+GNU Classpath 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, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+*/
+
+
+package gnu.classpath.examples.swing;
+
+import java.awt.BorderLayout;
+import java.awt.Point;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JTextArea;
+import javax.swing.SwingConstants;
+import javax.swing.SwingUtilities;
+import javax.swing.text.BadLocationException;
+import javax.swing.text.JTextComponent;
+import javax.swing.text.NavigationFilter;
+import javax.swing.text.Position;
+import javax.swing.text.Utilities;
+
+/**
+ * A demonstration of the <code>javax.swing.text.NavigationFilter</code> class.
+ *
+ * <p>It shows a NavigationFilter which lets you walk word-wise
+ * through a text.</p>
+ *
+ * @author Robert Schuster
+ */
+public class NavigationFilterDemo
+ extends JPanel
+ implements ActionListener
+{
+
+ JTextArea textArea;
+
+ /**
+ * Creates a new demo instance.
+ */
+ public NavigationFilterDemo()
+ {
+ createContent();
+ // initFrameContent() is only called (from main) when running this app
+ // standalone
+ }
+
+ /**
+ * When the demo is run independently, the frame is displayed, so we should
+ * initialise the content panel (including the demo content and a close
+ * button). But when the demo is run as part of the Swing activity board,
+ * only the demo content panel is used, the frame itself is never displayed,
+ * so we can avoid this step.
+ */
+ void initFrameContent()
+ {
+ JPanel closePanel = new JPanel();
+ JButton closeButton = new JButton("Close");
+ closeButton.setActionCommand("CLOSE");
+ closeButton.addActionListener(this);
+ closePanel.add(closeButton);
+ add(closePanel, BorderLayout.SOUTH);
+ }
+
+ private void createContent()
+ {
+ setLayout(new BorderLayout());
+
+ add(textArea = new JTextArea(10, 20));
+
+ textArea.setWrapStyleWord(true);
+
+ textArea.setLineWrap(true);
+
+ textArea.setNavigationFilter(new WordFilter());
+
+ textArea.setText("GNU Classpath, Essential Libraries for Java, " +
+ "is a GNU project to create free core class " +
+ "libraries for use with virtual machines and " +
+ "compilers for the java programming language.");
+ }
+
+ public void actionPerformed(ActionEvent e)
+ {
+ if (e.getActionCommand().equals("CLOSE"))
+ System.exit(0);
+
+ }
+
+ public static void main(String[] args)
+ {
+ SwingUtilities.invokeLater
+ (new Runnable()
+ {
+ public void run()
+ {
+ NavigationFilterDemo app = new NavigationFilterDemo();
+ app.initFrameContent();
+ JFrame frame = new JFrame("NavigationFilterDemo");
+ frame.getContentPane().add(app);
+ frame.pack();
+ frame.setVisible(true);
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ }
+ });
+ }
+
+ /**
+ * Returns a DemoFactory that creates a NavigationFilterDemo.
+ *
+ * @return a DemoFactory that creates a NavigationFilterDemo
+ */
+ public static DemoFactory createDemoFactory()
+ {
+ return new DemoFactory()
+ {
+ public JComponent createDemo()
+ {
+ return new NavigationFilterDemo();
+ }
+ };
+ }
+
+ class WordFilter extends NavigationFilter
+ {
+ public int getNextVisualPositionFrom(JTextComponent text,
+ int pos,
+ Position.Bias bias,
+ int direction,
+ Position.Bias[] biasRet)
+ throws BadLocationException
+ {
+ Point pt;
+
+ int newpos = pos;
+ switch (direction)
+ {
+ case SwingConstants.NORTH:
+ // Find out where the caret want to be positioned ideally.
+ pt = text.getCaret().getMagicCaretPosition();
+
+ // Calculate its position above.
+ newpos = Utilities.getPositionAbove(text, pos, (pt != null) ? pt.x : 0);
+
+ // If we have a valid position, then calculate the next word start
+ // from there.
+ if (newpos != -1)
+ return Utilities.getWordStart(text, newpos);
+ else
+ return pos;
+ case SwingConstants.SOUTH:
+ // Find out where the caret want to be positioned ideally.
+ pt = text.getCaret().getMagicCaretPosition();
+
+ // Calculate its position below.
+ newpos = Utilities.getPositionBelow(text, pos, (pt != null) ? pt.x : 0);
+
+ // If we have a valid position, then calculate the next word start
+ // from there.
+ if (newpos != -1)
+ return Utilities.getWordStart(text, newpos);
+ else
+ return pos;
+ case SwingConstants.WEST:
+ // Calculate the next word start.
+ newpos = Utilities.getWordStart(text, newpos);
+
+ // If that means that the caret will not move, return
+ // the start of the previous word.
+ if (newpos != pos)
+ return newpos;
+ else
+ return Utilities.getPreviousWord(text, newpos);
+ case SwingConstants.EAST:
+ return Utilities.getNextWord(text, newpos);
+ default:
+ // Do whatever the super implementation did.
+ return super.getNextVisualPositionFrom(text, pos, bias,
+ direction, biasRet);
+ }
+ }
+
+ }
+
+}
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/ProgressBarDemo.java b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/ProgressBarDemo.java
new file mode 100644
index 000000000..1391a00ba
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/ProgressBarDemo.java
@@ -0,0 +1,239 @@
+/* ProgressBarDemo.java -- A demonstration of JProgressBars
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath 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, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.examples.swing;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.Box;
+import javax.swing.BoxLayout;
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JProgressBar;
+import javax.swing.JSlider;
+import javax.swing.SwingUtilities;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+
+public class ProgressBarDemo
+ extends JPanel
+ implements ActionListener
+{
+
+ /**
+ * Creates a new ProgressBarDemo window with the specified title.
+ */
+ ProgressBarDemo()
+ {
+ super();
+ createContent();
+ }
+
+ void initFrameContent()
+ {
+ JPanel closePanel = new JPanel();
+ JButton closeButton = new JButton("Close");
+ closeButton.setActionCommand("CLOSE");
+ closeButton.addActionListener(this);
+ closePanel.add(closeButton);
+ add(closePanel);
+ }
+
+ private void createContent()
+ {
+ setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
+ JPanel horizontalProgressBar = createHorizontalProgressBar();
+ add(horizontalProgressBar);
+ add(Box.createVerticalStrut(10));
+ JPanel verticalProgressBar = createVerticalProgressBar();
+ add(verticalProgressBar);
+ }
+
+ private static JPanel createHorizontalProgressBar()
+ {
+ JPanel panel = new JPanel();
+ panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
+
+ // Plain progress bar.
+ final JProgressBar hor1 = new JProgressBar(JProgressBar.HORIZONTAL, 0, 100);
+ panel.add(hor1);
+ final JSlider slider1 = new JSlider(JSlider.HORIZONTAL, 0, 100, 0);
+ slider1.addChangeListener(new ChangeListener()
+ {
+ public void stateChanged(ChangeEvent event)
+ {
+ hor1.setValue(slider1.getValue());
+ }
+ });
+ panel.add(slider1);
+
+ panel.add(Box.createVerticalStrut(5));
+
+ // Plain progress bar with some text.
+ final JProgressBar hor2 = new JProgressBar(JProgressBar.HORIZONTAL, 0, 100);
+ hor2.setString("ProgressBar Demo");
+ hor2.setStringPainted(true);
+ panel.add(hor2);
+ final JSlider slider2 = new JSlider(JSlider.HORIZONTAL, 0, 100, 0);
+ slider2.addChangeListener(new ChangeListener()
+ {
+ public void stateChanged(ChangeEvent event)
+ {
+ hor2.setValue(slider2.getValue());
+ }
+ });
+ panel.add(slider2);
+
+ panel.add(Box.createVerticalStrut(5));
+
+ // Indeterminate progress bar.
+ final JProgressBar hor3 = new JProgressBar(JProgressBar.HORIZONTAL, 0, 100);
+ hor3.setIndeterminate(true);
+ panel.add(hor3);
+
+ panel.add(Box.createVerticalStrut(5));
+
+ // Indeterminate progress bar with text.
+ final JProgressBar hor4 = new JProgressBar(JProgressBar.HORIZONTAL, 0, 100);
+ hor4.setIndeterminate(true);
+ hor4.setString("Indeterminate ProgressBar");
+ hor4.setStringPainted(true);
+ panel.add(hor4);
+
+ return panel;
+ }
+
+ private static JPanel createVerticalProgressBar()
+ {
+ JPanel panel = new JPanel();
+ panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
+ final JProgressBar vert = new JProgressBar(JProgressBar.VERTICAL, 0, 100);
+ panel.add(vert);
+ final JSlider slider = new JSlider(JSlider.VERTICAL, 0, 100, 0);
+ slider.addChangeListener(new ChangeListener()
+ {
+ public void stateChanged(ChangeEvent event)
+ {
+ vert.setValue(slider.getValue());
+ }
+ });
+ panel.add(slider);
+
+ panel.add(Box.createHorizontalStrut(5));
+
+ final JProgressBar vert2 = new JProgressBar(JProgressBar.VERTICAL, 0, 100);
+ vert2.setString("ProgressBar Demo");
+ panel.add(vert2);
+ vert2.setStringPainted(true);
+ final JSlider slider2 = new JSlider(JSlider.VERTICAL, 0, 100, 0);
+ slider2.addChangeListener(new ChangeListener()
+ {
+ public void stateChanged(ChangeEvent event)
+ {
+ vert2.setValue(slider2.getValue());
+ }
+ });
+ panel.add(slider2);
+
+ panel.add(Box.createHorizontalStrut(5));
+
+ // Indeterminate progress bar.
+ final JProgressBar vert3 = new JProgressBar(JProgressBar.VERTICAL, 0, 100);
+ vert3.setIndeterminate(true);
+ panel.add(vert3);
+
+ panel.add(Box.createHorizontalStrut(5));
+
+ // Indeterminate progress bar with text.
+ final JProgressBar vert4 = new JProgressBar(JProgressBar.VERTICAL, 0, 100);
+ vert4.setIndeterminate(true);
+ vert4.setString("Indeterminate ProgressBar");
+ vert4.setStringPainted(true);
+ panel.add(vert4);
+ return panel;
+ }
+
+ public void actionPerformed(ActionEvent event)
+ {
+ if (event.getActionCommand().equals("CLOSE"))
+ {
+ System.exit(0);
+ }
+ }
+
+ /**
+ * The entry point when running as a standalone program.
+ *
+ * @param args command line arguments
+ */
+ public static void main(String[] args)
+ {
+ SwingUtilities.invokeLater(
+ new Runnable()
+ {
+ public void run()
+ {
+ ProgressBarDemo app = new ProgressBarDemo();
+ app.initFrameContent();
+ JFrame frame = new JFrame("ProgressBar Demo");
+ frame.getContentPane().add(app);
+ frame.pack();
+ frame.setVisible(true);
+ }
+ });
+ }
+
+ /**
+ * Returns a DemoFactory that creates a ProgressBarDemo.
+ *
+ * @return a DemoFactory that creates a ProgressBarDemo
+ */
+ public static DemoFactory createDemoFactory()
+ {
+ return new DemoFactory()
+ {
+ public JComponent createDemo()
+ {
+ return new ProgressBarDemo();
+ }
+ };
+ }
+}
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/ScrollBarDemo.java b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/ScrollBarDemo.java
new file mode 100644
index 000000000..505991e19
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/ScrollBarDemo.java
@@ -0,0 +1,174 @@
+/* ScrollBarDemo.java -- An example showing scroll bars in Swing.
+ Copyright (C) 2005, 2006, Free Software Foundation, Inc.
+
+This file is part of GNU Classpath examples.
+
+GNU Classpath 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, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+*/
+
+
+package gnu.classpath.examples.swing;
+
+import java.awt.BorderLayout;
+import java.awt.GridLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JScrollBar;
+import javax.swing.SwingUtilities;
+
+/**
+ * A simple scroll bar demo showing various scroll bars in different states.
+ */
+public class ScrollBarDemo
+ extends JPanel
+ implements ActionListener
+{
+
+ /**
+ * Creates a new demo instance.
+ */
+ public ScrollBarDemo()
+ {
+ super();
+ createContent();
+ }
+
+ /**
+ * When the demo is run independently, the frame is displayed, so we should
+ * initialise the content panel (including the demo content and a close
+ * button). But when the demo is run as part of the Swing activity board,
+ * only the demo content panel is used, the frame itself is never displayed,
+ * so we can avoid this step.
+ */
+ void initFrameContent()
+ {
+ JPanel closePanel = new JPanel();
+ JButton closeButton = new JButton("Close");
+ closeButton.setActionCommand("CLOSE");
+ closeButton.addActionListener(this);
+ closePanel.add(closeButton);
+ add(closePanel, BorderLayout.SOUTH);
+ }
+
+ /**
+ * Returns a panel with the demo content. The panel
+ * uses a BorderLayout(), and the BorderLayout.SOUTH area
+ * is empty, to allow callers to add controls to the
+ * bottom of the panel if they want to (a close button is
+ * added if this demo is being run as a standalone demo).
+ */
+ private void createContent()
+ {
+ setLayout(new BorderLayout());
+ JPanel panel = createScrollBarPanel();
+ add(panel);
+ }
+
+ private JPanel createScrollBarPanel()
+ {
+ JPanel panel = new JPanel(new BorderLayout());
+
+ JPanel horizontalPanel = new JPanel();
+
+ JScrollBar scroll1a = new JScrollBar(JScrollBar.HORIZONTAL);
+ JScrollBar scroll1b = new JScrollBar(JScrollBar.HORIZONTAL);
+ scroll1b.setEnabled(false);
+ JScrollBar scroll1c = new JScrollBar(JScrollBar.HORIZONTAL);
+ scroll1c.putClientProperty("JScrollBar.isFreeStanding", Boolean.FALSE);
+ JScrollBar scroll1d = new JScrollBar(JScrollBar.HORIZONTAL);
+ scroll1d.putClientProperty("JScrollBar.isFreeStanding", Boolean.FALSE);
+ scroll1d.setEnabled(false);
+ horizontalPanel.add(scroll1a);
+ horizontalPanel.add(scroll1b);
+ horizontalPanel.add(scroll1c);
+ horizontalPanel.add(scroll1d);
+
+ panel.add(horizontalPanel, BorderLayout.NORTH);
+
+ JPanel verticalPanel = new JPanel();
+ verticalPanel.setLayout(new GridLayout(1, 7));
+
+ JScrollBar scroll2a = new JScrollBar(JScrollBar.VERTICAL);
+ JScrollBar scroll2b = new JScrollBar(JScrollBar.VERTICAL);
+ scroll2b.setEnabled(false);
+ JScrollBar scroll2c = new JScrollBar(JScrollBar.VERTICAL);
+ scroll2c.putClientProperty("JScrollBar.isFreeStanding", Boolean.FALSE);
+ JScrollBar scroll2d = new JScrollBar(JScrollBar.VERTICAL);
+ scroll2d.setEnabled(false);
+ scroll2d.putClientProperty("JScrollBar.isFreeStanding", Boolean.FALSE);
+
+ verticalPanel.add(scroll2a);
+ verticalPanel.add(new JPanel());
+ verticalPanel.add(scroll2b);
+ verticalPanel.add(new JPanel());
+ verticalPanel.add(scroll2c);
+ verticalPanel.add(new JPanel());
+ verticalPanel.add(scroll2d);
+
+ panel.add(verticalPanel, BorderLayout.EAST);
+
+ JPanel centerPanel = new JPanel(new GridLayout(1, 2));
+ centerPanel.add(new JScrollBar(JScrollBar.HORIZONTAL));
+ centerPanel.add(new JScrollBar(JScrollBar.VERTICAL));
+ panel.add(centerPanel);
+ return panel;
+ }
+
+ public void actionPerformed(ActionEvent e)
+ {
+ if (e.getActionCommand().equals("CLOSE"))
+ {
+ System.exit(0);
+ }
+ }
+
+ public static void main(String[] args)
+ {
+ SwingUtilities.invokeLater
+ (new Runnable()
+ {
+ public void run()
+ {
+ ScrollBarDemo app = new ScrollBarDemo();
+ app.initFrameContent();
+ JFrame frame = new JFrame("ScrollBar Demo");
+ frame.getContentPane().add(app);
+ frame.pack();
+ frame.setVisible(true);
+ }});
+ }
+
+ /**
+ * Returns a DemoFactory that creates a ScrollBarDemo.
+ *
+ * @return a DemoFactory that creates a ScrollBarDemo
+ */
+ public static DemoFactory createDemoFactory()
+ {
+ return new DemoFactory()
+ {
+ public JComponent createDemo()
+ {
+ return new ScrollBarDemo();
+ }
+ };
+ }
+}
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/SliderDemo.java b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/SliderDemo.java
new file mode 100644
index 000000000..df84cc636
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/SliderDemo.java
@@ -0,0 +1,287 @@
+/* SliderDemo.java -- An example showing JSlider in various configurations.
+ Copyright (C) 2005, 2006, Free Software Foundation, Inc.
+
+This file is part of GNU Classpath examples.
+
+GNU Classpath 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, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+*/
+
+
+package gnu.classpath.examples.swing;
+
+import java.awt.BorderLayout;
+import java.awt.GridLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JComponent;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JSlider;
+import javax.swing.SwingUtilities;
+
+public class SliderDemo
+ extends JPanel
+ implements ActionListener
+{
+
+ JSlider hslider1;
+ JSlider hslider2;
+ JSlider hslider3;
+ JSlider hslider4;
+ JSlider hslider5;
+ JSlider hslider6;
+ JSlider hslider7;
+ JSlider hslider8;
+
+ JSlider vslider1;
+ JSlider vslider2;
+ JSlider vslider3;
+ JSlider vslider4;
+ JSlider vslider5;
+ JSlider vslider6;
+ JSlider vslider7;
+ JSlider vslider8;
+
+ JCheckBox enabledCheckBox;
+
+ public SliderDemo()
+ {
+ createContent();
+ }
+
+ /**
+ * When the demo is run independently, the frame is displayed, so we should
+ * initialise the content panel (including the demo content and a close
+ * button). But when the demo is run as part of the Swing activity board,
+ * only the demo content panel is used, the frame itself is never displayed,
+ * so we can avoid this step.
+ */
+ void initFrameContent()
+ {
+ JPanel closePanel = new JPanel();
+ JButton closeButton = new JButton("Close");
+ closeButton.setActionCommand("CLOSE");
+ closeButton.addActionListener(this);
+ closePanel.add(closeButton);
+ add(closePanel, BorderLayout.SOUTH);
+ }
+
+ /**
+ * Returns a panel with the demo content. The panel
+ * uses a BorderLayout(), and the BorderLayout.SOUTH area
+ * is empty, to allow callers to add controls to the
+ * bottom of the panel if they want to (a close button is
+ * added if this demo is being run as a standalone demo).
+ */
+ private void createContent()
+ {
+ setLayout(new BorderLayout());
+ JPanel panel = new JPanel(new GridLayout(1, 2));
+ panel.add(createHorizontalPanel());
+ panel.add(createVerticalPanel());
+ enabledCheckBox = new JCheckBox("Enabled");
+ enabledCheckBox.setSelected(true);
+ enabledCheckBox.setActionCommand("TOGGLE_ENABLED");
+ enabledCheckBox.addActionListener(this);
+ JPanel checkBoxPanel = new JPanel();
+ checkBoxPanel.add(enabledCheckBox);
+ JPanel panel2 = new JPanel(new BorderLayout());
+ panel2.add(panel);
+ panel2.add(checkBoxPanel, BorderLayout.SOUTH);
+ add(panel2);
+ }
+
+ private JPanel createHorizontalPanel()
+ {
+ JPanel panel = new JPanel(new GridLayout(8, 1));
+
+ hslider1 = new JSlider(JSlider.HORIZONTAL, 0, 100, 35);
+ panel.add(hslider1);
+
+ hslider2 = new JSlider(JSlider.HORIZONTAL, 0, 100, 35);
+ hslider2.setMajorTickSpacing(20);
+ hslider2.setMinorTickSpacing(5);
+ hslider2.setPaintTicks(true);
+ panel.add(hslider2);
+
+ hslider3 = new JSlider(JSlider.HORIZONTAL, 0, 100, 35);
+ hslider3.setMajorTickSpacing(20);
+ hslider3.setMinorTickSpacing(5);
+ hslider3.setPaintLabels(true);
+ hslider3.setPaintTicks(true);
+ panel.add(hslider3);
+
+ hslider4 = new JSlider(JSlider.HORIZONTAL, 0, 100, 35);
+ hslider4.putClientProperty("JSlider.isFilled", Boolean.TRUE);
+ hslider4.setMajorTickSpacing(20);
+ hslider4.setMinorTickSpacing(5);
+ hslider4.setPaintLabels(true);
+ hslider4.setPaintTicks(true);
+ panel.add(hslider4);
+
+ hslider5 = new JSlider(JSlider.HORIZONTAL, 0, 100, 35);
+ hslider5.setInverted(true);
+ panel.add(hslider5);
+
+ hslider6 = new JSlider(JSlider.HORIZONTAL, 0, 100, 35);
+ hslider6.setInverted(true);
+ hslider6.setMajorTickSpacing(20);
+ hslider6.setMinorTickSpacing(5);
+ hslider6.setPaintTicks(true);
+ panel.add(hslider6);
+
+ hslider7 = new JSlider(JSlider.HORIZONTAL, 0, 100, 35);
+ hslider7.setInverted(true);
+ hslider7.setMajorTickSpacing(20);
+ hslider7.setMinorTickSpacing(5);
+ hslider7.setPaintLabels(true);
+ hslider7.setPaintTicks(true);
+ panel.add(hslider7);
+
+ hslider8 = new JSlider(JSlider.HORIZONTAL, 0, 100, 35);
+ hslider8.putClientProperty("JSlider.isFilled", Boolean.TRUE);
+ hslider8.setInverted(true);
+ hslider8.setMajorTickSpacing(20);
+ hslider8.setMinorTickSpacing(5);
+ hslider8.setPaintLabels(true);
+ hslider8.setPaintTicks(true);
+ panel.add(hslider8);
+
+ return panel;
+ }
+
+ private JPanel createVerticalPanel()
+ {
+ JPanel panel = new JPanel(new GridLayout(1, 8));
+
+ vslider1 = new JSlider(JSlider.VERTICAL, 0, 100, 35);
+ panel.add(vslider1);
+
+ vslider2 = new JSlider(JSlider.VERTICAL, 0, 100, 35);
+ vslider2.setMajorTickSpacing(20);
+ vslider2.setMinorTickSpacing(5);
+ vslider2.setPaintTicks(true);
+ panel.add(vslider2);
+
+ vslider3 = new JSlider(JSlider.VERTICAL, 0, 100, 35);
+ vslider3.setMajorTickSpacing(20);
+ vslider3.setMinorTickSpacing(5);
+ vslider3.setPaintLabels(true);
+ vslider3.setPaintTicks(true);
+ panel.add(vslider3);
+
+ vslider4 = new JSlider(JSlider.VERTICAL, 0, 100, 35);
+ vslider4.putClientProperty("JSlider.isFilled", Boolean.TRUE);
+ vslider4.setMajorTickSpacing(20);
+ vslider4.setMinorTickSpacing(5);
+ vslider4.setPaintLabels(true);
+ vslider4.setPaintTicks(true);
+ panel.add(vslider4);
+
+ vslider5 = new JSlider(JSlider.VERTICAL, 0, 100, 35);
+ vslider5.setInverted(true);
+ panel.add(vslider5);
+
+ vslider6 = new JSlider(JSlider.VERTICAL, 0, 100, 35);
+ vslider6.setInverted(true);
+ vslider6.setMajorTickSpacing(20);
+ vslider6.setMinorTickSpacing(5);
+ vslider6.setPaintTicks(true);
+ panel.add(vslider6);
+
+ vslider7 = new JSlider(JSlider.VERTICAL, 0, 100, 35);
+ vslider7.setInverted(true);
+ vslider7.setMajorTickSpacing(20);
+ vslider7.setMinorTickSpacing(5);
+ vslider7.setPaintLabels(true);
+ vslider7.setPaintTicks(true);
+ panel.add(vslider7);
+
+ vslider8 = new JSlider(JSlider.VERTICAL, 0, 100, 35);
+ vslider8.putClientProperty("JSlider.isFilled", Boolean.TRUE);
+ vslider8.setInverted(true);
+ vslider8.setMajorTickSpacing(20);
+ vslider8.setMinorTickSpacing(5);
+ vslider8.setPaintLabels(true);
+ vslider8.setPaintTicks(true);
+ panel.add(vslider8);
+ return panel;
+ }
+
+ public void actionPerformed(ActionEvent e)
+ {
+ if (e.getActionCommand().equals("CLOSE"))
+ {
+ System.exit(0);
+ }
+ else if (e.getActionCommand().equals("TOGGLE_ENABLED"))
+ {
+ boolean enabled = enabledCheckBox.isSelected();
+ hslider1.setEnabled(enabled);
+ hslider2.setEnabled(enabled);
+ hslider3.setEnabled(enabled);
+ hslider4.setEnabled(enabled);
+ hslider5.setEnabled(enabled);
+ hslider6.setEnabled(enabled);
+ hslider7.setEnabled(enabled);
+ hslider8.setEnabled(enabled);
+ vslider1.setEnabled(enabled);
+ vslider2.setEnabled(enabled);
+ vslider3.setEnabled(enabled);
+ vslider4.setEnabled(enabled);
+ vslider5.setEnabled(enabled);
+ vslider6.setEnabled(enabled);
+ vslider7.setEnabled(enabled);
+ vslider8.setEnabled(enabled);
+ }
+ }
+ public static void main(String[] args)
+ {
+ SwingUtilities.invokeLater
+ (new Runnable()
+ {
+ public void run()
+ {
+ SliderDemo app = new SliderDemo();
+ app.initFrameContent();
+ JFrame frame = new JFrame("Slider Demo");
+ frame.getContentPane().add(app);
+ frame.pack();
+ frame.setVisible(true);
+ }
+ });
+ }
+
+
+ /**
+ * Returns a DemoFactory that creates a SliderDemo.
+ *
+ * @return a DemoFactory that creates a SliderDemo
+ */
+ public static DemoFactory createDemoFactory()
+ {
+ return new DemoFactory()
+ {
+ public JComponent createDemo()
+ {
+ return new SliderDemo();
+ }
+ };
+ }
+}
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/SpinnerDemo.java b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/SpinnerDemo.java
new file mode 100644
index 000000000..d0edd96ba
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/SpinnerDemo.java
@@ -0,0 +1,235 @@
+/* SpinnerDemo.java -- An example showing various spinners in Swing.
+ Copyright (C) 2006, Free Software Foundation, Inc.
+
+This file is part of GNU Classpath examples.
+
+GNU Classpath 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, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+*/
+
+
+package gnu.classpath.examples.swing;
+
+import java.awt.BorderLayout;
+import java.awt.Font;
+import java.awt.GridLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.Calendar;
+import java.util.Date;
+
+import javax.swing.BorderFactory;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JComponent;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JSpinner;
+import javax.swing.SpinnerDateModel;
+import javax.swing.SpinnerListModel;
+import javax.swing.SpinnerNumberModel;
+import javax.swing.SwingUtilities;
+
+/**
+ * A simple demo showing various spinners in different states.
+ */
+public class SpinnerDemo
+ extends JPanel
+ implements ActionListener
+{
+ private JCheckBox spinnerState1;
+ private JSpinner spinner1;
+ private JSpinner spinner2;
+
+ private JCheckBox spinnerState2;
+ private JSpinner spinner3;
+ private JSpinner spinner4;
+
+ private JCheckBox spinnerState3;
+ private JSpinner spinner5;
+ private JSpinner spinner6;
+
+ /**
+ * Creates a new demo instance.
+ */
+ public SpinnerDemo()
+ {
+ super();
+ createContent();
+ }
+
+ /**
+ * When the demo is run independently, the frame is displayed, so we should
+ * initialise the content panel (including the demo content and a close
+ * button). But when the demo is run as part of the Swing activity board,
+ * only the demo content panel is used, the frame itself is never displayed,
+ * so we can avoid this step.
+ */
+ void initFrameContent()
+ {
+ JPanel closePanel = new JPanel();
+ JButton closeButton = new JButton("Close");
+ closeButton.setActionCommand("CLOSE");
+ closeButton.addActionListener(this);
+ closePanel.add(closeButton);
+ add(closePanel, BorderLayout.SOUTH);
+ }
+
+ /**
+ * Returns a panel with the demo content. The panel
+ * uses a BorderLayout(), and the BorderLayout.SOUTH area
+ * is empty, to allow callers to add controls to the
+ * bottom of the panel if they want to (a close button is
+ * added if this demo is being run as a standalone demo).
+ */
+ private void createContent()
+ {
+ setLayout(new BorderLayout());
+ JPanel panel = new JPanel(new GridLayout(3, 1));
+ panel.add(createPanel1());
+ panel.add(createPanel2());
+ panel.add(createPanel3());
+ add(panel);
+ }
+
+ private JPanel createPanel1()
+ {
+ JPanel panel = new JPanel(new BorderLayout());
+ this.spinnerState1 = new JCheckBox("Enabled", true);
+ this.spinnerState1.setActionCommand("COMBO_STATE1");
+ this.spinnerState1.addActionListener(this);
+ panel.add(this.spinnerState1, BorderLayout.EAST);
+
+ JPanel controlPanel = new JPanel();
+ controlPanel.setBorder(BorderFactory.createTitledBorder(
+ "Number Spinner: "));
+ this.spinner1 = new JSpinner(new SpinnerNumberModel(5.0, 0.0, 10.0, 0.5));
+ this.spinner2 = new JSpinner(new SpinnerNumberModel(50, 0, 100, 5));
+ this.spinner2.setFont(new Font("Dialog", Font.PLAIN, 20));
+ controlPanel.add(this.spinner1);
+ controlPanel.add(this.spinner2);
+
+ panel.add(controlPanel);
+
+ return panel;
+ }
+
+ private JPanel createPanel2()
+ {
+ JPanel panel = new JPanel(new BorderLayout());
+ this.spinnerState2 = new JCheckBox("Enabled", true);
+ this.spinnerState2.setActionCommand("COMBO_STATE2");
+ this.spinnerState2.addActionListener(this);
+ panel.add(this.spinnerState2, BorderLayout.EAST);
+
+ JPanel controlPanel = new JPanel();
+ controlPanel.setBorder(BorderFactory.createTitledBorder("Date Spinner: "));
+ this.spinner3 = new JSpinner(new SpinnerDateModel(new Date(), null, null,
+ Calendar.DATE));
+
+ this.spinner4 = new JSpinner(new SpinnerDateModel(new Date(), null, null,
+ Calendar.YEAR));
+ this.spinner4.setFont(new Font("Dialog", Font.PLAIN, 20));
+
+ controlPanel.add(this.spinner3);
+ controlPanel.add(this.spinner4);
+
+ panel.add(controlPanel);
+
+ return panel;
+ }
+
+ private JPanel createPanel3()
+ {
+ JPanel panel = new JPanel(new BorderLayout());
+ this.spinnerState3 = new JCheckBox("Enabled", true);
+ this.spinnerState3.setActionCommand("COMBO_STATE3");
+ this.spinnerState3.addActionListener(this);
+ panel.add(this.spinnerState3, BorderLayout.EAST);
+
+ JPanel controlPanel = new JPanel();
+ controlPanel.setBorder(BorderFactory.createTitledBorder("List Spinner: "));
+ this.spinner5 = new JSpinner(new SpinnerListModel(new Object[] {"Red",
+ "Orange", "Yellow", "Green", "Blue", "Indigo", "Violet"}));
+
+ this.spinner6 = new JSpinner(new SpinnerListModel(new Object[] {"Red",
+ "Orange", "Yellow", "Green", "Blue", "Indigo", "Violet"}));
+ this.spinner6.setValue("Yellow");
+ this.spinner6.setFont(new Font("Dialog", Font.PLAIN, 20));
+
+ controlPanel.add(this.spinner5);
+ controlPanel.add(this.spinner6);
+
+ panel.add(controlPanel);
+
+ return panel;
+ }
+
+ public void actionPerformed(ActionEvent e)
+ {
+ if (e.getActionCommand().equals("COMBO_STATE1"))
+ {
+ spinner1.setEnabled(spinnerState1.isSelected());
+ spinner2.setEnabled(spinnerState1.isSelected());
+ }
+ else if (e.getActionCommand().equals("COMBO_STATE2"))
+ {
+ spinner3.setEnabled(spinnerState2.isSelected());
+ spinner4.setEnabled(spinnerState2.isSelected());
+ }
+ else if (e.getActionCommand().equals("COMBO_STATE3"))
+ {
+ spinner5.setEnabled(spinnerState3.isSelected());
+ spinner6.setEnabled(spinnerState3.isSelected());
+ }
+ else if (e.getActionCommand().equals("CLOSE"))
+ {
+ System.exit(0);
+ }
+ }
+
+ public static void main(String[] args)
+ {
+ SwingUtilities.invokeLater
+ (new Runnable()
+ {
+ public void run()
+ {
+ SpinnerDemo app = new SpinnerDemo();
+ app.initFrameContent();
+ JFrame frame = new JFrame("Spinner Demo");
+ frame.getContentPane().add(app);
+ frame.pack();
+ frame.setVisible(true);
+ }
+ });
+ }
+
+ /**
+ * Returns a DemoFactory that creates a SpinnerDemo.
+ *
+ * @return a DemoFactory that creates a SpinnerDemo
+ */
+ public static DemoFactory createDemoFactory()
+ {
+ return new DemoFactory()
+ {
+ public JComponent createDemo()
+ {
+ return new SpinnerDemo();
+ }
+ };
+ }
+}
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/TabbedPaneDemo.java b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/TabbedPaneDemo.java
new file mode 100644
index 000000000..bd0e6bf15
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/TabbedPaneDemo.java
@@ -0,0 +1,256 @@
+/* TabbedPaneDemo.java -- Demonstrates JTabbedPane
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath 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, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.examples.swing;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.GridLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JMenu;
+import javax.swing.JMenuItem;
+import javax.swing.JPanel;
+import javax.swing.JPopupMenu;
+import javax.swing.JScrollPane;
+import javax.swing.JTabbedPane;
+import javax.swing.JTextArea;
+import javax.swing.SwingConstants;
+import javax.swing.SwingUtilities;
+
+public class TabbedPaneDemo
+ extends JPanel
+ implements ActionListener
+{
+ static Color[] colors = { Color.BLUE, Color.CYAN, Color.GRAY, Color.GREEN,
+ Color.MAGENTA, Color.ORANGE, Color.PINK,
+ Color.ORANGE, Color.RED, Color.BLUE, Color.YELLOW
+ };
+ TabbedPaneDemo()
+ {
+ super();
+ createContent();
+ }
+
+ private void createContent()
+ {
+ JPanel p = new JPanel();
+ p.setLayout(new GridLayout(1, 1));
+
+ int COUNT = 25;
+ JTabbedPane tp = createTabbedPane(SwingConstants.TOP, "tab", COUNT);
+ p.add(tp);
+
+ final JPopupMenu popup = new JPopupMenu();
+
+ JMenu menu = new JMenu("tab placement");
+ menu.add(createPlacementChangingMenuItem("top",
+ SwingConstants.TOP,
+ tp));
+
+ menu.add(createPlacementChangingMenuItem("bottom",
+ SwingConstants.BOTTOM,
+ tp));
+
+ menu.add(createPlacementChangingMenuItem("left",
+ SwingConstants.LEFT,
+ tp));
+
+ menu.add(createPlacementChangingMenuItem("right",
+ SwingConstants.RIGHT,
+ tp));
+ popup.add(menu);
+
+ menu = new JMenu("tab layout");
+ menu.add(createLayoutPolicyChangingMenuItem("wrapping tabs",
+ JTabbedPane.WRAP_TAB_LAYOUT,
+ tp));
+
+ menu.add(createLayoutPolicyChangingMenuItem("scrolling tabs",
+ JTabbedPane.SCROLL_TAB_LAYOUT,
+ tp));
+ popup.add(menu);
+
+ tp.addMouseListener(new MouseAdapter()
+ {
+ public void mousePressed(MouseEvent e) {
+ showPopup(e);
+ }
+
+ public void mouseReleased(MouseEvent e) {
+ showPopup(e);
+ }
+
+ void showPopup(MouseEvent e) {
+ if (e.isPopupTrigger()) {
+ popup.show(e.getComponent(), e.getX(), e.getY());
+ }
+ }
+ });
+
+ setLayout(new BorderLayout());
+ add(p, BorderLayout.CENTER);
+
+ }
+
+ private JMenuItem createPlacementChangingMenuItem(String t,
+ final int v,
+ final JTabbedPane dst)
+ {
+ JMenuItem item = new JMenuItem(t);
+
+ item.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent ae)
+ {
+ dst.setTabPlacement(v);
+ }
+ });
+
+ return item;
+ }
+
+ private JMenuItem createLayoutPolicyChangingMenuItem(String t,
+ final int v,
+ final JTabbedPane dst)
+ {
+ JMenuItem item = new JMenuItem(t);
+
+ item.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent ae)
+ {
+ dst.setTabLayoutPolicy(v);
+ }
+ });
+
+ return item;
+ }
+
+ private JTabbedPane createTabbedPane(int direction, String name, int count)
+ {
+ JTabbedPane pane = new JTabbedPane(direction);
+
+ for(int i = 0; i< count; i++)
+ {
+ pane.addTab(name + " " + i, createTabContent(name + " " + i));
+ if (Math.random() >= 0.75)
+ pane.setEnabledAt(i, false);
+ }
+
+ return pane;
+ }
+
+ private JPanel createTabContent(String name)
+ {
+ JTextArea ta;
+ JPanel panel = new JPanel();
+ panel.add(new JLabel(name));
+ panel.add(new JButton(name));
+ panel.add(new JScrollPane(ta = new JTextArea(5, 5)));
+
+ ta.setBackground(colors[(int) (Math.random() * colors.length)]);
+
+ return panel;
+ }
+
+ public void actionPerformed(ActionEvent e)
+ {
+ if (e.getActionCommand().equals("CLOSE"))
+ {
+ System.exit(0);
+ }
+ }
+
+ /**
+ * When the demo is run independently, the frame is displayed, so we should
+ * initialise the content panel (including the demo content and a close
+ * button). But when the demo is run as part of the Swing activity board,
+ * only the demo content panel is used, the frame itself is never displayed,
+ * so we can avoid this step.
+ */
+ void initFrameContent()
+ {
+ JPanel closePanel = new JPanel();
+ JButton closeButton = new JButton("Close");
+ closeButton.setActionCommand("CLOSE");
+ closeButton.addActionListener(this);
+ closePanel.add(closeButton);
+ add(closePanel, BorderLayout.SOUTH);
+ }
+
+ public static void main(String[] args)
+ {
+ SwingUtilities.invokeLater
+ (new Runnable()
+ {
+ public void run()
+ {
+ TabbedPaneDemo app = new TabbedPaneDemo();
+ app.initFrameContent();
+ JFrame frame = new JFrame("TabbedPane Demo");
+ frame.getContentPane().add(app);
+ frame.pack();
+ frame.setVisible(true);
+ }
+ });
+ }
+
+ /**
+ * Returns a DemoFactory that creates a TabbedPaneDemo.
+ *
+ * @return a DemoFactory that creates a TabbedPaneDemo
+ */
+ public static DemoFactory createDemoFactory()
+ {
+ return new DemoFactory()
+ {
+ public JComponent createDemo()
+ {
+ return new TabbedPaneDemo();
+ }
+ };
+ }
+}
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/TableDemo.java b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/TableDemo.java
new file mode 100644
index 000000000..9f8e3e7d5
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/TableDemo.java
@@ -0,0 +1,411 @@
+/* TableDemo.java -- Demonstrates the use of JTable.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath 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, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.examples.swing;
+
+import java.awt.BorderLayout;
+import java.awt.Component;
+import java.awt.Dimension;
+import javax.swing.AbstractCellEditor;
+import javax.swing.BorderFactory;
+import javax.swing.DefaultCellEditor;
+import javax.swing.Icon;
+import javax.swing.JComboBox;
+import javax.swing.JComponent;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JScrollBar;
+import javax.swing.JScrollPane;
+import javax.swing.JSlider;
+import javax.swing.JTable;
+import javax.swing.SwingUtilities;
+import javax.swing.border.Border;
+import javax.swing.plaf.metal.MetalIconFactory;
+import javax.swing.table.DefaultTableColumnModel;
+import javax.swing.table.DefaultTableModel;
+import javax.swing.table.TableCellEditor;
+import javax.swing.table.TableCellRenderer;
+import javax.swing.table.TableColumn;
+import javax.swing.table.TableColumnModel;
+
+/**
+ * Displays the editable table. The first column consists of check boxes.
+ *
+ * @author Audrius Meskauskas (audriusa@bioinformatics.org)
+ */
+public class TableDemo extends JPanel
+{
+ /**
+ * The initial row count for this table.
+ */
+ static int rows = 32;
+
+ /**
+ * The initial column count for this table.
+ */
+ static int cols = 7;
+
+
+ /**
+ * The table model.
+ */
+ class TModel extends DefaultTableModel
+ {
+
+ /**
+ * All cells are editable in our table.
+ */
+ public boolean isCellEditable(int row, int column)
+ {
+ return true;
+ }
+
+ /**
+ * Get the number of the table rows.
+ */
+ public int getRowCount()
+ {
+ return rows;
+ }
+
+ /**
+ * Get the number of the table columns.
+ */
+ public int getColumnCount()
+ {
+ return cols;
+ }
+
+ /**
+ * Set the value at the given position
+ */
+ public void setValueAt(Object aValue, int aRow, int aColumn)
+ {
+ values[aRow][aColumn] = aValue;
+ }
+
+ /**
+ * Get the value at the given position.
+ */
+ public Object getValueAt(int aRow, int aColumn)
+ {
+ return values[aRow][aColumn];
+ }
+
+ /**
+ * The column name, as suggested by model. This header should not be
+ * visible, as it is overridden by setting the header name with
+ * {@link TableColumn#setHeaderValue} in {@link TableDemo#createContent}.
+ */
+ public String getColumnName(int column)
+ {
+ return "Error "+column;
+ }
+
+ /**
+ * The first column contains booleans, the second - icons,
+ * others - default class.
+ */
+ public Class getColumnClass(int column)
+ {
+ if (column == 0)
+ return Boolean.class;
+ else if (column == 1)
+ return Icon.class;
+ else
+ return super.getColumnClass(column);
+ }
+ }
+
+ /**
+ * The scroll bar renderer.
+ */
+ class SliderCell
+ extends AbstractCellEditor
+ implements TableCellEditor, TableCellRenderer
+ {
+ /**
+ * The editor bar.
+ */
+ JSlider bar;
+
+ /**
+ * The renderer bar.
+ */
+ JSlider rendererBar;
+
+ /**
+ * The border around the bar, if required.
+ */
+ Border border = BorderFactory.createLineBorder(table.getGridColor());
+
+ SliderCell()
+ {
+ bar = new JSlider();
+ bar.setOrientation(JScrollBar.HORIZONTAL);
+ bar.setMinimum(0);
+ bar.setMaximum(rows);
+ bar.setBorder(border);
+
+ rendererBar = new JSlider();
+ rendererBar.setMinimum(0);
+ rendererBar.setMaximum(rows);
+ rendererBar.setEnabled(false);
+ }
+
+ /**
+ * Get the editor.
+ */
+ public Component getTableCellEditorComponent(JTable table, Object value,
+ boolean isSelected, int row,
+ int column)
+ {
+ if (value instanceof Integer)
+ bar.setValue(((Integer) value).intValue());
+ return bar;
+ }
+
+ /**
+ * Get the renderer.
+ */
+ public Component getTableCellRendererComponent(JTable table, Object value,
+ boolean isSelected,
+ boolean hasFocus, int row,
+ int column)
+ {
+ rendererBar.setValue(((Integer) value).intValue());
+ if (hasFocus)
+ rendererBar.setBorder(border);
+ else
+ rendererBar.setBorder(null);
+ return rendererBar;
+ }
+
+ public Object getCellEditorValue()
+ {
+ return new Integer(bar.getValue());
+ }
+
+ }
+
+ /**
+ * The table being displayed.
+ */
+ JTable table = new JTable();
+
+ /**
+ * The table model.
+ */
+ TModel model = new TModel();
+
+ /**
+ * The table value array.
+ */
+ Object[][] values;
+
+ /**
+ * The icons that appear in the icon column.
+ */
+ Icon[] icons = new Icon[]
+ {
+ MetalIconFactory.getTreeComputerIcon(),
+ MetalIconFactory.getTreeHardDriveIcon(),
+ MetalIconFactory.getTreeFolderIcon(),
+ };
+
+ /**
+ * The choices in the combo boxes
+ */
+ String [] sides = new String[]
+ {
+ "north", "south", "east", "west"
+ };
+
+
+ /**
+ * Create the table demo with the given titel.
+ */
+ public TableDemo()
+ {
+ super();
+ createContent();
+ }
+
+ /**
+ * Returns a panel with the demo content. The panel uses a BorderLayout(), and
+ * the BorderLayout.SOUTH area is empty, to allow callers to add controls to
+ * the bottom of the panel if they want to (a close button is added if this
+ * demo is being run as a standalone demo).
+ */
+ private void createContent()
+ {
+ setLayout(new BorderLayout());
+ values = new Object[rows][];
+
+ for (int i = 0; i < values.length; i++)
+ {
+ values[i] = new Object[cols];
+ for (int j = 3; j < cols; j++)
+ {
+ values[i][j] = "" + ((char) ('a' + j)) + i;
+ }
+ values [i][0] = i % 2 == 0? Boolean.TRUE : Boolean.FALSE;
+ values [i][1] = icons [ i % icons.length ];
+ values [i][2] = sides [ i % sides.length ];
+ values [i][4] = new Integer(i);
+ }
+
+ table.setModel(model);
+
+ // Make the columns with gradually increasing width:
+ DefaultTableColumnModel cm = new DefaultTableColumnModel();
+ table.setColumnModel(cm);
+
+ for (int i = 0; i < cols; i++)
+ {
+ TableColumn column = new TableColumn(i);
+
+ // Showing the variable width columns.
+ int width = 100+10*i;
+ column.setPreferredWidth(width);
+
+ // If we do not set the header value here, the value, returned
+ // by model, is used.
+ column.setHeaderValue("Width +"+(20*i));
+
+ cm.addColumn(column);
+ }
+
+ setCustomEditors();
+ setInformativeHeaders();
+
+ // Create the table, place it into scroll pane and place
+ // the pane into this frame.
+ JScrollPane scroll = new JScrollPane();
+
+ // The horizontal scroll bar is never needed.
+ scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
+ scroll.getViewport().add(table);
+ add(scroll, BorderLayout.CENTER);
+
+ // Increase the row height to make the icons and sliders look better.
+ table.setRowHeight(table.getRowHeight()+2);
+ }
+
+ /**
+ * Set the more informative column headers for specific columns.
+ */
+ void setInformativeHeaders()
+ {
+ TableColumnModel cm = table.getColumnModel();
+
+ cm.getColumn(0).setHeaderValue("check");
+ cm.getColumn(1).setHeaderValue("icon");
+ cm.getColumn(2).setHeaderValue("combo");
+ cm.getColumn(3).setHeaderValue("edit combo");
+ cm.getColumn(4).setHeaderValue("slider");
+ }
+
+ /**
+ * Set the custom editors for combo boxes. This method also sets one
+ * custom renderer.
+ */
+ void setCustomEditors()
+ {
+ TableColumnModel cm = table.getColumnModel();
+
+ // Set combo-box based editor for icons (note that no custom
+ // renderer is needed for JComboBox to work with icons.
+ JComboBox combo0 = new JComboBox(icons);
+ cm.getColumn(1).setCellEditor(new DefaultCellEditor(combo0));
+
+ // Set the simple combo box editor for the third column:
+ JComboBox combo1 = new JComboBox(sides);
+ cm.getColumn(2).setCellEditor(new DefaultCellEditor(combo1));
+
+ // Set the editable combo box for the forth column:
+ JComboBox combo2 = new JComboBox(sides);
+ combo2.setEditable(true);
+ cm.getColumn(3).setCellEditor(new DefaultCellEditor(combo2));
+
+ SliderCell scrollView = new SliderCell();
+ cm.getColumn(4).setCellEditor(scrollView);
+ cm.getColumn(4).setCellRenderer(scrollView);
+
+ table.setColumnModel(cm);
+ }
+
+ /**
+ * The executable method to display the editable table.
+ *
+ * @param args
+ * unused.
+ */
+ public static void main(String[] args)
+ {
+ SwingUtilities.invokeLater
+ (new Runnable()
+ {
+ public void run()
+ {
+ TableDemo demo = new TableDemo();
+ JFrame frame = new JFrame();
+ frame.getContentPane().add(demo);
+ frame.setSize(new Dimension(640, 100));
+ frame.setVisible(true);
+ }
+ });
+ }
+
+ /**
+ * Returns a DemoFactory that creates a TableDemo.
+ *
+ * @return a DemoFactory that creates a TableDemo
+ */
+ public static DemoFactory createDemoFactory()
+ {
+ return new DemoFactory()
+ {
+ public JComponent createDemo()
+ {
+ return new TableDemo();
+ }
+ };
+ }
+}
+
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/TextAreaDemo.java b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/TextAreaDemo.java
new file mode 100644
index 000000000..b72997cb3
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/TextAreaDemo.java
@@ -0,0 +1,620 @@
+/* TextAreaDemo.java -- An example showing various textareas in Swing.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath examples.
+
+ GNU Classpath 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, or (at your option)
+ any later version.
+
+ GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+ */
+
+
+package gnu.classpath.examples.swing;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.Graphics;
+import java.awt.GridLayout;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.Shape;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.BorderFactory;
+import javax.swing.Box;
+import javax.swing.BoxLayout;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JComponent;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTabbedPane;
+import javax.swing.JTextArea;
+import javax.swing.SwingUtilities;
+import javax.swing.text.BadLocationException;
+import javax.swing.text.DefaultCaret;
+import javax.swing.text.Highlighter;
+import javax.swing.text.JTextComponent;
+import javax.swing.text.View;
+import javax.swing.text.LayeredHighlighter.LayerPainter;
+
+/**
+ * A simple textare demo showing various textareas in different states.
+ */
+public class TextAreaDemo
+ extends JPanel
+ implements ActionListener
+{
+
+ /**
+ * A custom caret for demonstration purposes. This class is inspired by the
+ * CornerCaret from the OReilly Swing book.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ */
+ static class CornerCaret
+ extends DefaultCaret
+ {
+ public CornerCaret()
+ {
+ super();
+ setBlinkRate(500);
+ }
+
+ protected synchronized void damage(Rectangle r)
+ {
+ if (r == null)
+ return;
+ x = r.x;
+ y = r.y + (r.height * 4 / 5 - 3);
+ width = 5;
+ height = 5;
+ repaint();
+ }
+
+ public void paint(Graphics g)
+ {
+ JTextComponent comp = getComponent();
+ if (comp == null)
+ return;
+ int dot = getDot();
+ Rectangle r = null;
+ try
+ {
+ r = comp.modelToView(dot);
+ }
+ catch (BadLocationException e)
+ {
+ return;
+ }
+ if (r == null)
+ return;
+ int dist = r.height * 4 / 5 - 3;
+ if ((x != r.x) || (y != r.y + dist))
+ {
+ repaint();
+ x = r.x;
+ y = r.y + dist;
+ width = 5;
+ height = 5;
+ }
+ if (isVisible())
+ {
+ g.drawLine(r.x, r.y + dist, r.x, r.y + dist + 4);
+ g.drawLine(r.x, r.y + dist + 4, r.x + 4, r.y + dist + 4);
+ }
+ }
+ }
+
+ static class DemoHighlightPainter
+ extends LayerPainter
+ {
+ static DemoHighlightPainter INSTANCE = new DemoHighlightPainter();
+
+ static Color[] colors = { Color.BLUE, Color.CYAN, Color.GRAY, Color.GREEN,
+ Color.MAGENTA, Color.ORANGE, Color.PINK,
+ Color.ORANGE, Color.RED, Color.BLUE, Color.YELLOW };
+
+ public DemoHighlightPainter()
+ {
+ super();
+ }
+
+ private void paintHighlight(Graphics g, Rectangle rect)
+ {
+ g.fillRect(rect.x, rect.y, rect.width, rect.height);
+ }
+
+ public void paint(Graphics g, int p0, int p1, Shape bounds, JTextComponent t)
+ {
+ try
+ {
+
+ for (int i = p0; i < p1; i++)
+ {
+ Rectangle r = t.modelToView(i);
+ Point l1 = t.modelToView(i + 1).getLocation();
+
+ g.setColor(colors[(int) (Math.random() * colors.length)]);
+ g.fillOval(r.x, r.y, l1.x - r.x, r.height);
+ }
+ }
+ catch (BadLocationException ble)
+ {
+ }
+
+ }
+
+ public Shape paintLayer(Graphics g, int p0, int p1, Shape bounds,
+ JTextComponent c, View view)
+ {
+ paint(g, p0, p1, bounds, c);
+
+ return bounds;
+ }
+ }
+
+ /**
+ * The non wrapping text areas and state buttons.
+ */
+ JTextArea textarea1;
+
+ JTextArea textarea2;
+
+ JTextArea textarea3;
+
+ JCheckBox enabled1;
+
+ JCheckBox editable1;
+
+ JPanel panel1;
+
+ /**
+ * The char wrapping textareas and state buttons.
+ */
+ JTextArea textarea4;
+
+ JTextArea textarea5;
+
+ JTextArea textarea6;
+
+ JCheckBox enabled2;
+
+ JCheckBox editable2;
+
+ /**
+ * The word wrapping textareas and state buttons.
+ */
+ JTextArea textarea7;
+
+ JTextArea textarea8;
+
+ JTextArea textarea9;
+
+ JCheckBox enabled3;
+
+ JCheckBox editable3;
+
+ /**
+ * The custom colored textareas and state buttons.
+ */
+ JTextArea textarea10;
+
+ JTextArea textarea11;
+
+ JTextArea textarea12;
+
+ JTextArea textarea13;
+
+ JTextArea textarea14;
+
+ JTextArea textarea14b;
+
+ JCheckBox enabled4;
+
+ JCheckBox editable4;
+
+ /**
+ * Some miscellaneous textarea demos.
+ */
+ JTextArea textarea15;
+
+ JTextArea textarea16;
+
+ JTextArea textarea17;
+
+ JCheckBox enabled5;
+
+ JCheckBox editable5;
+
+ /**
+ * Creates a new demo instance.
+ */
+ public TextAreaDemo()
+ {
+ super();
+ createContent();
+ }
+
+ /**
+ * When the demo is run independently, the frame is displayed, so we should
+ * initialise the content panel (including the demo content and a close
+ * button). But when the demo is run as part of the Swing activity board, only
+ * the demo content panel is used, the frame itself is never displayed, so we
+ * can avoid this step.
+ */
+ void initFrameContent()
+ {
+ JPanel closePanel = new JPanel();
+ JButton closeButton = new JButton("Close");
+ closeButton.setActionCommand("CLOSE");
+ closeButton.addActionListener(this);
+ closePanel.add(closeButton);
+ add(closePanel, BorderLayout.SOUTH);
+ }
+
+ /**
+ * Returns a panel with the demo content. The panel uses a BorderLayout(), and
+ * the BorderLayout.SOUTH area is empty, to allow callers to add controls to
+ * the bottom of the panel if they want to (a close button is added if this
+ * demo is being run as a standalone demo).
+ */
+ private void createContent()
+ {
+ setLayout(new BorderLayout());
+ JTabbedPane tabPane = new JTabbedPane();
+ tabPane.addTab("Non-wrap", createNonWrapPanel());
+ tabPane.addTab("Char-wrap", createCharWrapPanel());
+ tabPane.addTab("Word-wrap", createWordWrapPanel());
+ tabPane.addTab("Custom colors", createCustomColoredPanel());
+ tabPane.addTab("Misc", createMiscPanel());
+ add(tabPane);
+ }
+
+ private JPanel createNonWrapPanel()
+ {
+ JPanel panel = new JPanel(new BorderLayout());
+ panel.setBorder(BorderFactory.createTitledBorder("Not wrapping"));
+
+ panel1 = new JPanel(new GridLayout(2, 2));
+
+ textarea1 = new JTextArea("Hello World!");
+ textarea1.setFont(new Font("Dialog", Font.PLAIN, 8));
+ panel1.add(new JScrollPane(textarea1));
+
+ textarea2 = new JTextArea("Hello World!");
+ textarea2.setFont(new Font("Dialog", Font.ITALIC, 12));
+ panel1.add(new JScrollPane(textarea2));
+
+ textarea3 = new JTextArea("Hello World!");
+ textarea3.setFont(new Font("Dialog", Font.BOLD, 14));
+ panel1.add(new JScrollPane(textarea3));
+
+ panel.add(panel1);
+
+ JPanel statePanel = new JPanel();
+ statePanel.setLayout(new BoxLayout(statePanel, BoxLayout.Y_AXIS));
+ statePanel.add(Box.createVerticalGlue());
+ enabled1 = new JCheckBox("enabled");
+ enabled1.setSelected(true);
+ enabled1.addActionListener(this);
+ enabled1.setActionCommand("ENABLED1");
+ statePanel.add(enabled1);
+ editable1 = new JCheckBox("editable");
+ editable1.setSelected(true);
+ editable1.addActionListener(this);
+ editable1.setActionCommand("EDITABLE1");
+ statePanel.add(editable1);
+ statePanel.add(Box.createVerticalGlue());
+ panel.add(statePanel, BorderLayout.EAST);
+
+ return panel;
+ }
+
+ private JPanel createCharWrapPanel()
+ {
+ JPanel panel = new JPanel(new BorderLayout());
+ panel.setBorder(BorderFactory.createTitledBorder("Wrap at char bounds"));
+
+ JPanel innerPanel = new JPanel(new GridLayout(2, 2));
+
+ textarea4 = new JTextArea("Hello World!");
+ textarea4.setLineWrap(true);
+ textarea4.setFont(new Font("Dialog", Font.PLAIN, 8));
+ innerPanel.add(new JScrollPane(textarea4));
+
+ textarea5 = new JTextArea("Hello World!");
+ textarea5.setLineWrap(true);
+ textarea5.setFont(new Font("Dialog", Font.ITALIC, 12));
+ innerPanel.add(new JScrollPane(textarea5));
+
+ textarea6 = new JTextArea("Hello World!");
+ textarea6.setLineWrap(true);
+ textarea6.setFont(new Font("Dialog", Font.BOLD, 14));
+ innerPanel.add(new JScrollPane(textarea6));
+
+ panel.add(innerPanel);
+
+ JPanel statePanel = new JPanel();
+ statePanel.setLayout(new BoxLayout(statePanel, BoxLayout.Y_AXIS));
+ statePanel.add(Box.createVerticalGlue());
+ enabled2 = new JCheckBox("enabled");
+ enabled2.setSelected(true);
+ enabled2.addActionListener(this);
+ enabled2.setActionCommand("ENABLED2");
+ statePanel.add(enabled2);
+ editable2 = new JCheckBox("editable");
+ editable2.setSelected(true);
+ editable2.addActionListener(this);
+ editable2.setActionCommand("EDITABLE2");
+ statePanel.add(editable2);
+ statePanel.add(Box.createVerticalGlue());
+ panel.add(statePanel, BorderLayout.EAST);
+
+ return panel;
+ }
+
+ private JPanel createWordWrapPanel()
+ {
+ JPanel panel = new JPanel(new BorderLayout());
+ panel.setBorder(BorderFactory.createTitledBorder("Wrap at word bounds"));
+
+ JPanel innerPanel = new JPanel(new GridLayout(2, 2));
+
+ textarea7 = new JTextArea("Hello World!");
+ textarea7.setWrapStyleWord(true);
+ textarea7.setLineWrap(true);
+ textarea7.setFont(new Font("Dialog", Font.PLAIN, 8));
+ innerPanel.add(new JScrollPane(textarea7));
+
+ textarea8 = new JTextArea("Hello World!");
+ textarea8.setWrapStyleWord(true);
+ textarea8.setLineWrap(true);
+ textarea8.setFont(new Font("Dialog", Font.ITALIC, 12));
+ innerPanel.add(new JScrollPane(textarea8));
+
+ textarea9 = new JTextArea("Hello World!");
+ textarea9.setWrapStyleWord(true);
+ textarea9.setLineWrap(true);
+ textarea9.setFont(new Font("Dialog", Font.BOLD, 14));
+ innerPanel.add(new JScrollPane(textarea9));
+
+ panel.add(innerPanel);
+
+ JPanel statePanel = new JPanel();
+ statePanel.setLayout(new BoxLayout(statePanel, BoxLayout.Y_AXIS));
+ statePanel.add(Box.createVerticalGlue());
+ enabled3 = new JCheckBox("enabled");
+ enabled3.setSelected(true);
+ enabled3.addActionListener(this);
+ enabled3.setActionCommand("ENABLED3");
+ statePanel.add(enabled3);
+ editable3 = new JCheckBox("editable");
+ editable3.setSelected(true);
+ editable3.addActionListener(this);
+ editable3.setActionCommand("EDITABLE3");
+ statePanel.add(editable3);
+ statePanel.add(Box.createVerticalGlue());
+ panel.add(statePanel, BorderLayout.EAST);
+
+ return panel;
+ }
+
+ private JPanel createCustomColoredPanel()
+ {
+ JPanel panel = new JPanel(new BorderLayout());
+
+ JPanel innerPanel = new JPanel(new GridLayout(3, 2));
+ panel.setBorder(BorderFactory.createTitledBorder("Custom colors"));
+
+ textarea10 = new JTextArea("custom foreground", 10, 15);
+ textarea10.setForeground(Color.GREEN);
+ innerPanel.add(new JScrollPane(textarea10));
+
+ textarea11 = new JTextArea("custom background", 10, 15);
+ textarea11.setBackground(Color.YELLOW);
+ innerPanel.add(new JScrollPane(textarea11));
+
+ textarea12 = new JTextArea("custom disabled textcolor", 10, 15);
+ textarea12.setDisabledTextColor(Color.BLUE);
+ innerPanel.add(new JScrollPane(textarea12));
+
+ textarea13 = new JTextArea("custom selected text color", 10, 15);
+ textarea13.setSelectedTextColor(Color.RED);
+ innerPanel.add(new JScrollPane(textarea13));
+
+ textarea14 = new JTextArea("custom selection color", 10, 15);
+ textarea14.setSelectionColor(Color.RED);
+ innerPanel.add(new JScrollPane(textarea14));
+
+ textarea14b = new JTextArea("custom selection and selected text color", 10, 15);
+ textarea14b.setSelectedTextColor(Color.WHITE);
+ textarea14b.setSelectionColor(Color.BLACK);
+ innerPanel.add(new JScrollPane(textarea14b));
+
+ panel.add(innerPanel);
+
+ JPanel statePanel = new JPanel();
+ statePanel.setLayout(new BoxLayout(statePanel, BoxLayout.Y_AXIS));
+ statePanel.add(Box.createVerticalGlue());
+ enabled4 = new JCheckBox("enabled");
+ enabled4.setSelected(true);
+ enabled4.addActionListener(this);
+ enabled4.setActionCommand("ENABLED4");
+ statePanel.add(enabled4);
+ editable4 = new JCheckBox("editable");
+ editable4.setSelected(true);
+ editable4.addActionListener(this);
+ editable4.setActionCommand("EDITABLE4");
+ statePanel.add(editable4);
+ statePanel.add(Box.createVerticalGlue());
+ panel.add(statePanel, BorderLayout.EAST);
+
+ return panel;
+ }
+
+ private JPanel createMiscPanel()
+ {
+ JPanel panel = new JPanel(new BorderLayout());
+ panel.setBorder(BorderFactory.createTitledBorder("Miscellaneous"));
+
+ JPanel innerPanel = new JPanel(new GridLayout(2, 2));
+
+ textarea15 = new JTextArea("Custom Caret");
+ textarea15.setCaret(new CornerCaret());
+ innerPanel.add(new JScrollPane(textarea15));
+
+ textarea16 = new JTextArea("Custom Caret color");
+ textarea16.setCaretColor(Color.MAGENTA);
+ innerPanel.add(new JScrollPane(textarea16));
+
+ textarea16 = new JTextArea("Custom Selection painter");
+ textarea16.setFont(new Font("Dialog", Font.PLAIN, 24));
+ textarea16.setCaret(new DefaultCaret()
+ {
+ public Highlighter.HighlightPainter getSelectionPainter()
+ {
+ return DemoHighlightPainter.INSTANCE;
+ }
+ });
+
+ innerPanel.add(new JScrollPane(textarea16));
+
+ panel.add(innerPanel);
+
+ JPanel statePanel = new JPanel();
+ statePanel.setLayout(new BoxLayout(statePanel, BoxLayout.Y_AXIS));
+ statePanel.add(Box.createVerticalGlue());
+ enabled5 = new JCheckBox("enabled");
+ enabled5.setSelected(true);
+ enabled5.addActionListener(this);
+ enabled5.setActionCommand("ENABLED5");
+ statePanel.add(enabled5);
+ editable5 = new JCheckBox("editable");
+ editable5.setSelected(true);
+ editable5.addActionListener(this);
+ editable5.setActionCommand("EDITABLE5");
+ statePanel.add(editable5);
+ statePanel.add(Box.createVerticalGlue());
+ panel.add(statePanel, BorderLayout.EAST);
+
+ return panel;
+ }
+
+ public void actionPerformed(ActionEvent e)
+ {
+ if (e.getActionCommand().equals("CLOSE"))
+ {
+ System.exit(0);
+ }
+ else if (e.getActionCommand().equals("ENABLED1"))
+ {
+ boolean enabled = enabled1.isSelected();
+ textarea1.setEnabled(enabled);
+ textarea2.setEnabled(enabled);
+ textarea3.setEnabled(enabled);
+ }
+ else if (e.getActionCommand().equals("EDITABLE1"))
+ {
+ boolean editable = editable1.isSelected();
+ textarea1.setEditable(editable);
+ textarea2.setEditable(editable);
+ textarea3.setEditable(editable);
+ }
+ else if (e.getActionCommand().equals("ENABLED2"))
+ {
+ boolean enabled = enabled2.isSelected();
+ textarea4.setEnabled(enabled);
+ textarea5.setEnabled(enabled);
+ textarea6.setEnabled(enabled);
+ }
+ else if (e.getActionCommand().equals("EDITABLE2"))
+ {
+ boolean editable = editable2.isSelected();
+ textarea4.setEditable(editable);
+ textarea5.setEditable(editable);
+ textarea6.setEditable(editable);
+ }
+ else if (e.getActionCommand().equals("ENABLED3"))
+ {
+ boolean enabled = enabled3.isSelected();
+ textarea7.setEnabled(enabled);
+ textarea8.setEnabled(enabled);
+ textarea9.setEnabled(enabled);
+ }
+ else if (e.getActionCommand().equals("EDITABLE3"))
+ {
+ boolean editable = editable3.isSelected();
+ textarea7.setEditable(editable);
+ textarea8.setEditable(editable);
+ textarea9.setEditable(editable);
+ }
+ else if (e.getActionCommand().equals("ENABLED4"))
+ {
+ boolean enabled = enabled4.isSelected();
+ textarea10.setEnabled(enabled);
+ textarea11.setEnabled(enabled);
+ textarea12.setEnabled(enabled);
+ textarea13.setEnabled(enabled);
+ textarea14.setEnabled(enabled);
+ textarea14b.setEnabled(enabled);
+ }
+ else if (e.getActionCommand().equals("EDITABLE4"))
+ {
+ boolean editable = editable4.isSelected();
+ textarea10.setEditable(editable);
+ textarea11.setEditable(editable);
+ textarea12.setEditable(editable);
+ textarea13.setEditable(editable);
+ textarea14.setEditable(editable);
+ textarea14b.setEditable(editable);
+ }
+ }
+
+ public static void main(String[] args)
+ {
+ SwingUtilities.invokeLater
+ (new Runnable()
+ {
+ public void run()
+ {
+ TextAreaDemo app = new TextAreaDemo();
+ app.initFrameContent();
+ JFrame frame = new JFrame();
+ frame.getContentPane().add(app);
+ frame.pack();
+ frame.setVisible(true);
+ }
+ });
+ }
+
+ /**
+ * Returns a DemoFactory that creates a TextAreaDemo.
+ *
+ * @return a DemoFactory that creates a TextAreaDemo
+ */
+ public static DemoFactory createDemoFactory()
+ {
+ return new DemoFactory()
+ {
+ public JComponent createDemo()
+ {
+ return new TextAreaDemo();
+ }
+ };
+ }
+}
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/TextFieldDemo.java b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/TextFieldDemo.java
new file mode 100644
index 000000000..ba0fefa31
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/TextFieldDemo.java
@@ -0,0 +1,594 @@
+/* TextFieldDemo.java -- An example showing various textfields in Swing.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath examples.
+
+GNU Classpath 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, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+*/
+
+
+package gnu.classpath.examples.swing;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.Graphics;
+import java.awt.GridLayout;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.Shape;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.BorderFactory;
+import javax.swing.Box;
+import javax.swing.BoxLayout;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JComponent;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextField;
+import javax.swing.SwingUtilities;
+import javax.swing.border.CompoundBorder;
+import javax.swing.border.EmptyBorder;
+import javax.swing.border.LineBorder;
+import javax.swing.border.TitledBorder;
+import javax.swing.text.BadLocationException;
+import javax.swing.text.DefaultCaret;
+import javax.swing.text.Highlighter;
+import javax.swing.text.JTextComponent;
+import javax.swing.text.View;
+import javax.swing.text.LayeredHighlighter.LayerPainter;
+
+/**
+ * A simple textfield demo showing various textfields in different states.
+ */
+public class TextFieldDemo
+ extends JPanel
+ implements ActionListener
+{
+
+ /**
+ * A custom caret for demonstration purposes. This class is inspired by the
+ * CornerCaret from the OReilly Swing book.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ */
+ static class CornerCaret extends DefaultCaret
+ {
+ public CornerCaret()
+ {
+ super();
+ setBlinkRate(500);
+ }
+
+ protected synchronized void damage(Rectangle r)
+ {
+ if (r == null) return;
+ x = r.x;
+ y = r.y + (r.height * 4 / 5 - 3);
+ width = 5;
+ height = 5;
+ repaint();
+ }
+
+ public void paint(Graphics g)
+ {
+ JTextComponent comp = getComponent();
+ if (comp == null) return;
+ int dot = getDot();
+ Rectangle r = null;
+ try
+ {
+ r = comp.modelToView(dot);
+ }
+ catch (BadLocationException e)
+ {
+ return;
+ }
+ if (r == null) return;
+ int dist = r.height * 4 / 5 - 3;
+ if ((x != r.x) || (y != r.y + dist))
+ {
+ repaint();
+ x = r.x;
+ y = r.y + dist;
+ width = 5;
+ height = 5;
+ }
+ if (isVisible())
+ {
+ g.drawLine(r.x, r.y + dist, r.x, r.y + dist + 4);
+ g.drawLine(r.x, r.y + dist + 4, r.x + 4, r.y + dist + 4);
+ }
+ }
+ }
+
+ static class DemoHighlightPainter
+ extends LayerPainter
+ {
+
+ static DemoHighlightPainter INSTANCE = new DemoHighlightPainter();
+
+
+ static Color[] colors = { Color.BLUE, Color.CYAN, Color.GRAY, Color.GREEN,
+ Color.MAGENTA, Color.ORANGE, Color.PINK,
+ Color.ORANGE, Color.RED, Color.BLUE, Color.YELLOW };
+
+
+ public DemoHighlightPainter()
+ {
+ super();
+ }
+
+ private void paintHighlight(Graphics g, Rectangle rect)
+ {
+ g.fillRect(rect.x, rect.y, rect.width, rect.height);
+ }
+
+ public void paint(Graphics g, int p0, int p1, Shape bounds, JTextComponent t)
+ {
+ try
+ {
+
+ for (int i = p0; i < p1; i++)
+ {
+ Rectangle r = t.modelToView(i);
+ Point l1 = t.modelToView(i + 1).getLocation();
+
+ g.setColor(colors[(int) (Math.random() * colors.length)]);
+ g.fillOval(r.x, r.y, l1.x - r.x, r.height);
+ }
+ }
+ catch (BadLocationException ble)
+ {
+ }
+ }
+
+ public Shape paintLayer(Graphics g, int p0, int p1, Shape bounds,
+ JTextComponent c, View view)
+ {
+ paint(g, p0, p1, bounds, c);
+
+ return bounds;
+ }
+
+ }
+
+ /**
+ * The left aligned textfields and state buttons.
+ */
+ Compound compound1;
+
+ /**
+ * The right aligned textfields and state buttons.
+ */
+ Compound compound2;
+
+ /**
+ * The centered textfields and state buttons.
+ */
+ Compound compound3;
+
+ /**
+ * The custom colored textfields and state buttons.
+ */
+ Compound compound4;
+ Compound compound5;
+
+ /**
+ * Some miscellaneous textfield demos.
+ */
+ Compound compound6;
+
+ /**
+ * Some textfields with custom borders.
+ */
+ Compound compound7;
+
+ /**
+ * Creates a new demo instance.
+ */
+ public TextFieldDemo()
+ {
+ super();
+ createContent();
+ }
+
+ /**
+ * When the demo is run independently, the frame is displayed, so we should
+ * initialise the content panel (including the demo content and a close
+ * button). But when the demo is run as part of the Swing activity board,
+ * only the demo content panel is used, the frame itself is never displayed,
+ * so we can avoid this step.
+ */
+ void initFrameContent()
+ {
+ JPanel closePanel = new JPanel();
+ JButton closeButton = new JButton("Close");
+ closeButton.setActionCommand("CLOSE");
+ closeButton.addActionListener(this);
+ closePanel.add(closeButton);
+ add(closePanel, BorderLayout.SOUTH);
+ }
+
+ /**
+ * Returns a panel with the demo content. The panel
+ * uses a BorderLayout(), and the BorderLayout.SOUTH area
+ * is empty, to allow callers to add controls to the
+ * bottom of the panel if they want to (a close button is
+ * added if this demo is being run as a standalone demo).
+ */
+ private void createContent()
+ {
+ setLayout(new BorderLayout());
+ JPanel panel = new JPanel(new GridLayout(7, 1));
+ panel.add(createLeftAlignedPanel());
+ panel.add(createRightAlignedPanel());
+ panel.add(createCenteredPanel());
+ panel.add(createCustomColorPanel1());
+ panel.add(createCustomColorPanel2());
+ panel.add(createCustomBordersPanel());
+ panel.add(createMiscPanel());
+
+ // Put everything in a scroll pane to make it neccessary
+ // to reach the bottom inner panels if the screen is to small.
+ add(new JScrollPane(panel));
+ }
+
+ private JPanel createLeftAlignedPanel()
+ {
+ compound1 = createTextFieldCompound("Left aligned", 1);
+
+ compound1.setupTextfields("Hello World!",
+ JTextField.LEFT,
+ new Font[] { new Font("Dialog", Font.PLAIN, 8),
+ new Font("Dialog", Font.ITALIC, 12),
+ new Font("Dialog", Font.BOLD, 14)
+ });
+
+ return compound1.panel;
+ }
+
+ private Compound createTextFieldCompound(String title, int actionCommandNo)
+ {
+ Compound compound = new Compound();
+ compound.panel = new JPanel(new BorderLayout());
+ compound.panel.setBorder(BorderFactory.createTitledBorder(title));
+
+ compound.textFieldPanel = new JPanel();
+ compound.textFieldPanel.setLayout(new BoxLayout(compound.textFieldPanel, BoxLayout.X_AXIS));
+
+ compound.panel.add(compound.textFieldPanel);
+
+ JPanel statePanel = new JPanel();
+ statePanel.setLayout(new BoxLayout(statePanel, BoxLayout.Y_AXIS));
+ statePanel.add(Box.createVerticalGlue());
+ compound.enabled = new JCheckBox("enabled");
+ compound.enabled.setSelected(true);
+ compound.enabled.addActionListener(this);
+ compound.enabled.setActionCommand("ENABLED" + actionCommandNo);
+ statePanel.add(compound.enabled);
+ compound.editable = new JCheckBox("editable");
+ compound.editable.setSelected(true);
+ compound.editable.addActionListener(this);
+ compound.editable.setActionCommand("EDITABLE" + actionCommandNo);
+ statePanel.add(compound.editable);
+ statePanel.add(Box.createVerticalGlue());
+ compound.panel.add(statePanel, BorderLayout.EAST);
+
+ return compound;
+ }
+
+ private JPanel createRightAlignedPanel()
+ {
+ compound2 = createTextFieldCompound("Right aligned", 2);
+
+ compound2.setupTextfields("Hello World!",
+ JTextField.RIGHT,
+ new Font[] { new Font("Dialog", Font.PLAIN, 8),
+ new Font("Dialog", Font.ITALIC, 12),
+ new Font("Dialog", Font.BOLD, 14)
+ });
+
+ return compound2.panel;
+ }
+
+ private JPanel createCenteredPanel()
+ {
+ compound3 = createTextFieldCompound("Centered", 3);
+
+ compound3.setupTextfields("Hello World!",
+ JTextField.CENTER,
+ new Font[] { new Font("Dialog", Font.PLAIN, 8),
+ new Font("Dialog", Font.ITALIC, 12),
+ new Font("Dialog", Font.BOLD, 14)
+ });
+
+ return compound3.panel;
+ }
+
+ private JPanel createCustomColorPanel1()
+ {
+ compound4 = createTextFieldCompound("Custom colors I", 4);
+
+ compound4.textfield1 = new JTextField("custom foreground");
+ compound4.textfield1.setForeground(Color.RED);
+ compound4.textFieldPanel.add(compound4.textfield1);
+
+ compound4.textfield2 = new JTextField("custom background");
+ compound4.textfield2.setBackground(Color.YELLOW);
+ compound4.textFieldPanel.add(compound4.textfield2);
+
+ compound4.textfield3 = new JTextField("custom foreground and background");
+ compound4.textfield3.setForeground(Color.RED);
+ compound4.textfield3.setBackground(Color.YELLOW);
+ compound4.textFieldPanel.add(compound4.textfield3);
+
+ return compound4.panel;
+
+ }
+
+ private JPanel createCustomColorPanel2()
+ {
+ compound5 = createTextFieldCompound("Custom colors II", 5);
+
+ compound5.textfield1 = new JTextField("custom disabled textcolor");
+ compound5.textfield1.setDisabledTextColor(Color.BLUE);
+ compound5.textFieldPanel.add(compound5.textfield1);
+
+ compound5.textfield2 = new JTextField("custom selected text color");
+ compound5.textfield2.setSelectedTextColor(Color.RED);
+ compound5.textFieldPanel.add(compound5.textfield2);
+
+ compound5.textfield3 = new JTextField("custom selection color");
+ compound5.textfield3.setSelectionColor(Color.BLACK);
+ compound5.textFieldPanel.add(compound5.textfield3);
+
+ return compound5.panel;
+
+ }
+
+ private JPanel createMiscPanel()
+ {
+ compound6 = createTextFieldCompound("Miscellaneous", 6);
+
+ compound6.textfield1 = new JTextField("Custom Caret");
+ compound6.textfield1.setCaret(new CornerCaret());
+ compound6.textFieldPanel.add(compound6.textfield1);
+
+ compound6.textfield2 = new JTextField("Custom Caret color");
+ compound6.textfield2.setForeground(Color.LIGHT_GRAY);
+ compound6.textfield2.setBackground(Color.BLACK);
+ compound6.textfield2.setSelectedTextColor(Color.BLACK);
+ compound6.textfield2.setCaretColor(Color.WHITE);
+ compound6.textfield2.setSelectionColor(Color.DARK_GRAY);
+ compound6.textFieldPanel.add(compound6.textfield2);
+
+ compound6.textfield3 = new JTextField("Custom highlighter");
+ compound6.textfield3.setCaret(new DefaultCaret()
+ {
+ public Highlighter.HighlightPainter getSelectionPainter()
+ {
+ return DemoHighlightPainter.INSTANCE;
+ }
+ });
+ compound6.textFieldPanel.add(compound6.textfield3);
+
+ return compound6.panel;
+ }
+
+ private JPanel createCustomBordersPanel()
+ {
+ compound7 = createTextFieldCompound("Custom borders", 7);
+
+ compound7.textfield1 = new JTextField("red 5 pixel lineborder");
+ compound7.textfield1.setBorder(new LineBorder(Color.RED, 5));
+ compound7.textFieldPanel.add(compound7.textfield1);
+
+ compound7.textfield2 = new JTextField("complex irregular border");
+
+ CompoundBorder innerCompound = new CompoundBorder(new EmptyBorder(5, 40, 15, 10), new LineBorder(Color.BLACK));
+ CompoundBorder outerCompound = new CompoundBorder(new LineBorder(Color.BLACK), innerCompound);
+ compound7.textfield2.setBorder(outerCompound);
+ compound7.textFieldPanel.add(compound7.textfield2);
+
+ compound7.textfield3 = new JTextField("a titled border", 10);
+ compound7.textfield3.setBorder(new TitledBorder(null, "Freak Out Border", TitledBorder.CENTER, TitledBorder.LEFT));
+ compound7.textFieldPanel.add(compound7.textfield3);
+
+ return compound7.panel;
+ }
+
+ public void actionPerformed(ActionEvent e)
+ {
+ if (e.getActionCommand().equals("CLOSE"))
+ {
+ System.exit(0);
+ }
+ else if (e.getActionCommand().equals("ENABLED1"))
+ {
+ boolean enabled = compound1.enabled.isSelected();
+ compound1.textfield1.setEnabled(enabled);
+ compound1.textfield2.setEnabled(enabled);
+ compound1.textfield3.setEnabled(enabled);
+ }
+ else if (e.getActionCommand().equals("EDITABLE1"))
+ {
+ boolean editable = compound1.editable.isSelected();
+ compound1.textfield1.setEditable(editable);
+ compound1.textfield2.setEditable(editable);
+ compound1.textfield3.setEditable(editable);
+ }
+ else if (e.getActionCommand().equals("ENABLED2"))
+ {
+ boolean enabled = compound2.enabled.isSelected();
+ compound2.textfield1.setEnabled(enabled);
+ compound2.textfield2.setEnabled(enabled);
+ compound2.textfield3.setEnabled(enabled);
+ }
+ else if (e.getActionCommand().equals("EDITABLE2"))
+ {
+ boolean editable = compound2.editable.isSelected();
+ compound2.textfield1.setEditable(editable);
+ compound2.textfield2.setEditable(editable);
+ compound2.textfield3.setEditable(editable);
+ }
+ else if (e.getActionCommand().equals("ENABLED3"))
+ {
+ boolean enabled = compound3.enabled.isSelected();
+ compound3.textfield1.setEnabled(enabled);
+ compound3.textfield2.setEnabled(enabled);
+ compound3.textfield3.setEnabled(enabled);
+ }
+ else if (e.getActionCommand().equals("EDITABLE3"))
+ {
+ boolean editable = compound3.editable.isSelected();
+ compound3.textfield1.setEditable(editable);
+ compound3.textfield2.setEditable(editable);
+ compound3.textfield3.setEditable(editable);
+ }
+ else if (e.getActionCommand().equals("ENABLED4"))
+ {
+ boolean enabled = compound4.enabled.isSelected();
+ compound4.textfield1.setEnabled(enabled);
+ compound4.textfield2.setEnabled(enabled);
+ compound4.textfield3.setEnabled(enabled);
+ }
+ else if (e.getActionCommand().equals("EDITABLE4"))
+ {
+ boolean editable = compound4.editable.isSelected();
+ compound4.textfield1.setEditable(editable);
+ compound4.textfield2.setEditable(editable);
+ compound4.textfield3.setEditable(editable);
+ }
+ else if (e.getActionCommand().equals("ENABLED5"))
+ {
+ boolean enabled = compound5.enabled.isSelected();
+ compound5.textfield1.setEnabled(enabled);
+ compound5.textfield2.setEnabled(enabled);
+ compound5.textfield3.setEnabled(enabled);
+ }
+ else if (e.getActionCommand().equals("EDITABLE5"))
+ {
+ boolean editable = compound5.editable.isSelected();
+ compound5.textfield1.setEditable(editable);
+ compound5.textfield2.setEditable(editable);
+ compound5.textfield3.setEditable(editable);
+ }
+ else if (e.getActionCommand().equals("ENABLED6"))
+ {
+ boolean enabled = compound6.enabled.isSelected();
+ compound6.textfield1.setEnabled(enabled);
+ compound6.textfield2.setEnabled(enabled);
+ compound6.textfield3.setEnabled(enabled);
+ }
+ else if (e.getActionCommand().equals("EDITABLE6"))
+ {
+ boolean editable = compound6.editable.isSelected();
+ compound6.textfield1.setEditable(editable);
+ compound6.textfield2.setEditable(editable);
+ compound6.textfield3.setEditable(editable);
+ }
+ else if (e.getActionCommand().equals("ENABLED7"))
+ {
+ boolean enabled = compound7.enabled.isSelected();
+ compound7.textfield1.setEnabled(enabled);
+ compound7.textfield2.setEnabled(enabled);
+ compound7.textfield3.setEnabled(enabled);
+ }
+ else if (e.getActionCommand().equals("EDITABLE7"))
+ {
+ boolean editable = compound7.editable.isSelected();
+ compound7.textfield1.setEditable(editable);
+ compound7.textfield2.setEditable(editable);
+ compound7.textfield3.setEditable(editable);
+ }
+ }
+
+ public static void main(String[] args)
+ {
+ SwingUtilities.invokeLater
+ (new Runnable()
+ {
+ public void run()
+ {
+ TextFieldDemo app = new TextFieldDemo();
+ app.initFrameContent();
+ JFrame frame = new JFrame("TextField demo");
+ frame.getContentPane().add(app);
+ frame.pack();
+ frame.setVisible(true);
+ }
+ });
+ }
+
+ /**
+ * Returns a DemoFactory that creates a TextFieldDemo.
+ *
+ * @return a DemoFactory that creates a TextFieldDemo
+ */
+ public static DemoFactory createDemoFactory()
+ {
+ return new DemoFactory()
+ {
+ public JComponent createDemo()
+ {
+ return new TextFieldDemo();
+ }
+ };
+ }
+
+ static class Compound
+ {
+ JTextField textfield1;
+ JTextField textfield2;
+ JTextField textfield3;
+ JCheckBox enabled;
+ JCheckBox editable;
+ JPanel textFieldPanel;
+ JPanel panel;
+
+ /** Creates and initializes the textfields with the same text and
+ * alignment but with a different font.
+ *
+ * @param title The text for the textfields.
+ * @param align The alignment for the textfields.
+ * @param fonts The fonts to be used for the textfields.
+ */
+ void setupTextfields(String title, int align, Font[] fonts)
+ {
+ textfield1 = new JTextField(title);
+ textfield1.setHorizontalAlignment(align);
+ textfield1.setFont(fonts[0]);
+ textFieldPanel.add(textfield1);
+
+ textfield2 = new JTextField(title);
+ textfield2.setHorizontalAlignment(align);
+ textfield2.setFont(fonts[1]);
+ textFieldPanel.add(textfield2);
+
+ textfield3 = new JTextField(title);
+ textfield3.setHorizontalAlignment(align);
+ textfield3.setFont(fonts[2]);
+ textFieldPanel.add(textfield3);
+ }
+
+ }
+
+}
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/TreeDemo.java b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/TreeDemo.java
new file mode 100644
index 000000000..8da375071
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/TreeDemo.java
@@ -0,0 +1,318 @@
+/* TreeDemo.java -- Demostrates JTree
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath 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, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.examples.swing;
+
+import java.awt.BorderLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.ButtonGroup;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JComponent;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JRadioButton;
+import javax.swing.JScrollPane;
+import javax.swing.JTree;
+import javax.swing.SwingUtilities;
+import javax.swing.event.TreeSelectionEvent;
+import javax.swing.event.TreeSelectionListener;
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.DefaultTreeModel;
+import javax.swing.tree.DefaultTreeSelectionModel;
+import javax.swing.tree.TreePath;
+
+public class TreeDemo
+ extends JPanel
+ implements ActionListener
+{
+
+ TreeDemo()
+ {
+ super();
+ createContent();
+ }
+
+ private void createContent()
+ {
+ // non-leafs
+ DefaultMutableTreeNode root = new DefaultMutableTreeNode("Exotic Subsistence");
+ DefaultMutableTreeNode fruit = new DefaultMutableTreeNode("Interesting Fruit");
+ DefaultMutableTreeNode veg = new DefaultMutableTreeNode("Extraordinary Vegetables");
+ DefaultMutableTreeNode liq = new DefaultMutableTreeNode("Peculiar Liquids");
+
+ // leafs
+ DefaultMutableTreeNode f1 = new DefaultMutableTreeNode("Abiu");
+ DefaultMutableTreeNode f2 = new DefaultMutableTreeNode("Bamboo Shoots");
+ DefaultMutableTreeNode f3 = new DefaultMutableTreeNode("Breadfruit");
+ DefaultMutableTreeNode f4 = new DefaultMutableTreeNode("Canistel");
+ DefaultMutableTreeNode f5 = new DefaultMutableTreeNode("Duku");
+ DefaultMutableTreeNode f6 = new DefaultMutableTreeNode("Guava");
+ DefaultMutableTreeNode f7 = new DefaultMutableTreeNode("Jakfruit");
+ DefaultMutableTreeNode f8 = new DefaultMutableTreeNode("Quaribea");
+
+ DefaultMutableTreeNode v1 = new DefaultMutableTreeNode("Amaranth");
+ DefaultMutableTreeNode v2 = new DefaultMutableTreeNode("Kiwano");
+ DefaultMutableTreeNode v3 = new DefaultMutableTreeNode("Leeks");
+ DefaultMutableTreeNode v4 = new DefaultMutableTreeNode("Luffa");
+ DefaultMutableTreeNode v5 = new DefaultMutableTreeNode("Chayote");
+ DefaultMutableTreeNode v6 = new DefaultMutableTreeNode("Jicama");
+ DefaultMutableTreeNode v7 = new DefaultMutableTreeNode("Okra");
+
+ DefaultMutableTreeNode l1 = new DefaultMutableTreeNode("Alcoholic");
+ DefaultMutableTreeNode l11 = new DefaultMutableTreeNode("Caipirinha");
+ DefaultMutableTreeNode l21 = new DefaultMutableTreeNode("Mojito");
+ DefaultMutableTreeNode l31 = new DefaultMutableTreeNode("Margarita");
+ DefaultMutableTreeNode l41 = new DefaultMutableTreeNode("Martini");
+ DefaultMutableTreeNode l5 = new DefaultMutableTreeNode("Non Alcoholic");
+ DefaultMutableTreeNode l55 = new DefaultMutableTreeNode("Babaji");
+ DefaultMutableTreeNode l65 = new DefaultMutableTreeNode("Chikita");
+
+ root.add(fruit);
+ root.add(veg);
+ root.add(liq);
+ fruit.add(f1);
+ fruit.add(f2);
+ fruit.add(f3);
+ fruit.add(f4);
+ fruit.add(f5);
+ fruit.add(f6);
+ fruit.add(f7);
+ fruit.add(f8);
+ veg.add(v1);
+ veg.add(v2);
+ veg.add(v3);
+ veg.add(v4);
+ veg.add(v5);
+ veg.add(v6);
+ veg.add(v7);
+ liq.add(l1);
+ l1.add(l11);
+ l1.add(l21);
+ l1.add(l31);
+ l1.add(l41);
+ liq.add(l5);
+ l5.add(l55);
+ l5.add(l65);
+
+ final JTree tree = new JTree(root);
+ tree.setLargeModel(true);
+ tree.setEditable(true);
+ final DefaultTreeSelectionModel selModel = new DefaultTreeSelectionModel();
+ selModel.setSelectionMode(
+ DefaultTreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
+ tree.setSelectionModel(selModel);
+
+ // buttons to add and delete
+ JButton add = new JButton("add element");
+ add.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ for (int i = 0; i < tree.getRowCount(); i++)
+ {
+ if (tree.isRowSelected(i))
+ {
+ TreePath p = tree.getPathForRow(i);
+ DefaultMutableTreeNode n = (DefaultMutableTreeNode) p.
+ getLastPathComponent();
+ n.add(new DefaultMutableTreeNode("New Element"));
+
+ // The expansion state of the parent node does not change
+ // by default. We will expand it manually, to ensure that the
+ // added node is immediately visible.
+ tree.expandPath(p);
+
+ // Refresh the tree (.repaint would be not enough both in
+ // Classpath and Sun implementations).
+ DefaultTreeModel model = (DefaultTreeModel) tree.getModel();
+ model.reload(n);
+ break;
+ }
+ }
+ }
+ });
+
+ // Demonstration of the various selection modes
+ final JCheckBox cbSingle = new JCheckBox("single selection");
+ cbSingle.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ if (cbSingle.isSelected())
+ selModel.setSelectionMode(
+ DefaultTreeSelectionModel.SINGLE_TREE_SELECTION);
+ else
+ selModel.setSelectionMode(
+ DefaultTreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
+ }
+ });
+
+ // Demonstration of the root visibility changes
+ final JCheckBox cbRoot = new JCheckBox("root");
+ cbRoot.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ tree.setRootVisible(cbRoot.isSelected());
+ }
+ });
+ cbRoot.setSelected(true);
+
+ // Demonstration of the tree selection listener.
+ final JLabel choice = new JLabel("Make a choice");
+ tree.getSelectionModel().addTreeSelectionListener(
+ new TreeSelectionListener()
+ {
+ public void valueChanged(TreeSelectionEvent event)
+ {
+ TreePath was = event.getOldLeadSelectionPath();
+ TreePath now = event.getNewLeadSelectionPath();
+ String swas =
+ was == null ? "none":was.getLastPathComponent().toString();
+ String snow =
+ now == null ? "none":now.getLastPathComponent().toString();
+ choice.setText("From "+swas+" to "+snow);
+ }
+ }
+ );
+
+ setLayout(new BorderLayout());
+
+ JPanel p2 = new JPanel();
+ p2.add(add);
+ p2.add(cbSingle);
+ p2.add(cbRoot);
+
+ tree.getSelectionModel().
+ setSelectionMode(DefaultTreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
+
+ // Panel for selecting line style.
+ ActionListener l = new ActionListener()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ JRadioButton b = (JRadioButton) e.getSource();
+ tree.putClientProperty("JTree.lineStyle", b.getText());
+ tree.repaint();
+ }
+ };
+ JPanel lineStylePanel = new JPanel();
+ ButtonGroup buttons = new ButtonGroup();
+ lineStylePanel.add(new JLabel("Line style: "));
+ JRadioButton none = new JRadioButton("None");
+ lineStylePanel.add(none);
+ buttons.add(none);
+ none.addActionListener(l);
+ JRadioButton angled = new JRadioButton("Angled");
+ lineStylePanel.add(angled);
+ buttons.add(angled);
+ angled.addActionListener(l);
+ JRadioButton horizontal = new JRadioButton("Horizontal");
+ lineStylePanel.add(horizontal);
+ buttons.add(horizontal);
+ horizontal.addActionListener(l);
+ p2.add(lineStylePanel);
+
+ add(p2, BorderLayout.NORTH);
+
+ add(new JScrollPane(tree), BorderLayout.CENTER);
+ add(choice, BorderLayout.SOUTH);
+ }
+
+ public void actionPerformed(ActionEvent e)
+ {
+ if (e.getActionCommand().equals("CLOSE"))
+ {
+ System.exit(0);
+ }
+ }
+
+ /**
+ * When the demo is run independently, the frame is displayed, so we should
+ * initialise the content panel (including the demo content and a close
+ * button). But when the demo is run as part of the Swing activity board,
+ * only the demo content panel is used, the frame itself is never displayed,
+ * so we can avoid this step.
+ */
+ void initFrameContent()
+ {
+ JPanel closePanel = new JPanel();
+ JButton closeButton = new JButton("Close");
+ closeButton.setActionCommand("CLOSE");
+ closeButton.addActionListener(this);
+ closePanel.add(closeButton);
+ add(closePanel, BorderLayout.SOUTH);
+ }
+
+ public static void main(String[] args)
+ {
+ SwingUtilities.invokeLater
+ (new Runnable()
+ {
+ public void run()
+ {
+ TreeDemo app = new TreeDemo();
+ app.initFrameContent();
+ JFrame frame = new JFrame("Tree Demo");
+ frame.getContentPane().add(app);
+ frame.pack();
+ frame.setVisible(true);
+ }
+ });
+ }
+
+ /**
+ * Returns a DemoFactory that creates a TreeDemo.
+ *
+ * @return a DemoFactory that creates a TreeDemo
+ */
+ public static DemoFactory createDemoFactory()
+ {
+ return new DemoFactory()
+ {
+ public JComponent createDemo()
+ {
+ return new TreeDemo();
+ }
+ };
+ }
+}
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/forms.html b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/forms.html
new file mode 100644
index 000000000..010a94c93
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/forms.html
@@ -0,0 +1,98 @@
+<!-- welcome.html -- Some HTML stuff to show Swing HTML
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath 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, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. -->
+
+<html>
+
+ <head>
+ <title>HTML text styles</title>
+ </head>
+ <body>
+ <form>
+ <a href="welcome.html">Back to start page</a>
+ <h1>Some form elements</h1>
+ <h2>Textarea</h2>
+ <textarea cols="30" rows="5">
+ Hello GNU Classpath world. This text should show up in a text area
+ that has a size of 30 columns and 5 rows
+ </textarea>
+
+ <h2>Input fields</h2>
+ <p>
+ <input type="text" value="This is a normal textfield">
+ <input type="password" value="secret password">
+ </p>
+
+ <h2>Buttons</h2>
+ <p>
+ <input type="submit"></input>
+ <input type="reset"></input>
+ <input type="button" value="Some button"></input>
+ </p>
+
+ <h2>Checkboxes and Radiobuttons</h2>
+ <p>
+ <input type="checkbox" name="2">Check this!</input>
+ <input type="checkbox" name="2">Or this</input>
+ </p>
+ <p>
+ <input type="radio" name="1">A radio button</input>
+ <input type="radio" name="1">Another radio</input>
+ </p>
+ <h2>Select lists and combo boxes</h2>
+ <p>
+ <select>
+ <option>Value1</option>
+ <option>Value2</option>
+ <option>Value3</option>
+ <option label="Labeled value 4">Value4</option>
+ <option>Value5</option>
+ <option>Value6</option>
+ </select>
+ </p>
+ <p>
+ <select size="3">
+ <option>Value1</option>
+ <option>Value2</option>
+ <option>Value3</option>
+ <option label="Labeled value 4">Value4</option>
+ <option>Value5</option>
+ <option>Value6</option>
+ </select>
+ </p>
+ </form>
+ </body>
+</html> \ No newline at end of file
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/frame1.html b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/frame1.html
new file mode 100644
index 000000000..b9150592f
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/frame1.html
@@ -0,0 +1,41 @@
+<!-- frame1.html -- Some HTML stuff to show Swing HTML
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath 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, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. -->
+<html>
+<body>
+<h1>Top Left Frame</h1>
+</body>
+</html>
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/frame2.html b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/frame2.html
new file mode 100644
index 000000000..9dbf33c5a
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/frame2.html
@@ -0,0 +1,42 @@
+<!-- frame2.html -- Some HTML stuff to show Swing HTML
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath 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, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. -->
+<html>
+<body>
+<h1>Top Right
+ Frame</h1>
+</body>
+</html>
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/frame3.html b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/frame3.html
new file mode 100644
index 000000000..e677bd6a1
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/frame3.html
@@ -0,0 +1,42 @@
+<!-- frame3.html -- Some HTML stuff to show Swing HTML
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath 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, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. -->
+<html>
+<body>
+<h1>Bottom Left Frame</h1>
+</body>
+</html>
+
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/frame4.html b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/frame4.html
new file mode 100644
index 000000000..1da53b101
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/frame4.html
@@ -0,0 +1,41 @@
+<!-- frame4.html -- Some HTML stuff to show Swing HTML
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath 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, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. -->
+<html>
+<body>
+<h1>Bottom Left Frame</h1>
+</body>
+</html>
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/frames.html b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/frames.html
new file mode 100644
index 000000000..e7e2bf87c
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/frames.html
@@ -0,0 +1,44 @@
+<!-- frames.html -- Some HTML stuff to show Swing HTML
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath 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, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. -->
+<html>
+<frameset cols="40%,60%" rows="20%,80%">
+ <frame src="frame1.html">
+ <frame src="frame2.html">
+ <frame src="frame3.html">
+ <frame src="frame4.html">
+</frameset>
+</html> \ No newline at end of file
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/tables.html b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/tables.html
new file mode 100644
index 000000000..af908e1ab
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/tables.html
@@ -0,0 +1,66 @@
+<!-- tables.html -- Some HTML stuff to show Swing HTML
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath 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, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. -->
+
+<html>
+
+<head>
+ <title>HTML text styles</title>
+ </head>
+ <body>
+<h1>Table examples</h1>
+<h2>Table with grid and mixed rowspan/colspan</h2>
+ <table border="1">
+ <tr>
+ <td width="30%" colspan="2">Spans two columns</td>
+ <td rowspan="3">Spans three rows</td>
+ </tr>
+ <tr>
+ <td rowspan="2">Spans two rows</td>
+ <td>This is the center</td>
+ </tr>
+ <tr>
+ <td>This should be in the middle of row number 3</td>
+ </tr>
+ <tr>
+ <td>A small one cell box</td>
+ <td colspan="2" rowspan="2">Spans two x two cells</td>
+ </tr>
+ <tr>
+ <td>Another small one cell box</td>
+ </tr>
+ </table>
+</body></html>
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/textstyles.html b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/textstyles.html
new file mode 100644
index 000000000..786e18b77
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/textstyles.html
@@ -0,0 +1,78 @@
+<!-- welcome.html -- Some HTML stuff to show Swing HTML
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath 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, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. -->
+
+<html>
+
+ <head>
+ <title>HTML text styles</title>
+ </head>
+ <body>
+ <a href="welcome.html">Back to start page</a>
+ <h1>Colors</h1>
+ <p>The following are the 16 named colors in HTML. Of course you can also
+ use all RGB colors by specifying a value in the <code>#RRGGBB</code>
+ notation.</p>
+ <p>
+ <font color="black">Black</font>, <font color="gray">Gray</font>,
+ <font color="maroon">Maroon</font>, <font color="red">Red</font>,
+ <font color="green">Green</font>, <font color="lime">Lime</font>,
+ <font color="olive">Olive</font>, <font color="yellow">Yellow</font>,
+ <font color="navy">Navy</font>, <font color="blue">Blue</font>,
+ <font color="purple">Purple</font>, <font color="fuchsia">Fuchsia</font>,
+ <font color="teal">Teal</font>, <font color="aque">Aqua</font>,
+ <font color="silver">Silver</font>, <font color="white">White</font></p>
+ <h1>Font styles</h1>
+ <p>The following lists the logical and physical font styles that can be set
+ by certain HTML tags</p>
+ <p>
+ <!--<abbr>Abbreviation</abbr>, <acronym>Acronym</acronym>,-->
+ <address>Address</address>, <b>Bold</b>, <big>Big</big>,
+ <cite>Citation</cite>, <code>Code</code>, <del>Deleted</del>,
+ <em>Emphasized<em>, <i>Italic</i>, <ins>Inserted</ins>, <q>Quote</q>,
+ <s>Stroke-Through</s>, <samp>Example</samp>, <small>Small</small>,
+ <strike>Strike</strike>, <strong>Strong</strong>, <sub>Subscript</sub>,
+ <sup>Superscript</sup>, <u>Underlined</u>, <var>Variable</var>
+ </p>
+ <h1>Header Level 1</h1>
+ <h2>Header Level 2</h2>
+ <h3>Header Level 3</h3>
+ <h4>Header Level 4</h4>
+ <h5>Header Level 5</h5>
+ <h6>Header Level 6</h6>
+ <center>Some centered Text</center>
+ </body>
+</html> \ No newline at end of file
diff --git a/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/welcome.html b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/welcome.html
new file mode 100644
index 000000000..8bc987494
--- /dev/null
+++ b/gcc-4.4.3/libjava/classpath/examples/gnu/classpath/examples/swing/welcome.html
@@ -0,0 +1,63 @@
+<!-- welcome.html -- Some HTML stuff to show Swing HTML
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath 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, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. -->
+
+<html>
+ <head>
+ <title>GNU Classpath HTML Browser</title>
+ </head>
+ <body>
+ <img src="../icons/badge.png" width="100" height="100">
+ <h1>Welcome to GNU Classpath</h1>
+ <h2>A couple of websites that you might want to try out</h2>
+ <ul>
+ <li><a href="http://www.gnu.org/software/classpath/">GNU Classpath homepage</a></li>
+ <li><a href="http://planet.classpath.org">Planet Classpath</a></li>
+ <li><a href="http://developer.classpath.org">GNU Classpath developer pages</a></li>
+ <li><a href="http://www.google.com">Google</a></li>
+ </ul>
+
+ <h2>Testpages</h2>
+ <p>These few pages are here to demonstrate and test the HTML rendering
+ capabilities of GNU Classpath's Swing.</p>
+ <ul>
+ <li><a href="textstyles.html">Text styles</li>
+ <li><a href="forms.html">Form elements</li>
+ <li><a href="tables.html">Tables</li>
+ <li><a href="frames.html">Frames</li>
+ </ul>
+ </body>
+</html> \ No newline at end of file