Ejemplo n.º 1
0
  void jbInit() throws Exception {
    panel1.setLayout(borderLayout1);
    panel2.setBackground(Color.yellow);
    panel2.setLayout(borderLayout2);
    ButtonOK.setLabel("OK");
    ButtonOK.addMouseListener(
        new java.awt.event.MouseAdapter() {

          public void mouseClicked(MouseEvent e) {
            ButtonOK_mouseClicked(e);
          }
        });

    String s1 = CallingApp.MotherApplet.GetName();

    textArea1.setBackground(SystemColor.control);
    textArea1.setEditable(false);

    panel1.add(panel2, BorderLayout.CENTER);
    panel2.add(textArea1, BorderLayout.CENTER);
    panel1.add(panel3, BorderLayout.SOUTH);
    panel3.add(ButtonOK, null);
    String s =
        s1
            + " v:"
            + CallingApp.MotherApplet.GetVersionNum()
            + "\n"
            + CallingApp.MotherApplet.GetInfos();
    textArea1.setText(s);
  }
Ejemplo n.º 2
0
  /**
   * IRC Constructor
   *
   * @param jo the JVN object representing the Chat
   */
  public Irc(JvnObject jo) {
    sentence = jo;
    frame = new JFrame();
    frame.setLayout(new GridLayout(1, 1));
    text = new TextArea(10, 60);
    text.setEditable(false);
    text.setForeground(Color.red);
    frame.add(text);
    data = new TextField(40);
    frame.add(data);
    Button read_button = new Button("read");
    read_button.addActionListener(new readListener(this));
    frame.add(read_button);
    Button write_button = new Button("write");
    write_button.addActionListener(new writeListener(this));
    frame.add(write_button);
    frame.setSize(545, 201);
    // frame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    frame.addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(WindowEvent e) {
            System.out.println("Closed");
            try {
              JvnServerImpl.jvnGetServer().jvnTerminate();
            } catch (Exception exc) {
              System.out.println("An exception: " + exc);
            }

            e.getWindow().dispose();
          }
        });
    text.setBackground(Color.black);
    frame.setVisible(true);
  }
Ejemplo n.º 3
0
  public Irc(Sentence_itf s) {

    setLayout(new FlowLayout());

    text = new TextArea(10, 60);
    text.setEditable(false);
    text.setForeground(Color.red);
    add(text);

    data = new TextField(60);
    add(data);

    Button write_button = new Button("write");
    write_button.addActionListener(new writeListener(this));
    add(write_button);
    Button read_button = new Button("read");
    read_button.addActionListener(new readListener(this));
    add(read_button);

    setSize(470, 300);
    text.setBackground(Color.black);
    show();

    sentence = s;
  }
Ejemplo n.º 4
0
  public void frameInit() {
    ta.setBackground(Color.white);
    p = new Panel();
    p2 = new Panel();
    p3 = new Panel();

    b = new Button("close");
    status = new Label("Status:", Label.LEFT);

    p2.setLayout(new GridLayout(2, 1, 5, 5));
    p2.add(status);

    p.setLayout(new FlowLayout());
    p.add(b);

    p3.setLayout(new GridLayout(2, 1, 0, 0));
    p3.add(p2);
    p3.add(p);

    setLayout(new BorderLayout());
    add("Center", ta);

    add("South", p3);

    b.addActionListener(this);
  }
Ejemplo n.º 5
0
  public void init() {
    Output.web = true;

    String opts = getParameter("opts");
    if (opts != null) {
      almc lmc = new almc("-tdir=" + getCodeBase() + " " + opts);
      return;
    }

    setBackground(Color.black);
    setForeground(Color.lightGray);
    setLayout(new GridLayout(3, 1));

    panel1 = new Panel1(this);
    add(panel1);
    panel2 = new Panel2(this);
    add(panel2);
    err = new TextArea();
    err.setEditable(false);
    err.setBackground(Color.black);
    err.setForeground(Color.lightGray);
    add(err);
    stdReset();

    out.append(Output.version + "\n\n");
    err.append(Output.version + "\n");
    par.append(Output.version + "\n");
    Output.err.println("Running from " + getCodeBase());
  }
Ejemplo n.º 6
0
 /**
  * Adds one or two (side by side) text areas.
  *
  * @param text1 initial contents of the first text area
  * @param text2 initial contents of the second text area or null
  * @param rows the number of rows
  * @param columns the number of columns
  */
 public void addTextAreas(String text1, String text2, int rows, int columns) {
   if (textArea1 != null) return;
   Panel panel = new Panel();
   textArea1 = new TextArea(text1, rows, columns, TextArea.SCROLLBARS_NONE);
   if (IJ.isLinux()) textArea1.setBackground(Color.white);
   textArea1.addTextListener(this);
   panel.add(textArea1);
   if (text2 != null) {
     textArea2 = new TextArea(text2, rows, columns, TextArea.SCROLLBARS_NONE);
     if (IJ.isLinux()) textArea2.setBackground(Color.white);
     panel.add(textArea2);
   }
   c.gridx = 0;
   c.gridy = y;
   c.gridwidth = 2;
   c.anchor = GridBagConstraints.WEST;
   c.insets = getInsets(15, 20, 0, 0);
   grid.setConstraints(panel, c);
   add(panel);
   y++;
 }
Ejemplo n.º 7
0
  void setupGUI() {
    taDictionary = new TextArea();
    taDictionary.setLocation(0, 0);
    taDictionary.setSize(106, 567);
    taDictionary.setBackground(new Color(-1));
    taDictionary.setText("");
    taDictionary.setRows(5);
    taDictionary.setColumns(1);
    getContentPane().add(taDictionary);

    tfSourc = new TextField();
    tfSourc.setLocation(224, 90);
    tfSourc.setSize(266, 25);
    tfSourc.setBackground(new Color(-1));
    tfSourc.setText("");
    tfSourc.setColumns(10);
    getContentPane().add(tfSourc);

    lblSourc = new Label();
    lblSourc.setLocation(106, 90);
    lblSourc.setSize(119, 25);
    lblSourc.setText("Source Word:");
    getContentPane().add(lblSourc);
    /*
    lblDestinatio = new Label();
    lblDestinatio.setLocation(106,97);
    lblDestinatio.setSize(119,25);
    lblDestinatio.setText("Destination Wor");
    getContentPane().add(lblDestinatio);
       */

    lblDestinatio = new Label();
    lblDestinatio.setLocation(106, 120);
    lblDestinatio.setSize(119, 25);
    lblDestinatio.setText("Destination Word:");
    getContentPane().add(lblDestinatio);

    lblWordSize = new Label();
    lblWordSize.setLocation(106, 27); // 106,120
    lblWordSize.setSize(119, 25);
    lblWordSize.setText("Word Size:");
    getContentPane().add(lblWordSize);

    tfWordSize = new TextField();
    tfWordSize.setLocation(224, 27); // 224,120
    tfWordSize.setSize(263, 25);
    tfWordSize.setBackground(new Color(-1));
    tfWordSize.setText("5");
    tfWordSize.setColumns(10);
    getContentPane().add(tfWordSize);

    tfSourc_6 = new TextField();
    tfSourc_6.setLocation(226, 120);
    tfSourc_6.setSize(263, 25);
    tfSourc_6.setBackground(new Color(-1));
    tfSourc_6.setText("");
    tfSourc_6.setColumns(10);
    getContentPane().add(tfSourc_6);

    lblFileNam = new Label();
    lblFileNam.setLocation(104, 0);
    lblFileNam.setSize(119, 25);
    lblFileNam.setText("FilePath:");
    getContentPane().add(lblFileNam);

    tfFilePat = new TextField();
    tfFilePat.setLocation(224, 0);
    tfFilePat.setSize(266, 25);
    tfFilePat.setBackground(new Color(-1));

    // OS Detection
    if (System.getProperty("os.name").startsWith("Windows")) {
      // includes: Windows 2000,  Windows 95, Windows 98, Windows NT, Windows Vista, Windows XP
      tfFilePat.setText("c:\\ics340\\words.txt");
      System.out.println("Detected Windows: " + System.getProperty("os.name"));
    } else {
      tfFilePat.setText("/Users/jasonedstrom/ics340/d1.txt");
      System.out.println("Detected Mac OS X: " + System.getProperty("os.name"));
    }

    tfFilePat.setColumns(10);
    getContentPane().add(tfFilePat);

    btLoadTextFiel = new JButton();
    btLoadTextFiel.setLocation(108, 50); // 108,27
    btLoadTextFiel.setSize(198, 32);
    btLoadTextFiel.setText("Load Words from Text Field");
    getContentPane().add(btLoadTextFiel);

    btLoadFil = new JButton();
    btLoadFil.setLocation(306, 50); // 306,27
    btLoadFil.setSize(183, 32);
    btLoadFil.setText("Load Words from File");
    getContentPane().add(btLoadFil);

    btFindPat = new JButton();
    btFindPat.setLocation(106, 160);
    btFindPat.setSize(384, 38);
    btFindPat.setText("Find Path");
    getContentPane().add(btFindPat);

    lblDictCoun = new JLabel();
    lblDictCoun.setLocation(108, 513);
    lblDictCoun.setSize(300, 27);
    lblDictCoun.setForeground(new Color(-65536));
    lblDictCoun.setText("Words in Dictionary = 0 words");
    getContentPane().add(lblDictCoun);

    lblIndexing1 = new JLabel();
    lblIndexing1.setLocation(107, 454);
    lblIndexing1.setSize(130, 27);
    lblIndexing1.setForeground(new Color(-16777216));
    lblIndexing1.setText("");
    getContentPane().add(lblIndexing1);

    lblFindPat = new JLabel();
    lblFindPat.setLocation(108, 540);
    lblFindPat.setSize(250, 27);
    lblFindPat.setForeground(new Color(-14646771));
    lblFindPat.setText("Time to find Path: 0 milliseconds");
    getContentPane().add(lblFindPat);

    lblCos = new JLabel();
    lblCos.setLocation(360, 540);
    lblCos.setSize(175, 27);
    lblCos.setForeground(new Color(-16777216));
    lblCos.setText("Cost of Path: 0.0");
    getContentPane().add(lblCos);

    lblProgres = new JLabel();
    lblProgres.setLocation(108, 484);
    lblProgres.setSize(371, 26);
    lblProgres.setForeground(new Color(-14646771));
    lblProgres.setText("Time to Build Graph: 0 milliseconds");
    getContentPane().add(lblProgres);

    testpanel = new JPanel();
    testpanel.setLocation(106, 200);
    testpanel.setSize(350, 200);
    testpanel.setForeground(new Color(-14646771));
    // testpanel.setText("Test Location");
    getContentPane().add(testpanel);

    btClear = new JButton();
    btClear.setLocation(355, 513);
    btClear.setSize(125, 25);
    btClear.setText("Clear Results");
    getContentPane().add(btClear);

    // add actionlisteners to buttons
    btFindPat.addActionListener(this);
    btLoadTextFiel.addActionListener(this);
    btLoadFil.addActionListener(this);
    btClear.addActionListener(this);

    setTitle("WordLadderGUI");
    setSize(500, 600);
    setVisible(true);
    setResizable(false);
  }
Ejemplo n.º 8
0
  /** Creates and adds the necessary GUI components. */
  private void addGUIComponents() {
    setBackground(Color.white);

    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    setLayout(gridbag);

    // Expression
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0.0;
    Label exprFieldp = new Label("Expression: ", Label.RIGHT);
    gridbag.setConstraints(exprFieldp, c);
    add(exprFieldp);

    c.weightx = 0.8;
    exprField = new TextField(27);
    gridbag.setConstraints(exprField, c);
    add(exprField);

    // x
    c.weightx = 0.0;
    Label xFieldp = new Label("x: ", Label.RIGHT);
    gridbag.setConstraints(xFieldp, c);
    add(xFieldp);

    c.weightx = 0.2;
    c.gridwidth = GridBagConstraints.REMAINDER;
    xField = new TextField("" + xValue, 4);
    gridbag.setConstraints(xField, c);
    add(xField);

    // Result
    c.weightx = 0.0;
    c.gridwidth = 1;
    Label resultLabelText = new Label("Result: ", Label.RIGHT);
    gridbag.setConstraints(resultLabelText, c);
    add(resultLabelText);

    c.weightx = 1.0;
    c.gridwidth = GridBagConstraints.REMAINDER;
    resultLabel = new Label("", Label.LEFT);
    gridbag.setConstraints(resultLabel, c);
    add(resultLabel);

    // Options
    c.weightx = 0.0;
    c.gridwidth = 1;
    Label optionsLabelText = new Label("Options: ", Label.RIGHT);
    gridbag.setConstraints(optionsLabelText, c);
    add(optionsLabelText);

    c.weightx = 1.0;
    c.gridwidth = GridBagConstraints.REMAINDER;
    implicitCheckbox = new Checkbox("Implicit multiplication", true);
    gridbag.setConstraints(implicitCheckbox, c);
    add(implicitCheckbox);

    c.weightx = 0.0;
    c.gridwidth = 1;
    Label spaceLabelText = new Label(" ", Label.RIGHT);
    gridbag.setConstraints(spaceLabelText, c);
    add(spaceLabelText);

    c.weightx = 1.0;
    c.gridwidth = GridBagConstraints.REMAINDER;
    undeclaredCheckbox = new Checkbox("Allow undeclared identifiers");
    gridbag.setConstraints(undeclaredCheckbox, c);
    add(undeclaredCheckbox);

    // Errors
    c.weightx = 0.0;
    c.gridwidth = 1;
    c.anchor = GridBagConstraints.NORTH;
    Label errorLabel = new Label("Errors: ", Label.RIGHT);
    gridbag.setConstraints(errorLabel, c);
    add(errorLabel);

    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1.0;
    c.weighty = 1.0;
    c.gridwidth = GridBagConstraints.REMAINDER;
    errorTextArea = new TextArea("");
    errorTextArea.setEditable(false);
    errorTextArea.setBackground(Color.white);
    gridbag.setConstraints(errorTextArea, c);
    add(errorTextArea);

    // Set up listeners
    exprField.addTextListener(
        new TextListener() {
          public void textValueChanged(TextEvent evt) {
            exprFieldTextValueChanged();
          }
        });

    xField.addTextListener(
        new TextListener() {
          public void textValueChanged(TextEvent evt) {
            xFieldTextValueChanged();
          }
        });

    implicitCheckbox.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent evt) {
            optionsChanged();
          }
        });

    undeclaredCheckbox.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent evt) {
            optionsChanged();
          }
        });
  }