Beispiel #1
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);
  }
  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);
  }
Beispiel #3
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());
  }
Beispiel #4
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);
  }
Beispiel #5
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;
  }
Beispiel #6
0
  ComponentSampleI() {
    // analise o uso do método abaixo
    // tf.setPreferredSize(new Dimension(200,20));

    // insere b e tf no painel
    p.add(b);
    p.add(tf);

    // insere o painel no norte do frame
    add(p, BorderLayout.NORTH);

    // atribui cor ao fundo e às letras na área de texto
    ta.setBackground(Color.cyan);
    ta.setForeground(Color.red);
    ta.setPreferredSize(new Dimension(250, 50));

    x.setBackground(Color.yellow);
    add(x, BorderLayout.CENTER); // estica o componente em ambas as direções

    add(ta, BorderLayout.EAST); // estica o componente na horizontal
    add(l, BorderLayout.SOUTH); // estica o componente na vertical

    // descobre as dimensões do monitor
    d = (Toolkit.getDefaultToolkit()).getScreenSize();

    // calcula e posiciona o frame no centro da tela
    setLocation(
        (d.width - this.getSize().width) / 2 - 150, (d.height - this.getSize().height) / 2 - 200);

    setSize(300, 400);
    setVisible(true);
  }
  public EdgePropertiesDialog(Frame frame, Edge edge_in, Graph graph_in) {
    super(frame, "", true);
    frame_ = frame;

    graph_ = graph_in;
    edge_ = edge_in;
    //  if(edge_ == null)
    //     edge_ = Edge.defaults;

    LPanel p = new LPanel();
    p.constraints.weighty = 0.0;
    notDefault_[ndCount_++] = p.addLineLabel("Label:", 1);
    labelText_ = p.addTextField(8, 0, -1, 1.0, 0.0, 1, 1);

    p.addLineLabel("Line Style", 1);
    style_ = new Choice();
    for (int i = 0; i < Edge.styleLabels.length; i++) style_.addItem(Edge.styleLabels[i]);
    p.addComponent(style_, 0, -1, 1.0, 0.0, 0, 1);

    p.addLineLabel("Points in order x y z:", 0);

    pointsText_ = new TextArea(4, 20);
    pointsText_.setBackground(Color.white);
    p.addComponent(pointsText_, 0, -1, 1.0, 1.0, 3, 0);

    p.constraints.gridwidth = 1;
    p.constraints.weightx = 0.0;

    p.addLineLabel("Data", 1);
    data_ = new Choice();
    dataPanel_ = new Panel();
    dataPanel_.add(data_);
    p.addComponent(dataPanel_, 0, -1, 1.0, 0.0, 0, 1);

    dataText_ = new TextArea(4, 20);
    dataText_.setBackground(Color.white);
    p.constraints.insets.top = 0;
    p.addComponent(dataText_, 0, -1, 1.0, 1.0, 3, 0);

    p.addButtonPanel("Apply Cancel", 0);

    p.finish();
    add("Center", p);
    setEdge(edge_, graph_);
  }
Beispiel #8
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++;
 }
  public int showDialog(Frame parentWindow, Throwable error) {
    if (this._dialog != null) {
      throw new IllegalStateException("CustomOreGen Config Error Dialog is already open!");
    } else {
      this._dialog = new Dialog(parentWindow, "CustomOreGen Config Error", false);
      this._dialog.addWindowListener(this);
      TextArea text = new TextArea(this.getMessage(error), 30, 120, 1);
      text.setEditable(false);
      text.setBackground(Color.WHITE);
      text.setFont(new Font("Monospaced", 0, 12));
      this._dialog.add(text);
      Panel buttonPanel = new Panel();
      this._abort = new Button("Abort");
      this._abort.addActionListener(this);
      buttonPanel.add(this._abort);
      this._retry = new Button("Retry");
      this._retry.addActionListener(this);
      buttonPanel.add(this._retry);
      this._ignore = new Button("Ignore");
      this._ignore.addActionListener(this);
      buttonPanel.add(this._ignore);
      buttonPanel.setLayout(new BoxLayout(buttonPanel, 0));
      this._dialog.add(buttonPanel);
      this._dialog.setLayout(new BoxLayout(this._dialog, 1));
      this._dialog.pack();
      Point loc = parentWindow.getLocation();
      Dimension parentSize = parentWindow.getSize();
      Dimension size = this._dialog.getSize();
      loc.x += (parentSize.width - size.width) / 2;
      loc.y += (parentSize.height - size.height) / 2;
      this._dialog.setLocation(loc);
      this._waiting = true;
      this._returnVal = 0;
      this._dialog.setVisible(true);
      boolean usingLWJGL = false; // CustomOreGenBase.isClassLoaded("org.lwjgl.opengl.Display");

      while (this._waiting) {
        if (usingLWJGL && Display.isCreated()) {
          Display.processMessages();
        }
      }

      this._abort = null;
      this._retry = null;
      this._ignore = null;
      this._dialog.setVisible(false);
      this._dialog.dispose();
      this._dialog = null;
      return this._returnVal;
    }
  }
Beispiel #10
0
 /** ClipboardTest constructor comment. */
 public DictAWTView(String cfg) {
   super();
   IDictEngine e = org.dict.server.DatabaseFactory.getEngine(cfg);
   this.engine = e;
   f = new Frame("Dictionary lookup");
   f.setSize(600, 400);
   f.setLayout(new BorderLayout());
   ta = new TextArea();
   ta.setBackground(Color.white);
   ta.setForeground(Color.black);
   ta.addMouseListener(new ML());
   ta.addFocusListener(new FL());
   Button prev = new Button("History");
   prev.addActionListener(new History());
   mode = new Checkbox("Automatic", false);
   db = new Choice();
   for (int i = 0; i < e.getDatabases().length; i++) {
     db.add(e.getDatabases()[i].getName());
   }
   db.add("Any database");
   fontChoice = new Choice();
   fontChoice.add("serif");
   fontChoice.add("monospaced");
   fontChoice.add("dialog");
   fontChoice.addItemListener(new IL());
   sizeChoice = new Choice();
   sizeChoice.add("10");
   sizeChoice.add("12");
   sizeChoice.add("15");
   sizeChoice.addItemListener(new IL());
   Panel north = new Panel();
   north.setBackground(Color.lightGray);
   north.add(mode);
   north.add(db);
   north.add(fontChoice);
   north.add(sizeChoice);
   north.add(prev);
   f.add(north, "North");
   f.add(ta, "Center");
   f.addWindowListener(
       new WindowAdapter() {
         @Override
         public void windowClosing(WindowEvent e) {
           System.exit(0);
         }
       });
   f.setVisible(true);
 }
Beispiel #11
0
  @Override
  protected void addBody() {
    super.addBody();

    mTextArea = new TextArea();
    mTextArea.setBackground(Color.LIGHT_GRAY);
    mTextArea.setBounds(1, 1, mContentBody.getWidth() - 1, Config.WIN_PANEL_H - 1);

    JScrollPane scroll = new JScrollPane(mTextArea);
    scroll.setBounds(8, 4, Config.PANEL_BODY_WIDTH - 8 * 2, Config.PANEL_LEFT_HEIGHT - 4 * 2);
    scroll.setOpaque(false);
    scroll.getViewport().setOpaque(false);
    scroll.setBorder(BorderFactory.createEmptyBorder());

    mBodyPanel.add(scroll);
  }
Beispiel #12
0
  @Override
  public void run() {

    TextArea textArea = new TextArea(toString());
    textArea.setBackground(Color.BLACK);
    textArea.setForeground(Color.WHITE);

    JFrame janela = new JFrame("JACAS");
    janela.add(textArea);
    janela.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    janela.setSize(
        new Dimension(new Double(362 * 2.3).intValue(), new Double(373 * 2.3).intValue()));
    janela.setVisible(true);

    while (true) {
      try {
        Thread.sleep(1000);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
      textArea.setText(toString());
    }
  }
 public void error(String s) {
   output.append(s + "\n");
   output.setBackground(new Color(220, 0, 0));
 }
Beispiel #14
0
  /** *********************************************************************** */
  private void initComponents() {

    /** ******************** The main container *************************** */
    Container container = this.getContentPane();
    container.setLayout(new BoxLayout(container, BoxLayout.Y_AXIS));
    // container.setLayout( new PercentLayout() );
    container.setBackground(Color.black);

    addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(WindowEvent e) {
            System.out.println("Trace viewer closed!");
            // System.exit(0);
          }
        });

    /** ******************** Menu bar ************************************* */
    menuBar = new JMenuBar();
    setJMenuBar(menuBar);

    // Build a second menu in the menu bar.
    optionsMenu = new JMenu("      Options      ");
    optionsMenu.setBorder(new BevelBorder(BevelBorder.RAISED));
    optionsMenu.setToolTipText("Some options related to the GUI");
    animationMenuItem = new JMenuItem("    Animation    ");
    animationMenuItem.setToolTipText("Animation of the entire selected session");
    animationMenuItem.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent evt) {
            listenerTracesViewer.animationActionPerformed(evt);
          }
        });
    optionsMenu.add(animationMenuItem);
    menuBar.add(optionsMenu);

    // create a menu and add it to the menubar
    displayAllSessionsMenu = new JMenu("    Display Sessions    ");
    displayAllSessionsMenu.setBorder(new BevelBorder(BevelBorder.RAISED));
    displayAllSessionsMenu.setToolTipText(
        "Display all the retrieved sessions in a separate windows");
    displayAllSessionsMenu.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent evt) {
            listenerTracesViewer.displayAllSessionsMouseEvent(evt);
          }
        });
    // add the Controls menu to the menu bar
    menuBar.add(displayAllSessionsMenu);

    // create a menu and add it to the menubar
    refreshMenu = new JMenu("   Refresh   ");
    refreshMenu.setBorder(new BevelBorder(BevelBorder.RAISED));
    refreshMenu.setBackground(new Color(51, 153, 255));
    refreshMenu.setToolTipText("Get the new traces");
    refreshMenu.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent evt) {
            listenerTracesViewer.refreshActionPerformed(evt);
          }
        });
    // add the Controls menu to the menu bar
    menuBar.add(refreshMenu);

    // ...create and add some menus...
    menuBar.add(Box.createHorizontalGlue());

    helpMenu = new JMenu("    Help    ");
    helpMenu.setBorder(new BevelBorder(BevelBorder.RAISED));
    helpMenu.setToolTipText("Some useful notes about this tool");
    helpMenu.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent evt) {
            listenerTracesViewer.helpMenuMouseEvent(evt);
          }
        });
    menuBar.add(helpMenu);

    aboutMenu = new JMenu("    About    ");
    aboutMenu.setBorder(new BevelBorder(BevelBorder.RAISED));
    aboutMenu.setToolTipText("Some advertises about the creators!");
    aboutMenu.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent evt) {
            listenerTracesViewer.aboutMenuMouseEvent(evt);
          }
        });
    menuBar.add(aboutMenu);

    quitMenu = new JMenu("    Quit    ");
    quitMenu.setBorder(new BevelBorder(BevelBorder.RAISED));
    quitMenu.setToolTipText("Quit the traces viewer");
    quitMenu.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent evt) {
            close();
          }
        });
    menuBar.add(quitMenu);

    /** ****************** FIRST PANEL ******************************* */
    firstPanel = new JPanel();
    // If put to False: we see the container's background
    firstPanel.setOpaque(false);
    firstPanel.setLayout(new PercentLayout());
    // firstPanel.setLayout(  new BorderLayout() );
    container.add(firstPanel);

    // Sub right panel:
    // topx %, topy %, width %, height % 73, 100-> 65, 95
    PercentLayoutConstraint firstPanelConstraint = new PercentLayoutConstraint(30, 0, 70, 100);
    tracesSessionsList = new TracesSessionsList();
    tracesSessionsList.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            listenerTracesViewer.tracesSessionsListStateChanged(e);
          }
        });
    tracesSessionsList.setForeground(Color.black);
    tracesSessionsList.setFont(new Font("Dialog", 1, 14));

    ScrollPane scroll = new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS);
    TracesSession tracesSession = tracesSessions.firstElement();
    String name = tracesSession.getName();
    String logDescription = tracesSession.getLogDescription();
    String callId = tracesSessionsList.getCallId(name);
    String origin = tracesSessionsList.getOrigin(name);

    // Warning: to put before for the canvas!!!!
    TextArea messageContentTextArea = new TextArea();
    messageContentButton = new JButton("SIP Message:");
    if (name.equals("No available session, refresh")) {
      tracesCanvas = new TracesCanvas(tracesSession, messageContentTextArea, "unknown", this);
    } else if (logDescription == null || logDescription.trim().equals("")) {
      tracesCanvas = new TracesCanvas(tracesSession, messageContentTextArea, origin, this);
    } else {
      //  System.out.println("logDesc44:"+logDescription);
      tracesCanvas = new TracesCanvas(tracesSession, messageContentTextArea, logDescription, this);
    }

    tracesSessionsList.setTracesCanvas(tracesCanvas);
    // The ScrollPane for the Canvas
    scroll.add(tracesCanvas);
    firstPanel.add(scroll, firstPanelConstraint);

    /** ************************* SECOND PANEL ******************************* */

    //  left panel:
    secondPanel = new JPanel();
    secondPanel.setBackground(Color.black);
    // rows, columns
    //  secondPanel.setLayout(new GridLayout(3,1,0,0) );
    secondPanel.setLayout(new BorderLayout());
    // topx %, topy %, width %, height %
    PercentLayoutConstraint secondPanelConstraint = new PercentLayoutConstraint(0, 0, 30, 100);
    firstPanel.add(secondPanel, secondPanelConstraint);

    /** **************************** FIRST SUB PANEL ********************************* */

    // Sub left panel:
    firstSubPanel = new JPanel();
    firstSubPanel.setBackground(Color.black);
    // Top, left, bottom, right
    firstSubPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 7, 5));

    if (!standaloneViewer) {
      // rows, columns, gap, gap
      firstSubPanel.setLayout(new GridLayout(2, 1, 3, 6));
      secondPanel.add(firstSubPanel, BorderLayout.NORTH);

      JPanel panelGrid = new JPanel();
      panelGrid.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
      panelGrid.setLayout(new GridLayout(2, 1, 0, 0));

      JPanel panelBox = new JPanel();
      panelBox.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
      panelBox.setLayout(new BorderLayout());

      JLabel scriptLabel = new JLabel("Display the event script:");
      scriptLabel.setToolTipText("Display the content of the selected script");

      scriptLabel.setHorizontalAlignment(SwingConstants.CENTER);
      scriptLabel.setForeground(Color.black);
      scriptLabel.setFont(new Font("Dialog", 1, 14));
      // If put to true: we see the label's background
      scriptLabel.setOpaque(true);
      panelGrid.add(scriptLabel);

      choice = new Choice();
      panelBox.add(choice, BorderLayout.CENTER);

      scriptButton = new JButton("Open");
      scriptButton.setToolTipText("Get the script controlling the current session");
      scriptButton.setFont(new Font("Dialog", 1, 14));
      scriptButton.setFocusPainted(false);
      scriptButton.setBackground(new Color(186, 175, 175));
      scriptButton.setBorder(new BevelBorder(BevelBorder.RAISED));
      scriptButton.setVerticalAlignment(SwingConstants.CENTER);
      scriptButton.setHorizontalAlignment(SwingConstants.CENTER);
      panelBox.add(scriptButton, BorderLayout.EAST);
      scriptButton.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent evt) {
              listenerTracesViewer.scriptActionPerformed(evt);
            }
          });
      panelGrid.add(panelBox);
      firstSubPanel.add(panelGrid);
      // initComboBox();

      /*
      refreshButton=new JButton("Refresh");
      refreshButton.setToolTipText("Refresh all the sessions");
      refreshButton.setFont(new Font ("Dialog", 1, 14));
      refreshButton.setFocusPainted(false);
      //refreshButton.setBackground(new Color(186,175,175));
      refreshButton.setBackground( new Color(51,153,255));
      refreshButton.setBorder(new BevelBorder(BevelBorder.RAISED));
      refreshButton.setVerticalAlignment(AbstractButton.CENTER);
      refreshButton.setHorizontalAlignment(AbstractButton.CENTER);
      firstSubPanel.add(refreshButton);
      refreshButton.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent evt) {
               listenerTracesViewer.refreshActionPerformed(evt);
         }
      }
      );
       */
      ImageIcon icon;
      if (logoNist != null) {
        icon = new ImageIcon(logoNist);

        JLabel label = new JLabel(icon);
        label.setVisible(true);
        label.setToolTipText("The NIST logo!!!");
        // label.setHorizontalAlignment(AbstractButton.CENTER);
        label.setForeground(Color.black);
        // label.setFont(new Font ("Dialog", 1, 14));
        label.setOpaque(false);
        firstSubPanel.add(label);
      }
    } else {
      // rows, columns, gap, gap
      firstSubPanel.setLayout(new GridLayout(1, 1, 3, 6));
      secondPanel.add(firstSubPanel, BorderLayout.NORTH);

      ImageIcon icon;
      if (logoNist != null) {
        icon = new ImageIcon(logoNist);
        JLabel label = new JLabel(icon);
        label.setVisible(true);
        label.setToolTipText("The NIST logo!!!");
        label.setHorizontalAlignment(SwingConstants.CENTER);
        label.setForeground(Color.black);
        label.setFont(new Font("Dialog", 1, 14));
        label.setOpaque(false);
        firstSubPanel.add(label);
      }
    }

    /** **************** SECOND SUB PANEL *************************************** */
    JPanel panel = new JPanel();
    panel.setLayout(new GridLayout(2, 1, 0, 0));
    secondPanel.add(panel, BorderLayout.CENTER);
    secondSubPanel = new JPanel();
    secondSubPanel.setBackground(Color.black);
    secondSubPanel.setLayout(new BorderLayout());
    // secondPanel.add(secondSubPanel);
    panel.add(secondSubPanel);

    sessionsLabel = new JLabel("Sessions available:");
    sessionsLabel.setToolTipText("All the sessions currently available");
    // Alignment of the text
    sessionsLabel.setHorizontalAlignment(SwingConstants.CENTER);
    // Color of the text
    sessionsLabel.setForeground(Color.black);
    // Size of the text
    sessionsLabel.setFont(new Font("Dialog", 1, 14));
    // If put to true: we see the label's background
    sessionsLabel.setOpaque(true);
    sessionsLabel.setBackground(Color.lightGray);
    sessionsLabel.setBorder(BorderFactory.createLineBorder(Color.darkGray));
    secondSubPanel.add(sessionsLabel, BorderLayout.NORTH);

    ScrollPane scrollList = new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS);
    scrollList.add(tracesSessionsList);
    // secondSubPanel.add(scrollList,BorderLayout.CENTER);
    secondSubPanel.add(tracesSessionsList, BorderLayout.CENTER);

    /** ****************** THIRD SUB PANEL *************************************** */
    thirdSubPanel = new JPanel();
    thirdSubPanel.setBackground(Color.black);
    thirdSubPanel.setLayout(new BorderLayout());
    // secondPanel.add(thirdSubPanel);
    panel.add(thirdSubPanel);

    messageContentButton.setToolTipText("Display all the content of the current SIP message");
    // Alignment of the text
    messageContentButton.setHorizontalAlignment(SwingConstants.CENTER);
    // Color of the text
    messageContentButton.setForeground(Color.black);
    // Size of the text
    messageContentButton.setFont(new Font("Dialog", 1, 14));
    // If put to true: we see the label's background
    messageContentButton.setOpaque(true);
    messageContentButton.setBackground(Color.lightGray);
    messageContentButton.setBorder(BorderFactory.createLineBorder(Color.darkGray));
    messageContentButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent evt) {
            listenerTracesViewer.debugActionPerformed(evt);
          }
        });
    messageContentTextArea.setBackground(Color.white);
    messageContentTextArea.setEditable(false);
    messageContentTextArea.setFont(new Font("Dialog", 1, 12));
    messageContentTextArea.setForeground(Color.black);
    thirdSubPanel.add(messageContentButton, BorderLayout.NORTH);
    thirdSubPanel.add(messageContentTextArea, BorderLayout.CENTER);

    validateTree();
  }
  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);
  }
Beispiel #16
0
  public MainFrame(
      final Socket socket, String user, ObjectInputStream reader, ObjectOutputStream writer) {
    super("Main");

    frame = this;
    this.socket = socket;
    owner = user;
    Reader = reader;
    Writer = writer;

    screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    frameSize = new Dimension(300, 510);
    setSize(frameSize);
    setLocation(screenSize.width / 2 - frameSize.width, (screenSize.height - frameSize.height) / 2);
    setBackground(Color.decode("#ccfffa"));
    setResizable(false);
    setLayout(null);

    // add Label "Online User List:"
    Label label1 = new Label("Online User List:");
    label1.setSize(200, 20);
    label1.setLocation(20, 40);
    add(label1);
    // add user list
    userList = new List(10, false);
    userList.setSize(260, 95);
    userList.setLocation(20, 60);
    add(userList);
    // add label "chat content:"
    Label label2 = new Label("Chat Content:");
    label2.setSize(200, 20);
    label2.setLocation(20, 160);
    add(label2);
    // add chat content
    textArea = new TextArea("", 18, 30, TextArea.SCROLLBARS_VERTICAL_ONLY);
    textArea.setBackground(Color.white);
    textArea.setEditable(false);
    textArea.setSize(260, 220);
    textArea.setLocation(20, 180);
    add(textArea);
    // add label "Send Message:"
    Label label3 = new Label("Send Message:");
    label3.setSize(200, 20);
    label3.setLocation(20, 405);
    add(label3);
    // add input textfield
    final TextField inputArea = new TextField();
    inputArea.setSize(205, 25);
    inputArea.setLocation(20, 425);
    add(inputArea);

    // add send button
    Button send = new Button("Send");
    send.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent arg0) {
            String text = inputArea.getText();
            try {
              Writer.writeObject(new MSG("MSG", text));
            } catch (IOException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            }
            textArea.setText(textArea.getText().concat("[" + owner + "]:" + text + "\n"));
            inputArea.setText("");
          }
        });
    send.setSize(50, 25);
    send.setLocation(230, 425);
    add(send);

    // add button "Start Game"
    final Button btnGame = new Button("Start Game");
    btnGame.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            if (!isGame) {
              setSize(460, 510);
              controlPanel = new ControlPanel(socket, Reader, Writer, frame, owner);
              controlPanel.setLocation(300, 60);
              add(controlPanel);
              isGame = true;
              try {
                Writer.writeObject(new MSG("REQLIST", ""));
              } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
              }
              btnGame.setLabel("End Game");
            } else {
              try {
                Writer.writeObject(new MSG("QUIT", ""));
              } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
              }
              setSize(300, 510);
              remove(controlPanel);
              isGame = false;
              btnGame.setLabel("Start Game");
            }
          }
        });
    btnGame.setSize(90, 25);
    btnGame.setLocation(65, 465);
    add(btnGame);

    // add button quit
    Button btnQuit = new Button("Exit");
    btnQuit.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            if (isGame) {
              if (!controlPanel.canQuit) return;
              try {
                Writer.writeObject(new MSG("QUIT", ""));
              } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
              }
              controlPanel.isHost = false;
              controlPanel.panelHost = null;
              controlPanel.panelHost = null;
              controlPanel.initPanelStart();
              controlPanel.panelStart.setSize(135, 420);
              controlPanel.panelStart.setLocation(0, 0);
              controlPanel.add(controlPanel.panelStart);
            }
            runFlag = false;
            if (socket != null) {
              try {
                Writer.writeObject(new MSG("QUT", ""));
                socket.close();
              } catch (IOException e) {
                // TODO Auto-generated catch block
                // e.printStackTrace();
              }
            }
            System.exit(0);
          }
        });
    btnQuit.setSize(55, 25);
    btnQuit.setLocation(175, 465);
    add(btnQuit);

    new ReceiveThread(Reader).start();
  }
  public void makeTheWarning(
      int X,
      int Y,
      int width,
      int height,
      Color fg,
      Color bg,
      String title,
      String text,
      boolean oneLine,
      Frame frame) {

    Font warnFont = new java.awt.Font("SanSerif", Font.BOLD, 12);
    FontMetrics warnFontMetrics = getFontMetrics(warnFont);

    // Create Dialog window with modal blocking set to true.
    // Make final so inner class below can access it.

    final Dialog mww = new Dialog(frame, title, true);
    mww.setLayout(new BorderLayout());
    mww.setSize(width, height);
    mww.setLocation(X, Y);

    // Use Label for 1-line warning

    if (oneLine) {
      Label hT = new Label(text, Label.CENTER);
      hT.setForeground(fg);
      hT.setBackground(bg);
      hT.setFont(warnFont);
      mww.add("Center", hT);

      // Use TextArea for multiline warning

    } else {
      TextArea hT = new TextArea("", height, width, TextArea.SCROLLBARS_NONE);
      hT.setEditable(false);
      hT.setForeground(fg);
      hT.setBackground(bg); // no effect once setEditable (false)?
      hT.setFont(warnFont);
      mww.add("Center", hT);
      hT.appendText(text);
    }

    mww.setTitle(title);

    // Add dismiss button

    Panel botPanel = new Panel();
    botPanel.setBackground(Color.lightGray);
    Label label1 = new Label();
    Label label2 = new Label();

    Button dismissButton = new Button("Dismiss");
    botPanel.add(label1);
    botPanel.add(dismissButton);
    botPanel.add(label2);

    // Add inner class event handler for Dismiss button.  This must be
    // added to the dismissButton before botPanel is added to mww.

    dismissButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            mww.hide();
            mww.dispose();
          }
        });

    mww.add("South", botPanel);

    // Add window closing button (inner class)

    mww.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            mww.hide();
            mww.dispose();
          }
        });

    mww.show(); // Note that this show must come after all the above
    // additions; otherwise they are not added before the
    // window is displayed.
  }
 public void message(String s) {
   output.append(s + "\n");
   output.setBackground(Color.white);
 }
Beispiel #19
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();
          }
        });
  }