示例#1
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;
  }
示例#2
0
 private void AbrirProyectoActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_AbrirProyectoActionPerformed
   // TODO add your handling code here:
   JFileChooser CargarProy = new JFileChooser();
   String leerl = "", filecomplete = "";
   javax.swing.filechooser.FileFilter filtro =
       new FileNameExtensionFilter("Proyecto (.java)", "java");
   CargarProy.setFileFilter(filtro);
   CargarProy.setFileSelectionMode(JFileChooser.FILES_ONLY);
   CargarProy.showOpenDialog(this);
   if (CargarProy.getSelectedFile() != null) {
     Errores.InicializarTablaDeErrores();
     Proyecto = CargarProy.getSelectedFile();
     try {
       FileReader fr = new FileReader(Proyecto);
       BufferedReader br = new BufferedReader(fr);
       while ((leerl = br.readLine()) != null) {
         filecomplete = filecomplete + "\n" + leerl;
       }
     } catch (IOException ex) {
       Logger.getLogger(Interfaz.class.getName()).log(Level.SEVERE, null, ex);
     }
     TextArea a = new TextArea();
     a.setEditable(true);
     a.setText(filecomplete);
     a.setEnabled(true);
     archivos.add(Proyecto);
     TAREAS.add(a);
     this.jTP.add(a);
     this.Guardados = true;
   } // GEN-LAST:event_AbrirProyectoActionPerformed
 }
  void login() {
    try {
      logoutBtn.setEnabled(true);
      contactList.setEditable(false);
      loginBtn.setEnabled(false);
      loginId.setEnabled(false);
      password.setEnabled(false);

      //
      plugin.login(
          getMyLoginId(), password.getText(), getContactList(), MessagingNetwork.STATUS_ONLINE);
      logoutBtn.setEnabled(true);
    } catch (Throwable tr) {
      printException(tr);
      boolean loggedIn = false;
      try {
        loggedIn = plugin.getClientStatus(getMyLoginId()) != MessagingNetwork.STATUS_OFFLINE;
      } catch (Throwable tr2) {
        printException(tr2);
      }
      if (!loggedIn) {
        enableLoginUI();
      }
    }
  }
示例#4
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);
  }
示例#5
0
  // TextArea Text;
  public void init() {

    // Tell the applet not to use a layout manager.
    setSize(500, 500);
    setLayout(null);

    // initialze the button and give it a text.
    Rubric = new Button("Rubric Editor");
    GradeSheet = new Button("Grade Sheet Editor");
    TextArea text = new TextArea("Please Choose one of the following");

    // now we will specify the positions of the GUI components.
    // this is done by specifying the x and y coordinate and
    // the width and height.
    Rubric.setBounds(100, 275, 100, 30);
    GradeSheet.setBounds(230, 275, 150, 30);
    text.setBounds(100, 225, 300, 50);
    text.setEditable(false);
    (text).getScrollbarVisibility();
    // now that all is set we can add these components to the applet
    add(text);
    add(Rubric);
    add(GradeSheet);
    Rubric.addActionListener(this);
    GradeSheet.addActionListener(this);
  }
示例#6
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());
  }
示例#7
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);
  }
示例#8
0
  /** Create the dialog. */
  public AlertMessage(String Message) {
    setBounds(100, 100, 300, 200);
    getContentPane().setLayout(new BorderLayout());
    contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    getContentPane().add(contentPanel, BorderLayout.CENTER);
    contentPanel.setLayout(new GridLayout(1, 0, 0, 0));
    {
      TextArea textArea = new TextArea(Message);
      textArea.setEditable(false);
      contentPanel.add(textArea);
    }
    {
      JPanel buttonPane = new JPanel();
      buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
      getContentPane().add(buttonPane, BorderLayout.SOUTH);
      {
        JButton okButton = new JButton("OK");
        okButton.addActionListener(
            new ActionListener() {

              @Override
              public void actionPerformed(ActionEvent arg0) {
                dispose();
              }
            });
        buttonPane.add(okButton);
        getRootPane().setDefaultButton(okButton);
      }
    }
  }
示例#9
0
  public SafeFrame(String title) {
    super(title);
    setBackground(Color.lightGray);
    setLayout(new BorderLayout());

    // textClockを配置
    add(textClock, BorderLayout.NORTH);
    textClock.setEditable(false);

    // textScreenを配置
    add(textScreen, BorderLayout.CENTER);
    textScreen.setEditable(false);

    // パネルにボタンを格納
    Panel panel = new Panel();
    panel.add(buttonUse);
    panel.add(buttonAlarm);
    panel.add(buttonPhone);
    panel.add(buttonExit);

    // パネルを配置
    add(panel, BorderLayout.SOUTH);

    // 表示
    pack();
    show();

    // リスナーの設定
    buttonUse.addActionListener(this);
    buttonAlarm.addActionListener(this);
    buttonPhone.addActionListener(this);
    buttonExit.addActionListener(this);
  }
 // Script Editor
 private void scriptEditor() {
   scriptfield.setEditable(true);
   scriptfield.setFont(font);
   scriptfield.setPreferredSize(new Dimension(800, 900));
   scriptfield.setCursor(null);
   script.add(scriptfield);
 }
示例#11
0
  private JPanel getContainer() {
    layout = new FlowLayout(); // Instanciation du layout
    layout.setAlignment(FlowLayout.CENTER); // On centre les composants

    container = new JPanel(); // On cr�e notre objet
    container.setLayout(layout); // On applique le layout

    textCycle.setEditable(false);
    textCycle.setPreferredSize(new Dimension(600, 200));
    for (int k = 0; k < cycles.size(); k++) {
      textCycle.setText(
          textCycle.getText()
              + "Cycle no"
              + k
              + " :"
              + cycles.get(k).toString()
              + "\n"
              + "\n"); // On lui donne un texte
      container.add(textCycle); // On l'ajoute au container
    }

    btnPath = new JButton(); // Cr�ation du bouton
    btnPath.setPreferredSize(new Dimension(200, 25)); // On lui donne une taille
    btnPath.setText("Show path"); // On lui donne un texte
    btnPath.addActionListener(this); // On ajoute la fen�tre en tant qu'�couteur du bouton
    container.add(btnPath); // On l'ajoute � la fen�tre

    oneState =
        new JComboBox(listOneState); // On cr�e la liste en lui donnant un tableau d'op�rateurs
    oneState.setPreferredSize(new Dimension(140, 25)); // On lui donne une taille
    container.add(oneState); // on l'ajoute � la fen�tre

    twoStates =
        new JComboBox(listTwoStates); // On cr�e la liste en lui donnant un tableau d'op�rateurs
    twoStates.setPreferredSize(new Dimension(140, 25)); // On lui donne une taille
    container.add(twoStates); // on l'ajoute � la fen�tre

    btnCycle = new JButton(); // Cr�ation du bouton
    btnCycle.setPreferredSize(new Dimension(300, 25)); // On lui donne une taille
    btnCycle.setText("Show cycle"); // On lui donne un texte
    btnCycle.addActionListener(this); // On ajoute la fen�tre en tant qu'�couteur du bouton
    container.add(btnCycle); // On l'ajoute � la fen�tre

    cyclesBox =
        new JComboBox(listCycles); // On cr�e la liste en lui donnant un tableau d'op�rateurs
    cyclesBox.setPreferredSize(new Dimension(120, 25)); // On lui donne une taille
    container.add(cyclesBox); // on l'ajoute � la fen�tre

    btnReset = new JButton(); // Cr�ation du bouton
    btnReset.setPreferredSize(new Dimension(400, 25)); // On lui donne une taille
    btnReset.setText("Clear"); // On lui donne un texte
    btnReset.addActionListener(this); // On ajoute la fen�tre en tant qu'�couteur du bouton
    container.add(btnReset); // On l'ajoute � la fen�tre

    return container;
  }
  /** Returns the output text area. */
  private TextArea getOutput() {
    if (output == null) {
      output = new TextArea(6, 100);
      output.append("Output Goes Here...");
      output.setPreferredSize(new Dimension(580, 120));
      output.setEditable(false);
    }

    return output;
  }
示例#13
0
  public void initComponents() {
    /** ******************** The main container *************************** */
    Container container = this.getContentPane();
    container.setLayout(new BorderLayout());
    container.setBackground(Color.black);
    this.setSize(650, 600);
    this.addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(WindowEvent e) {}
        });

    /** ************************* MAIN PANEL ******************************* */
    mainPanel = new JPanel();
    // If put to False: we see the container's background
    mainPanel.setOpaque(false);
    mainPanel.setLayout(new BorderLayout());
    container.add(mainPanel, BorderLayout.CENTER);

    allmessagesTextArea = new TextArea();
    allmessagesTextArea.setEditable(false);
    allmessagesTextArea.setFont(new Font("Dialog", 1, 12));
    allmessagesTextArea.setForeground(Color.black);
    allmessagesTextArea.append("Select a session in the list to view its messages");
    mainPanel.add(allmessagesTextArea, BorderLayout.CENTER);

    sessionsList = new List();
    sessionsList.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            showMessages(e);
          }
        });
    sessionsList.setForeground(Color.black);
    sessionsList.setFont(new Font("Dialog", 1, 14));
    mainPanel.add(sessionsList, BorderLayout.WEST);

    okButton = new JButton("  OK  ");
    okButton.setToolTipText("Returns to the main frame");
    okButton.setFont(new Font("Dialog", 1, 16));
    okButton.setFocusPainted(false);
    okButton.setBackground(Color.lightGray);
    okButton.setBorder(new BevelBorder(BevelBorder.RAISED));
    okButton.setVerticalAlignment(SwingConstants.CENTER);
    okButton.setHorizontalAlignment(SwingConstants.CENTER);
    container.add(okButton, BorderLayout.SOUTH);
    okButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent evt) {
            setVisible(false);
          }
        });
  }
 void enableLoginUI() {
   try {
     logoutBtn.setEnabled(false);
     contactList.setEditable(true);
     loginBtn.setEnabled(true);
     loginId.setEnabled(true);
     password.setEnabled(true);
   } catch (Throwable tr) {
     CAT.error("exception", tr);
   }
 }
 public ParamValueEditDialog(String s) {
   super(new Frame(), " Edit parameter value");
   text = new TextArea(s, 10, 80, TextArea.SCROLLBARS_BOTH);
   text.setEditable(true);
   add(text, BorderLayout.CENTER);
   setResizable(true);
   pack();
   /*
    * doesn't work anyhow addNotify(); text.setCaretPosition(0);
    */
 }
示例#16
0
  public AppExport() {
    JLabel label = new JLabel("Choose Dashboard's Web directory:               ");
    add(label);

    JButton go = new JButton("Browse...");
    go.addActionListener(this);
    add(go);

    textArea = new TextArea("", 20, 100, TextArea.SCROLLBARS_NONE);
    textArea.setEditable(false);
    add(textArea);
  }
示例#17
0
 public VertexInfoDialog(Vertex vertex) {
   v = vertex;
   setTitle("Vertex: " + v.getName());
   Container cp = getContentPane();
   JPanel p = new JPanel();
   p.setLayout(new GridLayout(1, 1));
   opis = new TextArea(v.getInfo());
   opis.setEditable(false);
   p.add(opis, new FlowLayout());
   cp.add(p);
   setSize(200, 300);
   setDefaultCloseOperation(DISPOSE_ON_CLOSE);
 }
示例#18
0
  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;
    }
  }
示例#19
0
  public NewFractionCalc() {

    super("Fraction Calculator");
    setLayout(new FlowLayout());
    add(msg);
    msg.setEditable(false);
    for (int i = 0; i < sa.length; i++) {
      buta[i] = new Button(sa[i]);
      buta[i].addActionListener(this);
      add(buta[i]);
    }
    setSize(110, 230);
    show();
  }
示例#20
0
  public void addComponentsToPane() {

    testfield = new JTextField("", 33);
    testfield.addKeyListener(this);

    testtextarea = new TextArea(buffer, 15, 33, TextArea.SCROLLBARS_VERTICAL_ONLY);
    testtextarea.setEditable(false);
    JScrollPane scrollPane = new JScrollPane(testtextarea);
    scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    scrollPane.setPreferredSize(new Dimension(600, 200));

    getContentPane().add(testfield, BorderLayout.PAGE_END);
    getContentPane().add(testtextarea, BorderLayout.CENTER);
  }
示例#21
0
 /** Creates new HelpBox */
 public HelpBox() {
   super(new Frame(), " Help ", false);
   this.setBackground(Color.white);
   this.setLayout(new BorderLayout());
   helpTextArea = new TextArea();
   helpTextArea.setEditable(false);
   // fill the help box
   helpTextArea.append(
       "National Institute of Standards and Technology\n"
           + "========================================\n"
           + "\n"
           + "NIST-SIP Trace viewer 1.1\n"
           + "========================================\n"
           + "\n"
           + "\n"
           + " Hit refresh  to get new trace data from the proxy. \n"
           + "If no traces appear at all, you should check if the proxy is started.\n"
           + "Once some SIP sessions are available, you can click directly on \n"
           + "an arrow representing a SIP message of your \n"
           + "choice, and see the text of the chosen SIP message. \n"
           + "If any small yellow bubbles appear on the top right of the SIP message, \n"
           + "you can click on it and see some extra informations logged by the proxy.\n"
           + "\n"
           + "\n"
           + "If you experience any problems please contact:\n"
           + "[email protected]\n"
           + "\n");
   ok = new Button(" Ok ");
   ok.setBackground(Color.lightGray);
   ok.setForeground(Color.black);
   this.add(helpTextArea, BorderLayout.CENTER);
   this.add(ok, BorderLayout.SOUTH);
   ok.addMouseListener(
       new MouseAdapter() {
         @Override
         public void mouseClicked(MouseEvent e) {
           setVisible(false);
         }
       });
   this.addWindowListener(
       new WindowAdapter() {
         @Override
         public void windowClosing(WindowEvent e) {
           setVisible(false);
         }
       });
   // width, height
   this.setSize(400, 400);
 }
示例#22
0
  int runProgram(String test, Panel w) {
    DataInputStream in;

    if (w != null) {

      w.setLayout(new BorderLayout(15, 15));

      textarea = new TextArea(10, 40);
      textarea.setEditable(false);

      w.add("Center", textarea);

      textfield = new TextField(15);
      w.add("South", textfield);

      w.resize(600, 300);
      w.show();

      String hello = "Hello.";
      response(">> " + hello);
      response(processInput(hello));
      textfield.requestFocus();

    } else {
      try {
        in = new DataInputStream(new FileInputStream(test));
        String s;
        s = "Hello.";
        while (true) {
          System.out.println(">> " + s);
          String reply = processInput(s);
          System.out.println(reply);
          if (finished) break;
          s = in.readLine();
          if (s == null) break;
        }
      } catch (IOException e) {
        System.out.println("Problem reading test file.");
        return 1;
      }
    }

    return 0;
  }
示例#23
0
  public ReciveFile() {
    super("파일전송");
    setLayout(null);
    lbl = new Label("파일 전송을 기다립니다.");
    lbl.setBounds(10, 30, 230, 20);
    lbl.setBackground(Color.gray);
    lbl.setForeground(Color.white);
    add(lbl);
    txt = new TextArea("", 0, 0, TextArea.SCROLLBARS_BOTH);
    txt.setBounds(10, 60, 230, 100);
    txt.setEditable(false);
    add(txt);
    btn = new Button("닫기");
    btn.setBounds(105, 170, 40, 20);
    btn.setVisible(false);
    btn.addActionListener(this);
    add(btn);
    addWindowListener(new WinListener());
    setSize(250, 200);
    show();

    try {
      ServerSocket socket = new ServerSocket(port);
      Socket sock = null;
      FileThread client = null;
      try {
        sock = socket.accept();
        client = new FileThread(this, sock);
        client.start();
      } catch (IOException e) {
        System.out.println(e);
        try {
          if (sock != null) sock.close();
        } catch (IOException e1) {
          System.out.println(e1);
        } finally {
          sock = null;
        }
      }
    } catch (IOException e) {
    }
  }
示例#24
0
  public FriendListUI(final ClientTool clientTool) {
    this.clientTool = clientTool;

    this.friendListPanel = new JPanel();
    friendListPanel.setPreferredSize(new Dimension(220, 300));
    friendListPanel.setLayout(new BorderLayout());

    JPanel panel = clientTool.initFriendListPanel();
    scrollPane = new JScrollPane(panel);
    friendListPanel.add(scrollPane, BorderLayout.CENTER);

    broadcastPanel = new JPanel();
    broadcastPanel.setLayout(new BorderLayout());
    broadcastPanel.setPreferredSize(new Dimension(460, 300));

    JPanel inputPanel = new JPanel();
    inputPanel.setPreferredSize(new Dimension(450, 35));
    this.broadcastInputField = new JTextField(30);
    inputPanel.add(broadcastInputField);

    // Bind enter
    broadcastInputField.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            broadcast();
          }
        });

    this.sendBroadcast = new JButton("Broadcast");

    // Bind click
    sendBroadcast.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {
            broadcast();
          }
        });

    inputPanel.add(sendBroadcast);

    this.broadcastContent = new TextArea();
    broadcastContent.setEditable(false);

    this.broadcastContent.setFont(new Font("Verdana", Font.BOLD, 12));
    this.broadcastContent.setForeground(Color.black);

    broadcastPanel.add(broadcastContent, BorderLayout.CENTER);
    broadcastPanel.add(inputPanel, BorderLayout.SOUTH);

    this.add(friendListPanel, BorderLayout.WEST);
    this.add(broadcastPanel, BorderLayout.EAST);
    this.setSize(680, 300);
    this.setResizable(false);
    this.setTitle("Online friend list");
    this.addWindowListener(
        new WindowListener() {

          @Override
          public void windowOpened(WindowEvent e) {}

          @Override
          public void windowIconified(WindowEvent e) {}

          @Override
          public void windowDeiconified(WindowEvent e) {}

          @Override
          public void windowDeactivated(WindowEvent e) {}

          @Override
          public void windowClosing(WindowEvent e) {
            if (clientTool.isServerShutdownConfirmation()) {
              System.exit(0);
              _this.setDefaultCloseOperation(EXIT_ON_CLOSE);
            } else {
              clientTool.closeClient();
              System.exit(0);
              _this.setDefaultCloseOperation(EXIT_ON_CLOSE);
            }
          }

          @Override
          public void windowClosed(WindowEvent e) {}

          @Override
          public void windowActivated(WindowEvent e) {}
        });
    this.clientTool.bindFriendUI(this);
    this.setLocation(665, 330);
    _this = this;
    this.setVisible(true);
  }
示例#25
0
  public Configure() {
    int Width = 640;
    int Height = 480;
    cb = new Checkbox[128];
    final Frame f = new Frame("Configure gnu.io.rxtx.properties");
    String fileSep = System.getProperty("file.separator", "/");
    String devPath;
    if (fileSep.compareTo("/") != 0) {
      devPath = "COM";
    } else {
      devPath = "/dev/";
    }

    f.setBounds(100, 50, Width, Height);
    f.setLayout(new BorderLayout());
    p1 = new Panel();
    p1.setLayout(new GridLayout(16, 4));
    ActionListener l =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            {
              String res = e.getActionCommand();
              if (res.equals("Save")) {
                saveSpecifiedPorts();
              }
            }
          }
        };

    addCheckBoxes(devPath);
    TextArea t = new TextArea(EnumMessage, 5, 50, TextArea.SCROLLBARS_NONE);
    t.setSize(50, Width);
    t.setEditable(false);

    final Panel p2 = new Panel();
    p2.add(new Label("Port Name:"));
    TextField tf = new TextField(devPath, 8);
    tf.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            addCheckBoxes(e.getActionCommand());
            f.setVisible(true);
          }
        });
    p2.add(tf);
    Checkbox Keep = new Checkbox("Keep Ports");
    p2.add(Keep);
    Button b[] = new Button[6];
    for (int j = 0, i = 4; i < 129; i *= 2, j++) {
      b[j] = new Button("1-" + i);
      b[j].addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              int k = Integer.parseInt(e.getActionCommand().substring(2));
              for (int x = 0; x < k; x++) {
                cb[x].setState(!cb[x].getState());
                f.setVisible(true);
              }
            }
          });
      p2.add(b[j]);
    }
    Button b1 = new Button("More");
    Button b2 = new Button("Save");
    b1.addActionListener(l);
    b2.addActionListener(l);
    p2.add(b1);
    p2.add(b2);
    f.add("South", p2);
    f.add("Center", p1);
    f.add("North", t);
    f.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });
    f.setVisible(true);
  }
  /** Create the dialog. */
  public JBookSearch() {
    setAlwaysOnTop(true);
    setTitle("图书查询");
    setBounds(100, 100, 440, 290);
    getContentPane().setLayout(new BorderLayout());
    contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    getContentPane().add(contentPanel, BorderLayout.CENTER);
    contentPanel.setLayout(null);

    JLabel label = new JLabel("请输入你想查找的书名:(关键字)");
    label.setForeground(Color.WHITE);
    label.setFont(new Font("微软雅黑", Font.PLAIN, 16));
    label.setBounds(20, 0, 264, 28);
    contentPanel.add(label);

    textField = new JTextField();
    textField.setFont(new Font("微软雅黑", Font.PLAIN, 16));
    textField.setBounds(20, 38, 255, 28);
    contentPanel.add(textField);
    textField.setColumns(10);

    TextArea textArea = new TextArea();
    textArea.setEditable(false);
    textArea.setFont(new Font("微软雅黑", Font.PLAIN, 16));
    textArea.setBounds(20, 109, 391, 143);
    contentPanel.add(textArea);

    JLabel label_1 = new JLabel("查询结果:");
    label_1.setForeground(Color.WHITE);
    label_1.setFont(new Font("微软雅黑", Font.PLAIN, 16));
    label_1.setBounds(20, 75, 89, 28);
    contentPanel.add(label_1);

    JButton button = new JButton("查询");
    button.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            try {

              /*
               * 在textArea中输出所搜索的书籍信息
               */
              textArea.setText("");
              textArea.append("书号");
              textArea.append("\t");
              textArea.append("书名");
              textArea.append("\t");
              textArea.append("作者");
              textArea.append("\t");
              textArea.append("出版社");
              textArea.append("\t");
              textArea.append("总数");
              textArea.append("\t");
              textArea.append("现存");
              textArea.append("\n");
              String name = textField.getText();
              BookManagement searchabook = new BookManagement();
              List<Book> bookList = searchabook.searchBook(name);
              if (bookList == null) {
                @SuppressWarnings("unused")
                Exception f;
              } else {
                for (int i = 0; i < bookList.size(); i++) {
                  String bookID = Integer.toString(bookList.get(i).getBookID());
                  name = bookList.get(i).getName();
                  String author = bookList.get(i).getAuthor();
                  String publisher = bookList.get(i).getPublisher();
                  String bookNumber = Integer.toString(bookList.get(i).getBookNumber());
                  String book_in_Number = Integer.toString(bookList.get(i).getBook_in_Number());
                  textArea.append(bookID);
                  textArea.append("\t");
                  textArea.append(name);
                  textArea.append("\t");
                  textArea.append(author);
                  textArea.append("\t");
                  textArea.append(publisher);
                  textArea.append("\t");
                  textArea.append(bookNumber);
                  textArea.append("\t");
                  textArea.append(book_in_Number);
                  textArea.append("\n");
                }
              }
            } catch (Exception f) {
              JFailureOperation failure = new JFailureOperation();
              failure.setVisible(true);
              failure.setLocationRelativeTo(null);
              failure.setResizable(false);
            }
          }
        });
    button.setFont(new Font("微软雅黑", Font.PLAIN, 16));
    button.setBounds(310, 20, 93, 23);
    contentPanel.add(button);

    JButton button_1 = new JButton("取消");
    button_1.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            dispose();
          }
        });
    button_1.setFont(new Font("微软雅黑", Font.PLAIN, 16));
    button_1.setBounds(310, 61, 93, 23);
    contentPanel.add(button_1);

    JLabel label_2 = new JLabel("");
    label_2.setIcon(new ImageIcon(JBookSearch.class.getResource("/sources/4.jpg")));
    label_2.setBounds(0, 0, 434, 262);
    contentPanel.add(label_2);
  }
示例#27
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 babylonServerWindow(babylonServer parent, String Name) {
    super(Name);
    server = parent;

    myLayout = new GridBagLayout();
    setLayout(myLayout);

    p = new Panel();
    p.setLayout(myLayout);

    listening = new Label(server.strings.get(thisClass, "listenport") + " " + server.port);
    p.add(
        listening,
        new babylonConstraints(
            0,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.NONE,
            new Insets(0, 0, 0, 0),
            0,
            0));

    logChat = new Checkbox(server.strings.get(thisClass, "logchats"), server.logChats);
    logChat.addItemListener(this);
    p.add(
        logChat,
        new babylonConstraints(
            1,
            0,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.NONE,
            new Insets(0, 0, 0, 0),
            0,
            0));

    userList = new List(4, false);
    userList.addItemListener(this);
    p.add(
        userList,
        new babylonConstraints(
            0,
            1,
            1,
            5,
            1.0,
            1.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 5, 0),
            0,
            0));

    userAdmin = new Button(server.strings.get(thisClass, "usermanagement"));
    userAdmin.addActionListener(this);
    p.add(
        userAdmin,
        new babylonConstraints(
            1,
            1,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, 0, 0, 0),
            0,
            0));

    console = new Button(server.strings.get(thisClass, "adminclient"));
    console.addActionListener(this);
    p.add(
        console,
        new babylonConstraints(
            1,
            2,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, 0, 0, 0),
            0,
            0));

    disconnect = new Button(server.strings.get(thisClass, "disconnectuser"));
    disconnect.setEnabled(false);
    disconnect.addActionListener(this);
    p.add(
        disconnect,
        new babylonConstraints(
            1,
            3,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, 0, 0, 0),
            0,
            0));

    disconnectAll = new Button(server.strings.get(thisClass, "disconnectall"));
    disconnectAll.setEnabled(false);
    disconnectAll.addActionListener(this);
    p.add(
        disconnectAll,
        new babylonConstraints(
            1,
            4,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, 0, 0, 0),
            0,
            0));

    shutdown = new Button(server.strings.get(thisClass, "shutdown"));
    shutdown.addActionListener(this);
    p.add(
        shutdown,
        new babylonConstraints(
            1,
            5,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, 0, 0, 0),
            0,
            0));

    stats =
        new TextField(
            server.strings.get(thisClass, "connectionscurrent")
                + " 0  "
                + server.strings.get(thisClass, "connectionspeak")
                + " 0  "
                + server.strings.get(thisClass, "connectionstotal")
                + " 0",
            40);
    stats.setEditable(false);
    p.add(
        stats,
        new babylonConstraints(
            0,
            7,
            2,
            1,
            1.0,
            1.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 0),
            0,
            0));

    logWindow =
        new TextArea(
            server.strings.get(thisClass, "activitylog") + "\n",
            10,
            40,
            TextArea.SCROLLBARS_VERTICAL_ONLY);
    logWindow.setEditable(false);
    p.add(
        logWindow,
        new babylonConstraints(
            0,
            8,
            2,
            1,
            1.0,
            1.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 5, 0),
            0,
            0));

    canvas = new babylonPictureCanvas(this);
    p.add(
        canvas,
        new babylonConstraints(
            0,
            9,
            2,
            1,
            1.0,
            1.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 0),
            0,
            0));

    add(
        p,
        new babylonConstraints(
            0,
            0,
            1,
            1,
            1.0,
            1.0,
            GridBagConstraints.NORTHWEST,
            GridBagConstraints.BOTH,
            new Insets(5, 5, 5, 5),
            0,
            0));

    try {
      URL url = new URL("file", "localhost", "babylonPic.jpg");
      Image image = getToolkit().getImage(url);

      canvas.setimage(image);
    } catch (Exception e) {
      System.out.println(e);
    }

    try {
      URL iconUrl = new URL("file", "localhost", "babylonIcon.jpg");
      ImageIcon icon = new ImageIcon(iconUrl);
      this.setIconImage(icon.getImage());
    } catch (Exception e) {
      /* Not important */
    }

    addWindowListener(this);

    setSize(600, 600);
    pack();
  }
示例#29
0
import java.applet.*;
 {
   eventLog.setEditable(false);
 }