# HG changeset patch
# User samer
# Date 1554497382 -3600
# Node ID f0fa855432af7e6b0ba8d43e8edd81cd046b247f
# Parent b67a33c44de76aa93475d8ba1ec6654d62e37ad1
Remove stuff
diff -r b67a33c44de7 -r f0fa855432af examples/gui/awt/Light.java
--- a/examples/gui/awt/Light.java Fri Apr 05 21:34:25 2019 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-// program to test lightweight components
-package test.awt;
-
-import java.awt.*;
-import java.awt.event.*;
-import java.applet.*;
-
-
-public class Light extends Applet
-{
- public static void run(Container c)
- {
- c.setLayout(new FlowLayout());
- c.add( new Button("Hello!"));
- c.add( new Lightweight(Color.green,"harpo"));
- c.add( new Lightweight(Color.blue,"groucho"));
- c.add( new Lightweight(Color.red,"zeppo"));
- c.validate();
- }
-
- public static void main(String[] args)
- {
- Frame fr=new Frame("Lightweight test");
- fr.addWindowListener(new WindowAdapter() {
- public void windowClosing(WindowEvent e) {
- System.exit(0);
- }
- } );
- fr.setSize(400,100);
- fr.show();
- run(fr);
- }
-
- public void init()
- {
- setBackground( Color.black);
- setForeground( Color.yellow);
- getParent().setBackground( Color.red);
- run(this);
- }
-
-}
\ No newline at end of file
diff -r b67a33c44de7 -r f0fa855432af examples/gui/awt/LightS.java
--- a/examples/gui/awt/LightS.java Fri Apr 05 21:34:25 2019 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-// program to test lightweight components (Swing version)
-package test.awt;
-
-import java.awt.*;
-import java.awt.event.*;
-import javax.swing.*;
-
-// this is a lightweight component
-
-
-public class LightS extends JApplet
-{
- public static void run(Container c)
- {
- JButton b = new JButton("Hello!");
-
- c.setLayout(new FlowLayout());
- c.add( b);
- c.add( new Lightweight(Color.green,"harpo"));
- c.add( new Lightweight(Color.blue,"groucho"));
- c.add( new Lightweight(Color.red,"zeppo"));
- c.validate();
- }
-
- public static void main(String[] args)
- {
- JFrame fr=new JFrame("Lightweight test");
- fr.addWindowListener(new WindowAdapter() {
- public void windowClosing(WindowEvent e) {
- System.exit(0);
- }
- } );
- fr.setSize(400,100);
- fr.show();
- run(fr.getContentPane());
- }
-
- public void init()
- {
- getParent().setBackground( Color.red);
- run(getContentPane());
- }
-}
\ No newline at end of file
diff -r b67a33c44de7 -r f0fa855432af examples/gui/awt/Lightweight.java
--- a/examples/gui/awt/Lightweight.java Fri Apr 05 21:34:25 2019 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
-// program to test lightweight components
-package test.awt;
-import java.awt.*;
-
-// this is a lightweight component
-
-public class Lightweight extends Component
-{
- Color col;
- String text;
-
- Lightweight(Color color, String label) {
- text=label; col=color;
- setBackground(Color.getHSBColor(0.3F,0.4F,0.7F));
- }
-
- public void paint(Graphics g)
- {
- Dimension d=getSize();
- g.setColor(getBackground());
- g.fillRect(0,0,getWidth(),getHeight());
- g.setColor(getForeground());
- g.drawString(text,10,16);
- }
-
- public boolean isOpaque() { return true; }
- public Dimension getPreferredSize()
- {
- return new Dimension(80,20);
- }
-}
-
diff -r b67a33c44de7 -r f0fa855432af examples/gui/awt/light.html
--- a/examples/gui/awt/light.html Fri Apr 05 21:34:25 2019 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +0,0 @@
-
-Test Applet
-
-
-
-
-
-
-
Lightweight Components
-a test applet
-
-This is blah blah
-
-
-
-
-
diff -r b67a33c44de7 -r f0fa855432af examples/gui/awt/light2.html
--- a/examples/gui/awt/light2.html Fri Apr 05 21:34:25 2019 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +0,0 @@
-
-Test Applet
-
-
-
-
-
-
-
Lightweight Components
-a test applet
-
-This is blah blah
-
-
-
-
-
diff -r b67a33c44de7 -r f0fa855432af examples/gui/awt/tester.java
--- a/examples/gui/awt/tester.java Fri Apr 05 21:34:25 2019 +0100
+++ b/examples/gui/awt/tester.java Fri Apr 05 21:49:42 2019 +0100
@@ -1,70 +1,70 @@
-/*
- * AppletBorders.java
- *
- * Copyright (c) 2000, Samer Abdallah, King's College London.
- * All rights reserved.
- *
- * This software is provided AS iS and WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.
- */
-package test;
-import samer.core.*;
-import samer.core.util.*;
-import samer.core.util.heavy.*;
-import samer.core.util.heavy.Borders.*;
-import samer.core.util.Tools;
-import java.awt.*;
-
+/*
+ * AppletBorders.java
+ *
+ * Copyright (c) 2000, Samer Abdallah, King's College London.
+ * All rights reserved.
+ *
+ * This software is provided AS iS and WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.
+ */
+package test;
+import samer.core.*;
+import samer.core.util.*;
+import samer.core.util.heavy.*;
+import samer.core.util.heavy.Borders.*;
+import samer.core.util.Tools;
+import java.awt.*;
+
public class tester
-{
- public static void main(String args[])
- {
- new samer.core.shells.AppShell();
-
- final Shell.Window win=Shell.getWindow("tester");
-
- win.container().setBackground(Color.white);
- // win.container().setForeground(Color.white);
-
- win.container().setLayout(new StackLayout(0));
- win.container().add(Shell.createLabel("hmmm..."));
- win.container().add(createBlock(new Color(200,160,180), "the world"));
- win.container().add(createBlock(new Color(200,180,160), "welcome to"));
- win.container().add(createBlock(new Color(180,200,160), "i like"));
- win.container().add(createBlock(new Color(160,200,180), "of borders"));
- win.container().add(createBlock(new Color(160,180,200), "these colours"));
- win.container().add(createBlock(new Color(180,160,200), "hello there!"));
- win.expose();
-
- Agent agent=new Agent() {
- public void getCommands(Agent.Registry r) { r.add("repaint"); }
- public void execute(String cmd, Environment env) {
- if (cmd.equals("repaint")) {
- win.container().repaint();
- }
- }
- };
- Shell.exposeCommands(agent);
- Shell.registerAgent(agent);
- }
-
- static Border.Interface border = new CompoundBorder(
- new ParentBgBorder(12),
- new RoundedBorder(3,26,3) {
- protected Color getDefaultColor(Component c) {
- return c.getBackground().darker(); // brighter();
- }
- }
- );
-
- static Component createBlock(Color bg, String msg)
- {
- JPanel p1=new JPanel(border);
- p1.setLayout(new FlowLayout());
- p1.setBackground(bg);
- p1.setForeground(bg.darker().darker().darker());
- p1.add(Shell.createLabel(msg));
- return p1;
- }
-}
\ No newline at end of file
+{
+ public static void main(String args[])
+ {
+ new samer.core.shells.AWTShell();
+
+ final Shell.Window win=Shell.getWindow("tester");
+
+ win.container().setBackground(Color.white);
+ // win.container().setForeground(Color.white);
+
+ win.container().setLayout(new StackLayout(0));
+ win.container().add(Shell.createLabel("hmmm..."));
+ win.container().add(createBlock(new Color(200,160,180), "the world"));
+ win.container().add(createBlock(new Color(200,180,160), "welcome to"));
+ win.container().add(createBlock(new Color(180,200,160), "i like"));
+ win.container().add(createBlock(new Color(160,200,180), "of borders"));
+ win.container().add(createBlock(new Color(160,180,200), "these colours"));
+ win.container().add(createBlock(new Color(180,160,200), "hello there!"));
+ win.expose();
+
+ Agent agent=new Agent() {
+ public void getCommands(Agent.Registry r) { r.add("repaint"); }
+ public void execute(String cmd, Environment env) {
+ if (cmd.equals("repaint")) {
+ win.container().repaint();
+ }
+ }
+ };
+ Shell.exposeCommands(agent);
+ Shell.registerAgent(agent);
+ }
+
+ static Border.Interface border = new CompoundBorder(
+ new ParentBgBorder(12),
+ new RoundedBorder(3,26,3) {
+ protected Color getDefaultColor(Component c) {
+ return c.getBackground().darker(); // brighter();
+ }
+ }
+ );
+
+ static Component createBlock(Color bg, String msg)
+ {
+ JPanel p1=new JPanel(border);
+ p1.setLayout(new FlowLayout());
+ p1.setBackground(bg);
+ p1.setForeground(bg.darker().darker().darker());
+ p1.add(Shell.createLabel(msg));
+ return p1;
+ }
+}
diff -r b67a33c44de7 -r f0fa855432af examples/gui/swing/BLDComponent.java
--- a/examples/gui/swing/BLDComponent.java Fri Apr 05 21:34:25 2019 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,101 +0,0 @@
-import java.awt.*;
-import java.awt.event.*;
-import javax.swing.*;
-
-/** A rectangle that has a fixed size. */
-class BLDComponent extends JComponent {
- private Color normalHue;
- private final Dimension preferredSize;
- private String name;
- private boolean restrictMaximumSize;
- private boolean printSize;
-
- public BLDComponent(float alignmentX, float hue,
- int shortSideSize,
- boolean restrictSize,
- boolean printSize,
- String name) {
- this.name = name;
- this.restrictMaximumSize = restrictSize;
- this.printSize = printSize;
- setAlignmentX(alignmentX);
- normalHue = Color.getHSBColor(hue, 0.4f, 0.85f);
- preferredSize = new Dimension(shortSideSize*2, shortSideSize);
-
- MouseListener l = new MouseAdapter() {
- public void mousePressed(MouseEvent e) {
- int width = getWidth();
- float alignment = (float)(e.getX())
- / (float)width;
-
- // Round to the nearest 1/10th.
- int tmp = Math.round(alignment * 10.0f);
- alignment = (float)tmp / 10.0f;
-
- setAlignmentX(alignment);
- revalidate(); // this GUI needs relayout
- repaint();
- }
- };
- addMouseListener(l);
- }
-
- /**
- * Our BLDComponents are completely opaque, so we override
- * this method to return true. This lets the painting
- * system know that it doesn't need to paint any covered
- * part of the components underneath this component. The
- * end result is possibly improved painting performance.
- */
- public boolean isOpaque() {
- return true;
- }
-
- public void paint(Graphics g) {
- int width = getWidth();
- int height = getHeight();
- float alignmentX = getAlignmentX();
-
- g.setColor(normalHue);
- g.fill3DRect(0, 0, width, height, true);
-
- /* Draw a vertical white line at the alignment point.*/
- // XXX: This code is probably not the best.
- g.setColor(Color.white);
- int x = (int)(alignmentX * (float)width) - 1;
- g.drawLine(x, 0, x, height - 1);
-
- /* Say what the alignment point is. */
- g.setColor(Color.black);
- g.drawString(Float.toString(alignmentX), 3, height - 3);
-
- if (printSize) {
- System.out.println("BLDComponent " + name + ": size is "
- + width + "x" + height
- + "; preferred size is "
- + getPreferredSize().width + "x"
- + getPreferredSize().height);
- }
- }
-
- public Dimension getPreferredSize() {
- return preferredSize;
- }
-
- public Dimension getMinimumSize() {
- return preferredSize;
- }
-
- public Dimension getMaximumSize() {
- if (restrictMaximumSize) {
- return preferredSize;
- } else {
- return super.getMaximumSize();
- }
- }
-
- public void setSizeRestriction(boolean restrictSize) {
- restrictMaximumSize = restrictSize;
- }
-
-}
diff -r b67a33c44de7 -r f0fa855432af examples/gui/swing/BoxLayoutDemo.java
--- a/examples/gui/swing/BoxLayoutDemo.java Fri Apr 05 21:34:25 2019 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,77 +0,0 @@
-import java.awt.*;
-import java.awt.event.*;
-import javax.swing.*;
-
-public class BoxLayoutDemo {
- protected static int NUM_COMPONENTS = 3;
- protected static float[] xAlignment = {Component.LEFT_ALIGNMENT,
- Component.CENTER_ALIGNMENT,
- Component.RIGHT_ALIGNMENT};
- protected static float[] hue = {0.0f, 0.33f, 0.67f};
- protected static boolean restrictSize = true;
- protected static boolean sizeIsRandom = false;
- protected static BLDComponent[] bldComponent =
- new BLDComponent[NUM_COMPONENTS];
-
- public static void main(String[] args) {
- final JPanel panel = new JPanel();
- panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
-
- //Create the rectangles.
- int shortSideSize = 15;
- for (int i = 0; i < NUM_COMPONENTS; i++) {
- if (sizeIsRandom) {
- shortSideSize = (int)(30.0 * Math.random()) + 30;
- } else {
- shortSideSize += 10;
- }
- bldComponent[i] = new BLDComponent(xAlignment[i], hue[i],
- shortSideSize,
- restrictSize,
- sizeIsRandom,
- String.valueOf(i));
- panel.add(bldComponent[i]);
- }
-
- //Create the instructions.
- JLabel label = new JLabel("Click a rectangle to "
- + "change its X alignment.");
- JCheckBox cb = new JCheckBox("Restrict maximum rectangle size.");
- cb.setSelected(restrictSize);
- cb.addItemListener(new ItemListener() {
- public void itemStateChanged(ItemEvent e) {
- if (e.getStateChange() == ItemEvent.SELECTED) {
- restrictSize = true;
- } else {
- restrictSize = false;
- }
- notifyBLDComponents();
- }
- });
-
- JFrame f = new JFrame("BoxLayoutDemo");
- Container contentPane = f.getContentPane();
- contentPane.add(panel, BorderLayout.CENTER);
- panel.setBorder(BorderFactory.createLineBorder(Color.red));
-
- Box box = Box.createVerticalBox();
- box.add(label);
- box.add(cb);
-
- contentPane.add(box, BorderLayout.SOUTH);
- f.addWindowListener(new WindowAdapter() {
- public void windowClosing(WindowEvent e) {
- System.exit(0);
- }
- });
- f.pack();
- f.setVisible(true);
- }
-
- static public void notifyBLDComponents() {
- for (int i = 0; i < NUM_COMPONENTS; i++) {
- bldComponent[i].setSizeRestriction(restrictSize);
- }
- bldComponent[0].revalidate();
- }
-}
diff -r b67a33c44de7 -r f0fa855432af examples/gui/swing/ConversionPanel.java
--- a/examples/gui/swing/ConversionPanel.java Fri Apr 05 21:34:25 2019 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,117 +0,0 @@
-/*
- * 1.1+Swing version.
- */
-
-import javax.swing.*;
-import javax.swing.event.*;
-import java.awt.*;
-import java.awt.event.*;
-import java.util.*;
-import java.text.NumberFormat;
-
-public class ConversionPanel extends JPanel {
- DecimalField textField;
- JComboBox unitChooser;
- JSlider slider;
- ConverterRangeModel sliderModel;
- Converter controller;
- Unit[] units;
- String title;
- final static boolean DEBUG = false;
- final static boolean COLORS = false;
- final static int MAX = 10000;
-
- ConversionPanel(Converter myController, String myTitle,
- Unit[] myUnits,
- ConverterRangeModel myModel) {
- if (COLORS) {
- setBackground(Color.cyan);
- }
- setBorder(BorderFactory.createCompoundBorder(
- BorderFactory.createTitledBorder(myTitle),
- BorderFactory.createEmptyBorder(5,5,5,5)));
-
- //Save arguments in instance variables.
- controller = myController;
- units = myUnits;
- title = myTitle;
- sliderModel = myModel;
-
- //Add the text field. It initially displays "0" and needs
- //to be at least 10 columns wide.
- NumberFormat numberFormat = NumberFormat.getNumberInstance();
- numberFormat.setMaximumFractionDigits(2);
- textField = new DecimalField(0, 10, numberFormat);
- textField.setValue(sliderModel.getDoubleValue());
- textField.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- sliderModel.setDoubleValue(textField.getValue());
- }
- });
-
- //Add the combo box.
- unitChooser = new JComboBox();
- for (int i = 0; i < units.length; i++) { //Populate it.
- unitChooser.addItem(units[i].description);
- }
- unitChooser.setSelectedIndex(0);
- sliderModel.setMultiplier(units[0].multiplier);
- unitChooser.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- //Set new maximums for the sliders.
- int i = unitChooser.getSelectedIndex();
- sliderModel.setMultiplier(units[i].multiplier);
- controller.resetMaxValues(false);
- }
- });
-
- //Add the slider.
- slider = new JSlider(sliderModel);
- sliderModel.addChangeListener(new ChangeListener() {
- public void stateChanged(ChangeEvent e) {
- textField.setValue(sliderModel.getDoubleValue());
- }
- });
-
- //Make the textfield/slider group a fixed size.
- JPanel unitGroup = new JPanel() {
- public Dimension getMinimumSize() {
- return getPreferredSize();
- }
- public Dimension getPreferredSize() {
- return new Dimension(150,
- super.getPreferredSize().height);
- }
- public Dimension getMaximumSize() {
- return getPreferredSize();
- }
- };
- if (COLORS) {
- unitGroup.setBackground(Color.blue);
- }
- unitGroup.setBorder(BorderFactory.createEmptyBorder(
- 0,0,0,5));
- unitGroup.setLayout(new BoxLayout(unitGroup,
- BoxLayout.Y_AXIS));
- unitGroup.add(textField);
- unitGroup.add(slider);
-
- setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
- add(unitGroup);
- add(unitChooser);
- unitGroup.setAlignmentY(TOP_ALIGNMENT);
- unitChooser.setAlignmentY(TOP_ALIGNMENT);
- }
-
- /**
- * Returns the multiplier (units/meter) for the currently
- * selected unit of measurement.
- */
- public double getMultiplier() {
- return sliderModel.getMultiplier();
- }
-
- public double getValue() {
- return sliderModel.getDoubleValue();
- }
-}
diff -r b67a33c44de7 -r f0fa855432af examples/gui/swing/Converter.java
--- a/examples/gui/swing/Converter.java Fri Apr 05 21:34:25 2019 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,157 +0,0 @@
-/*
- * 1.1+Swing version.
- */
-
-import javax.swing.*;
-import javax.swing.event.*;
-import java.awt.*;
-import java.awt.event.*;
-import java.util.*;
-
-public class Converter {
- ConversionPanel metricPanel, usaPanel;
- Unit[] metricDistances = new Unit[3];
- Unit[] usaDistances = new Unit[4];
- final static boolean COLORS = false;
- final static boolean DEBUG = false;
- final static String LOOKANDFEEL = null;
- ConverterRangeModel dataModel = new ConverterRangeModel();
- JPanel mainPane;
-
- /**
- * Create the ConversionPanels (one for metric, another for U.S.).
- * I used "U.S." because although Imperial and U.S. distance
- * measurements are the same, this program could be extended to
- * include volume measurements, which aren't the same.
- *
- * Put the ConversionPanels into a frame, and bring up the frame.
- */
- public Converter() {
- //Create Unit objects for metric distances, and then
- //instantiate a ConversionPanel with these Units.
- metricDistances[0] = new Unit("Centimeters", 0.01);
- metricDistances[1] = new Unit("Meters", 1.0);
- metricDistances[2] = new Unit("Kilometers", 1000.0);
- metricPanel = new ConversionPanel(this, "Metric System",
- metricDistances,
- dataModel);
-
- //Create Unit objects for U.S. distances, and then
- //instantiate a ConversionPanel with these Units.
- usaDistances[0] = new Unit("Inches", 0.0254);
- usaDistances[1] = new Unit("Feet", 0.305);
- usaDistances[2] = new Unit("Yards", 0.914);
- usaDistances[3] = new Unit("Miles", 1613.0);
- usaPanel = new ConversionPanel(this, "U.S. System",
- usaDistances,
- new FollowerRangeModel(dataModel));
-
- //Create a JPanel, and add the ConversionPanels to it.
- mainPane = new JPanel();
- if (COLORS) {
- mainPane.setBackground(Color.red);
- }
- mainPane.setLayout(new GridLayout(2,1,5,5));
- mainPane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
- mainPane.add(metricPanel);
- mainPane.add(usaPanel);
- resetMaxValues(true);
- }
-
- public void resetMaxValues(boolean resetCurrentValues) {
- double metricMultiplier = metricPanel.getMultiplier();
- double usaMultiplier = usaPanel.getMultiplier();
- int maximum = ConversionPanel.MAX;
-
- if (metricMultiplier > usaMultiplier) {
- maximum = (int)(ConversionPanel.MAX *
- (usaMultiplier/metricMultiplier));
- }
-
- if (DEBUG) {
- System.out.println("in Converter resetMaxValues");
- System.out.println(" metricMultiplier = "
- + metricMultiplier
- + "; usaMultiplier = "
- + usaMultiplier
- + "; maximum = "
- + maximum);
- }
-
- dataModel.setMaximum(maximum);
-
- if (resetCurrentValues) {
- dataModel.setDoubleValue(maximum);
- }
- }
-
- private static void initLookAndFeel() {
- String lookAndFeel = null;
-
- if (LOOKANDFEEL != null) {
- if (LOOKANDFEEL.equals("Metal")) {
- lookAndFeel = UIManager.getCrossPlatformLookAndFeelClassName();
- } else if (LOOKANDFEEL.equals("System")) {
- lookAndFeel = UIManager.getSystemLookAndFeelClassName();
- } else if (LOOKANDFEEL.equals("Mac")) {
- lookAndFeel = "com.sun.java.swing.plaf.mac.MacLookAndFeel";
- //PENDING: check!
- } else if (LOOKANDFEEL.equals("Windows")) {
- lookAndFeel = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
- } else if (LOOKANDFEEL.equals("Motif")) {
- lookAndFeel = "com.sun.java.swing.plaf.motif.MotifLookAndFeel";
- }
-
- if (DEBUG) {
- System.out.println("About to request look and feel: "
- + lookAndFeel);
- }
-
- try {
- UIManager.setLookAndFeel(lookAndFeel);
- } catch (ClassNotFoundException e) {
- System.err.println("Couldn't find class for specified look and feel:"
- + lookAndFeel);
- System.err.println("Did you include the L&F library in the class path?");
- System.err.println("Using the default look and feel.");
- } catch (UnsupportedLookAndFeelException e) {
- System.err.println("Can't use the specified look and feel ("
- + lookAndFeel
- + ") on this platform.");
- System.err.println("Using the default look and feel.");
- } catch (Exception e) {
- System.err.println("Couldn't get specified look and feel ("
- + lookAndFeel
- + "), for some reason.");
- System.err.println("Using the default look and feel.");
- e.printStackTrace();
- }
- }
- }
-
- public static void main(String[] args) {
- initLookAndFeel();
- Converter converter = new Converter();
-
- //Create a new window.
- JFrame f = new JFrame("Converter");
- f.addWindowListener(new WindowAdapter() {
- public void windowClosing(WindowEvent e) {
- System.exit(0);
- }
- });
-
- //Add the JPanel to the window and display the window.
- //We can use a JPanel for the content pane because
- //JPanel is opaque.
- f.setContentPane(converter.mainPane);
- if (COLORS) {
- //This has no effect, since the JPanel completely
- //covers the content pane.
- f.getContentPane().setBackground(Color.green);
- }
-
- f.pack(); //Resizes the window to its natural size.
- f.setVisible(true);
- }
-}
diff -r b67a33c44de7 -r f0fa855432af examples/gui/swing/MenuDemo.java
--- a/examples/gui/swing/MenuDemo.java Fri Apr 05 21:34:25 2019 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,164 +0,0 @@
-import java.awt.*;
-import java.awt.event.*;
-import javax.swing.JMenu;
-import javax.swing.JMenuItem;
-import javax.swing.JCheckBoxMenuItem;
-import javax.swing.JRadioButtonMenuItem;
-import javax.swing.ButtonGroup;
-import javax.swing.JMenuBar;
-import javax.swing.KeyStroke;
-import javax.swing.ImageIcon;
-
-import javax.swing.JTextArea;
-import javax.swing.JScrollPane;
-import javax.swing.JFrame;
-
-/*
- * This class adds event handling to MenuLookDemo.
- */
-public class MenuDemo extends JFrame
- implements ActionListener, ItemListener {
- JTextArea output;
- JScrollPane scrollPane;
- String newline = "\n";
-
- public MenuDemo() {
- JMenuBar menuBar;
- JMenu menu, submenu;
- JMenuItem menuItem;
- JRadioButtonMenuItem rbMenuItem;
- JCheckBoxMenuItem cbMenuItem;
-
- addWindowListener(new WindowAdapter() {
- public void windowClosing(WindowEvent e) {
- System.exit(0);
- }
- });
-
- //Add regular components to the window, using the default BorderLayout.
- Container contentPane = getContentPane();
- output = new JTextArea(5, 30);
- output.setEditable(false);
- scrollPane = new JScrollPane(output);
- contentPane.add(scrollPane, BorderLayout.CENTER);
-
- //Create the menu bar.
- menuBar = new JMenuBar();
- setJMenuBar(menuBar);
-
- //Build the first menu.
- menu = new JMenu("A Menu");
- menu.setMnemonic(KeyEvent.VK_A);
- menu.getAccessibleContext().setAccessibleDescription(
- "The only menu in this program that has menu items");
- menuBar.add(menu);
-
- //a group of JMenuItems
- menuItem = new JMenuItem("A text-only menu item",
- KeyEvent.VK_T);
- //menuItem.setMnemonic(KeyEvent.VK_T); //used constructor instead
- menuItem.setAccelerator(KeyStroke.getKeyStroke(
- KeyEvent.VK_1, ActionEvent.ALT_MASK));
- menuItem.getAccessibleContext().setAccessibleDescription(
- "This doesn't really do anything");
- menuItem.addActionListener(this);
- menu.add(menuItem);
-
- menuItem = new JMenuItem("Both text and icon",
- new ImageIcon("images/middle.gif"));
- menuItem.setMnemonic(KeyEvent.VK_B);
- menuItem.addActionListener(this);
- menu.add(menuItem);
-
- menuItem = new JMenuItem(new ImageIcon("images/middle.gif"));
- menuItem.setMnemonic(KeyEvent.VK_D);
- menuItem.addActionListener(this);
- menu.add(menuItem);
-
- //a group of radio button menu items
- menu.addSeparator();
- ButtonGroup group = new ButtonGroup();
- rbMenuItem = new JRadioButtonMenuItem("A radio button menu item");
- rbMenuItem.setSelected(true);
- rbMenuItem.setMnemonic(KeyEvent.VK_R);
- group.add(rbMenuItem);
- rbMenuItem.addActionListener(this);
- menu.add(rbMenuItem);
- rbMenuItem = new JRadioButtonMenuItem("Another one");
- rbMenuItem.setMnemonic(KeyEvent.VK_O);
- group.add(rbMenuItem);
- rbMenuItem.addActionListener(this);
- menu.add(rbMenuItem);
-
- //a group of check box menu items
- menu.addSeparator();
- cbMenuItem = new JCheckBoxMenuItem("A check box menu item");
- cbMenuItem.setMnemonic(KeyEvent.VK_C);
- cbMenuItem.addItemListener(this);
- menu.add(cbMenuItem);
- cbMenuItem = new JCheckBoxMenuItem("Another one");
- cbMenuItem.setMnemonic(KeyEvent.VK_H);
- cbMenuItem.addItemListener(this);
- menu.add(cbMenuItem);
-
- //a submenu
- menu.addSeparator();
- submenu = new JMenu("A submenu");
- submenu.setMnemonic(KeyEvent.VK_S);
-
- menuItem = new JMenuItem("An item in the submenu");
- menuItem.setAccelerator(KeyStroke.getKeyStroke(
- KeyEvent.VK_2, ActionEvent.ALT_MASK));
- menuItem.addActionListener(this);
- submenu.add(menuItem);
-
- menuItem = new JMenuItem("Another item");
- menuItem.addActionListener(this);
- submenu.add(menuItem);
- menu.add(submenu);
-
- //Build second menu in the menu bar.
- menu = new JMenu("Another Menu");
- menu.setMnemonic(KeyEvent.VK_N);
- menu.getAccessibleContext().setAccessibleDescription(
- "This menu does nothing");
- menuBar.add(menu);
- }
-
- public void actionPerformed(ActionEvent e) {
- JMenuItem source = (JMenuItem)(e.getSource());
- String s = "Action event detected."
- + newline
- + " Event source: " + source.getText()
- + " (an instance of " + getClassName(source) + ")";
- output.append(s + newline);
- }
-
- public void itemStateChanged(ItemEvent e) {
- JMenuItem source = (JMenuItem)(e.getSource());
- String s = "Item event detected."
- + newline
- + " Event source: " + source.getText()
- + " (an instance of " + getClassName(source) + ")"
- + newline
- + " New state: "
- + ((e.getStateChange() == ItemEvent.SELECTED) ?
- "selected":"unselected");
- output.append(s + newline);
- }
-
- // Returns just the class name -- no package info.
- protected String getClassName(Object o) {
- String classString = o.getClass().getName();
- int dotIndex = classString.lastIndexOf(".");
- return classString.substring(dotIndex+1);
- }
-
- public static void main(String[] args) {
- MenuDemo window = new MenuDemo();
-
- window.setTitle("MenuDemo");
- window.setSize(450, 260);
- window.setVisible(true);
- }
-}
diff -r b67a33c44de7 -r f0fa855432af examples/gui/swing/MenuLookDemo.java
--- a/examples/gui/swing/MenuLookDemo.java Fri Apr 05 21:34:25 2019 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,128 +0,0 @@
-import java.awt.*;
-import java.awt.event.*;
-import javax.swing.JMenu;
-import javax.swing.JMenuItem;
-import javax.swing.JCheckBoxMenuItem;
-import javax.swing.JRadioButtonMenuItem;
-import javax.swing.ButtonGroup;
-import javax.swing.JMenuBar;
-import javax.swing.KeyStroke;
-import javax.swing.ImageIcon;
-
-import javax.swing.JTextArea;
-import javax.swing.JScrollPane;
-import javax.swing.JFrame;
-
-/*
- * This class exists solely to show you what menus look like.
- * It has no menu-related event handling.
- */
-public class MenuLookDemo extends JFrame {
- JTextArea output;
- JScrollPane scrollPane;
-
- public MenuLookDemo() {
- JMenuBar menuBar;
- JMenu menu, submenu;
- JMenuItem menuItem;
- JCheckBoxMenuItem cbMenuItem;
- JRadioButtonMenuItem rbMenuItem;
-
- addWindowListener(new WindowAdapter() {
- public void windowClosing(WindowEvent e) {
- System.exit(0);
- }
- });
-
- //Add regular components to the window, using the default BorderLayout.
- Container contentPane = getContentPane();
- output = new JTextArea(5, 30);
- output.setEditable(false);
- scrollPane = new JScrollPane(output);
- contentPane.add(scrollPane, BorderLayout.CENTER);
-
- //Create the menu bar.
- menuBar = new JMenuBar();
- setJMenuBar(menuBar);
-
- //Build the first menu.
- menu = new JMenu("A Menu");
- menu.setMnemonic(KeyEvent.VK_A);
- menu.getAccessibleContext().setAccessibleDescription(
- "The only menu in this program that has menu items");
- menuBar.add(menu);
-
- //a group of JMenuItems
- menuItem = new JMenuItem("A text-only menu item",
- KeyEvent.VK_T);
- //menuItem.setMnemonic(KeyEvent.VK_T); //used constructor instead
- menuItem.setAccelerator(KeyStroke.getKeyStroke(
- KeyEvent.VK_1, ActionEvent.ALT_MASK));
- menuItem.getAccessibleContext().setAccessibleDescription(
- "This doesn't really do anything");
- menu.add(menuItem);
-
- menuItem = new JMenuItem("Both text and icon",
- new ImageIcon("images/middle.gif"));
- menuItem.setMnemonic(KeyEvent.VK_B);
- menu.add(menuItem);
-
- menuItem = new JMenuItem(new ImageIcon("images/middle.gif"));
- menuItem.setMnemonic(KeyEvent.VK_D);
- menu.add(menuItem);
-
- //a group of radio button menu items
- menu.addSeparator();
- ButtonGroup group = new ButtonGroup();
-
- rbMenuItem = new JRadioButtonMenuItem("A radio button menu item");
- rbMenuItem.setSelected(true);
- rbMenuItem.setMnemonic(KeyEvent.VK_R);
- group.add(rbMenuItem);
- menu.add(rbMenuItem);
-
- rbMenuItem = new JRadioButtonMenuItem("Another one");
- rbMenuItem.setMnemonic(KeyEvent.VK_O);
- group.add(rbMenuItem);
- menu.add(rbMenuItem);
-
- //a group of check box menu items
- menu.addSeparator();
- cbMenuItem = new JCheckBoxMenuItem("A check box menu item");
- cbMenuItem.setMnemonic(KeyEvent.VK_C);
- menu.add(cbMenuItem);
-
- cbMenuItem = new JCheckBoxMenuItem("Another one");
- cbMenuItem.setMnemonic(KeyEvent.VK_H);
- menu.add(cbMenuItem);
-
- //a submenu
- menu.addSeparator();
- submenu = new JMenu("A submenu");
- submenu.setMnemonic(KeyEvent.VK_S);
-
- menuItem = new JMenuItem("An item in the submenu");
- menuItem.setAccelerator(KeyStroke.getKeyStroke(
- KeyEvent.VK_2, ActionEvent.ALT_MASK));
- submenu.add(menuItem);
-
- menuItem = new JMenuItem("Another item");
- submenu.add(menuItem);
- menu.add(submenu);
-
- //Build second menu in the menu bar.
- menu = new JMenu("Another Menu");
- menu.setMnemonic(KeyEvent.VK_N);
- menu.getAccessibleContext().setAccessibleDescription(
- "This menu does nothing");
- menuBar.add(menu);
- }
-
- public static void main(String[] args) {
- MenuLookDemo window = new MenuLookDemo();
-
- window.setTitle("MenuLookDemo");
- window.setSize(450, 260);
- window.setVisible(true);
- }
-}
diff -r b67a33c44de7 -r f0fa855432af examples/gui/swing/PopupMenuDemo.java
--- a/examples/gui/swing/PopupMenuDemo.java Fri Apr 05 21:34:25 2019 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,196 +0,0 @@
-import java.awt.*;
-import java.awt.event.*;
-import javax.swing.JPopupMenu;
-import javax.swing.JMenu;
-import javax.swing.JMenuItem;
-import javax.swing.JCheckBoxMenuItem;
-import javax.swing.JRadioButtonMenuItem;
-import javax.swing.ButtonGroup;
-import javax.swing.JMenuBar;
-import javax.swing.KeyStroke;
-import javax.swing.ImageIcon;
-
-import javax.swing.JTextArea;
-import javax.swing.JScrollPane;
-import javax.swing.JFrame;
-
-/*
- * This class adds popup menus to MenuDemo.
- */
-public class PopupMenuDemo extends JFrame
- implements ActionListener, ItemListener {
- JTextArea output;
- JScrollPane scrollPane;
- String newline = "\n";
- JPopupMenu popup;
-
- public PopupMenuDemo() {
- JMenuBar menuBar;
- JMenu menu, submenu;
- JMenuItem menuItem;
- JRadioButtonMenuItem rbMenuItem;
- JCheckBoxMenuItem cbMenuItem;
-
- addWindowListener(new WindowAdapter() {
- public void windowClosing(WindowEvent e) {
- System.exit(0);
- }
- });
-
- //Add regular components to the window, using the default BorderLayout.
- Container contentPane = getContentPane();
- output = new JTextArea(5, 30);
- output.setEditable(false);
- scrollPane = new JScrollPane(output);
- contentPane.add(scrollPane, BorderLayout.CENTER);
-
- //Create the menu bar.
- menuBar = new JMenuBar();
- setJMenuBar(menuBar);
-
- //Build the first menu.
- menu = new JMenu("A Menu");
- menu.setMnemonic(KeyEvent.VK_A);
- menu.getAccessibleContext().setAccessibleDescription(
- "The only menu in this program that has menu items");
- menuBar.add(menu);
-
- //a group of JMenuItems
- menuItem = new JMenuItem("A text-only menu item",
- KeyEvent.VK_T);
- //menuItem.setMnemonic(KeyEvent.VK_T); //used constructor instead
- menuItem.setAccelerator(KeyStroke.getKeyStroke(
- KeyEvent.VK_1, ActionEvent.ALT_MASK));
- menuItem.getAccessibleContext().setAccessibleDescription(
- "This doesn't really do anything");
- menuItem.addActionListener(this);
- menu.add(menuItem);
- menuItem = new JMenuItem("Both text and icon",
- new ImageIcon("images/middle.gif"));
- menuItem.setMnemonic(KeyEvent.VK_B);
- menuItem.addActionListener(this);
- menu.add(menuItem);
- menuItem = new JMenuItem(new ImageIcon("images/middle.gif"));
- menuItem.setMnemonic(KeyEvent.VK_D);
- menuItem.addActionListener(this);
- menu.add(menuItem);
-
- //a group of radio button menu items
- menu.addSeparator();
- ButtonGroup group = new ButtonGroup();
- rbMenuItem = new JRadioButtonMenuItem("A radio button menu item");
- rbMenuItem.setSelected(true);
- rbMenuItem.setMnemonic(KeyEvent.VK_R);
- group.add(rbMenuItem);
- rbMenuItem.addActionListener(this);
- menu.add(rbMenuItem);
- rbMenuItem = new JRadioButtonMenuItem("Another one");
- rbMenuItem.setMnemonic(KeyEvent.VK_O);
- group.add(rbMenuItem);
- rbMenuItem.addActionListener(this);
- menu.add(rbMenuItem);
-
- //a group of check box menu items
- menu.addSeparator();
- cbMenuItem = new JCheckBoxMenuItem("A check box menu item");
- cbMenuItem.setMnemonic(KeyEvent.VK_C);
- cbMenuItem.addItemListener(this);
- menu.add(cbMenuItem);
- cbMenuItem = new JCheckBoxMenuItem("Another one");
- cbMenuItem.setMnemonic(KeyEvent.VK_H);
- cbMenuItem.addItemListener(this);
- menu.add(cbMenuItem);
-
- //a submenu
- menu.addSeparator();
- submenu = new JMenu("A submenu");
- submenu.setMnemonic(KeyEvent.VK_S);
-
- menuItem = new JMenuItem("An item in the submenu");
- menuItem.setAccelerator(KeyStroke.getKeyStroke(
- KeyEvent.VK_2, ActionEvent.ALT_MASK));
- menuItem.addActionListener(this);
- submenu.add(menuItem);
-
- menuItem = new JMenuItem("Another item");
- menuItem.addActionListener(this);
- submenu.add(menuItem);
- menu.add(submenu);
-
- //Build second menu in the menu bar.
- menu = new JMenu("Another Menu");
- menu.setMnemonic(KeyEvent.VK_N);
- menu.getAccessibleContext().setAccessibleDescription(
- "This menu does nothing");
- menuBar.add(menu);
-
- //Create the popup menu.
- popup = new JPopupMenu();
- menuItem = new JMenuItem("A popup menu item");
- menuItem.addActionListener(this);
- popup.add(menuItem);
- menuItem = new JMenuItem("Another popup menu item");
- menuItem.addActionListener(this);
- popup.add(menuItem);
-
- //Add listener to components that can bring up popup menus.
- MouseListener popupListener = new PopupListener();
- output.addMouseListener(popupListener);
- scrollPane.addMouseListener(popupListener);
- menuBar.addMouseListener(popupListener);
- }
-
- public void actionPerformed(ActionEvent e) {
- JMenuItem source = (JMenuItem)(e.getSource());
- String s = "Action event detected."
- + newline
- + " Event source: " + source.getText()
- + " (an instance of " + getClassName(source) + ")";
- output.append(s + newline);
- }
-
- public void itemStateChanged(ItemEvent e) {
- JMenuItem source = (JMenuItem)(e.getSource());
- String s = "Item event detected."
- + newline
- + " Event source: " + source.getText()
- + " (an instance of " + getClassName(source) + ")"
- + newline
- + " New state: "
- + ((e.getStateChange() == ItemEvent.SELECTED) ?
- "selected":"unselected");
- output.append(s + newline);
- }
-
- // Returns just the class name -- no package info.
- protected String getClassName(Object o) {
- String classString = o.getClass().getName();
- int dotIndex = classString.lastIndexOf(".");
- return classString.substring(dotIndex+1);
- }
-
- public static void main(String[] args) {
- PopupMenuDemo window = new PopupMenuDemo();
-
- window.setTitle("PopupMenuDemo");
- window.setSize(450, 260);
- window.setVisible(true);
- }
-
- class PopupListener extends MouseAdapter {
- public void mousePressed(MouseEvent e) {
- maybeShowPopup(e);
- }
-
- public void mouseReleased(MouseEvent e) {
- maybeShowPopup(e);
- }
-
- private void maybeShowPopup(MouseEvent e) {
- if (e.isPopupTrigger()) {
- popup.show(e.getComponent(),
- e.getX(), e.getY());
- }
- }
- }
-}
diff -r b67a33c44de7 -r f0fa855432af examples/misc/args
--- a/examples/misc/args Fri Apr 05 21:34:25 2019 +0100
+++ b/examples/misc/args Fri Apr 05 21:49:42 2019 +0100
@@ -1,5 +1,5 @@
#properties
-#Fri Apr 05 21:28:03 BST 2019
+#Fri Apr 05 21:35:02 BST 2019
mouse.y.trace.map.minimum=-0.0
ft.power.plotter.window.bounds=(323,142,512,118)
mouse.x.trace.map.symmetric=false