コード例 #1
0
ファイル: Irc.java プロジェクト: greg5813/projet-sysco
  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
ファイル: DynamicEvents.java プロジェクト: xjpsjtu/Tij
 public DynamicEvents() {
   setLayout(new FlowLayout());
   b1.addActionListener(new B());
   b1.addActionListener(new B1());
   b2.addActionListener(new B());
   b2.addActionListener(new B2());
   add(b1);
   add(b2);
 }
コード例 #3
0
  /** Method declaration */
  private void initGUI() {

    Panel pQuery = new Panel();
    Panel pCommand = new Panel();

    pResult = new Panel();

    pQuery.setLayout(new BorderLayout());
    pCommand.setLayout(new BorderLayout());
    pResult.setLayout(new BorderLayout());

    Font fFont = new Font("Dialog", Font.PLAIN, 12);

    txtCommand = new TextArea(5, 40);

    txtCommand.addKeyListener(this);

    txtResult = new TextArea(20, 40);

    txtCommand.setFont(fFont);
    txtResult.setFont(new Font("Courier", Font.PLAIN, 12));

    butExecute = new Button("Execute");
    butClear = new Button("Clear");

    butExecute.addActionListener(this);
    butClear.addActionListener(this);
    pCommand.add("East", butExecute);
    pCommand.add("West", butClear);
    pCommand.add("Center", txtCommand);

    gResult = new Grid();

    setLayout(new BorderLayout());
    pResult.add("Center", gResult);
    pQuery.add("North", pCommand);
    pQuery.add("Center", pResult);
    fMain.add("Center", pQuery);

    tTree = new Tree();

    // (ulrivo): screen with less than 640 width
    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();

    if (d.width >= 640) {
      tTree.setMinimumSize(new Dimension(200, 100));
    } else {
      tTree.setMinimumSize(new Dimension(80, 100));
    }

    gResult.setMinimumSize(new Dimension(200, 300));
    fMain.add("West", tTree);
    doLayout();
    fMain.pack();
  }
コード例 #4
0
ファイル: TransCreator.java プロジェクト: asanian/GenNet
  /**
   * Cr�e une nouvelle instance de CreeTrans
   *
   * @param mf fenetre principale de l'application
   * @param zg Zone graphique
   * @param auto automate
   * @param be barre d'�tat
   */
  public TransCreator(MainFrame mf, GraphicZone g, Automate auto, StateBar be) {

    super(JOptionPane.getFrameForComponent(mf), "Creating interaction", true);

    this.setResizable(false);

    this.gz = g;
    this.auto = auto;
    this.bar = be;
    this.mf = mf;

    be.displayInfo("Creating interaction");

    tfJPanel1 = new JPanel(new FlowLayout(FlowLayout.LEFT));
    tfJPanel1.setBackground(Color.lightGray);
    tfJPanel1.add(new JLabel("Type  : "));
    groupe = new CheckboxGroup();
    plus = new Checkbox("activator", groupe, true);
    tfJPanel1.add(plus);
    minus = new Checkbox("inhibitor", groupe, false);
    tfJPanel1.add(minus);

    tfJPanel2 = new JPanel(new FlowLayout(FlowLayout.LEFT));
    tfJPanel2.setBackground(Color.lightGray);
    tfJPanel2.add(new JLabel("Threshold  = "));
    tf = new JTextField(auto.nbrCharTransLabel);
    tf.setText("1");
    tfJPanel2.add(tf);

    btJPanel = new JPanel(new GridLayout(1, 2, 0, 0));
    btJPanel.setBackground(Color.lightGray);
    ok = new Button("Ok");
    ok.setBackground(Color.lightGray);
    ok.addActionListener(this);
    cancel = new Button("Cancel");
    cancel.setBackground(Color.lightGray);
    cancel.addActionListener(this);
    btJPanel.add(ok);
    btJPanel.add(cancel);

    content = this.getContentPane();
    content.setLayout(new BorderLayout());
    content.setBackground(Color.lightGray);
    content.add(tfJPanel1, BorderLayout.NORTH);
    content.add(tfJPanel2, BorderLayout.CENTER);
    content.add(btJPanel, BorderLayout.SOUTH);

    this.pack();
    this.setLocationRelativeTo(this.mf);

    tf.requestFocusInWindow();

    // rendre la fenetre visible
    setVisible(true);
  }
コード例 #5
0
ファイル: GUIConfig.java プロジェクト: kojones/HRIS
 public void init(GUI gui) {
   m_gui = gui;
   // Create the display
   // width, height
   addWindowListener(
       new WindowAdapter() {
         public void windowClosing(WindowEvent e) {
           dispose();
         }
       });
   setSize(new Dimension(100, 100));
   setBackground(Color.white);
   setFont(new Font("Helvetica", Font.PLAIN, 14));
   GridBagLayout gridbag = new GridBagLayout();
   setLayout(gridbag);
   GridBagConstraints c = new GridBagConstraints();
   c.fill = GridBagConstraints.BOTH;
   c.weightx = 1.0;
   recency = new TextField(Truline.userProps.getProperty("RecencyDays", "28"), 5);
   setRow(c, gridbag, new Label("Recency Days"), recency);
   maxdays = new TextField(Truline.userProps.getProperty("MaxDays", "120"), 5);
   setRow(c, gridbag, new Label("Max Days"), maxdays);
   maxvariant = new TextField(Truline.userProps.getProperty("MaxVariant", "25"), 5);
   setRow(c, gridbag, new Label("Max Variant"), maxvariant);
   maiden = new TextField(Truline.userProps.getProperty("UseMaiden", "Y"), 2);
   setRow(c, gridbag, new Label("Use Maiden"), maiden);
   betFactorVersion = new TextField(Truline.userProps.getProperty("BetFactorVersion", " "), 7);
   setRow(c, gridbag, new Label("Bet Factor Version"), betFactorVersion);
   datadir = new TextField(Truline.userProps.getProperty("DATADIR", "."), 40);
   setRow(c, gridbag, new Label("Data Directory"), datadir);
   fontsize = new TextField(Truline.userProps.getProperty("FontSize", "8"), 40);
   setRow(c, gridbag, new Label("Print Font Size (8,9,10)"), fontsize);
   printProgram =
       new TextField(Truline.userProps.getProperty("PrintProgram", "WordPad.exe /p"), 40);
   setRow(c, gridbag, new Label("Print program"), printProgram);
   // shell = new TextField(Truline.userProps.getProperty("Shell", "command"),
   // 40);
   // setRow(c, gridbag, new Label("Shell program"), shell);
   Panel panel1 = new Panel();
   panel1.setLayout(new BorderLayout());
   Button OKButton = new Button(" OK ");
   OKButton.setActionCommand("ok");
   OKButton.addActionListener(this);
   panel1.add(OKButton, BorderLayout.CENTER);
   Panel panel2 = new Panel();
   panel2.setLayout(new BorderLayout());
   Button cancelButton = new Button("Cancel");
   cancelButton.setActionCommand("cancel");
   cancelButton.addActionListener(this);
   panel2.add(cancelButton, BorderLayout.CENTER);
   setRow(c, gridbag, panel2, panel1);
   pack();
   show();
 }
コード例 #6
0
  {
    removeFromContactList.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ev) {
            try {
              String cl = contactList.getText();
              for (; ; ) {
                int pos = cl.indexOf(contactListEntry.getText());
                if (pos == -1) break;
                cl = cl.substring(0, pos) + cl.substring(pos + contactListEntry.getText().length());
              }
              for (; ; ) {
                int pos = cl.indexOf("\n\n");
                if (pos == -1) break;
                cl = cl.substring(0, pos) + cl.substring(pos + "\n\n".length());
              }
              if (cl.startsWith("\n")) cl = cl.substring("\n".length());
              if (cl.endsWith("\n")) cl = cl.substring(0, cl.length() - "\n".length());
              contactList.setText(cl);

              //
              plugin.removeFromContactList(getMyLoginId(), contactListEntry.getText());
            } catch (Throwable tr) {
              printException(tr);
            }
          }
        });
  }
コード例 #7
0
ファイル: HardcopyWriter.java プロジェクト: olexy/RealJava
 /** Constructor for the test program's window. */
 public Demo() {
   super("HardcopyWriter Test"); // Call frame constructor
   Panel p = new Panel(); // Add a panel to the frame
   this.add(p, "Center"); // Center it
   p.setFont(
       new Font(
           "SansSerif", // Set a default font
           Font.BOLD,
           18));
   print = new Button("Print Test Page"); // Create a Print button
   quit = new Button("Quit"); // Create a Quit button
   print.addActionListener(this); // Specify that we'll handle
   quit.addActionListener(this); //   button presses
   p.add(print); // Add the buttons to the panel
   p.add(quit);
   this.pack(); // Set the size of everything
 }
コード例 #8
0
 {
   closeBtn.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent ev) {
           try {
             quit();
           } catch (Throwable tr) {
             CAT.error("exception", tr);
           }
         }
       });
 }
コード例 #9
0
 private Button getSendContactsButton() {
   if (sendContactsButton == null) {
     sendContactsButton = new Button("send random contacts");
     sendContactsButton.addActionListener(
         new ActionListener() {
           public void actionPerformed(ActionEvent e) {
             sendContacts();
           }
         });
   }
   return sendContactsButton;
 }
コード例 #10
0
 {
   loginBtn.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent ev) {
           new Thread("icqtest/login button handler") {
             public void run() {
               try {
                 login();
               } catch (Throwable tr) {
                 CAT.error("exception", tr);
               }
             }
           }.start();
         }
       });
 }
コード例 #11
0
 private Button getUserDetailsButton() {
   if (userDetailsButton == null) {
     userDetailsButton = new Button("user info");
     userDetailsButton.addActionListener(
         new ActionListener() {
           public void actionPerformed(ActionEvent e) {
             try {
               fetchUserDetails();
             } catch (Throwable tr) {
               CAT.error("exception", tr);
             }
           }
         });
   }
   return userDetailsButton;
 }
コード例 #12
0
  public NslWrong(NslFrame parent) {

    super(parent, "Error", true);
    frame = parent;

    setLayout(new GridLayout(2, 1));

    Panel panel = new Panel();
    panel.add(new Label("Error: Invalid value for variable entered!"));

    add(panel);

    Button b;

    Panel okbutton = new Panel();
    okbutton.add(b = new Button("Ok"));
    b.addActionListener(this);

    add(okbutton);
    setSize(300, 85);
    setVisible(true);
  }
コード例 #13
0
  /**
   *   Handles when aides cover each other. They must tell
   *   us who they're covering so that that poor person
   *   doesn't get a missed shift. This of course means i
   *   have to work on MyHours some more... If they select
   *   a valid userid to cover for makes the appropriate
   *   entry in AIDELOG.
   *
   *   @param An SaoWorker who is covering someone else
   */
  public void WhoRUCovering(final SaoWorker w)
  {
    int i = 0;
    int h = bd.getHours();
    int m = bd.getMinutes();
    if (((m >= 20) && (m < 30)) || ((m >= 50) && (m < 60)))
    {
      if (m < 30) { m = m + 10; }
      else { m = m + 10 - 60; h = h + 1; }      
    }
    int dopp = bd.getDoPP();
    if (dopp > 7) { dopp = dopp - 7; }
    String slotid = bd.getSlot(h, m, dopp);
    String q = "select * from AIDESCHED where " + slotid + "=1";
    final String[] userids = {"", "", "", "", "", "", "", "", "", ""};
    final BatSQL bSQL = new BatSQL();
    ResultSet rs = bSQL.query(q);
    
    try
    {
      boolean more = rs.next();
      if (more) //because there might be only one person for this slot
      {
        while (more)
        {
          userids[i] = rs.getString(1);
          i++;
          more = rs.next();
        }
      } //end of if more
    } //end of try
    catch (SQLException ex)
    {
      System.out.println("!*******SQLException caught*******!");
      System.out.println("WhoRUCovering");
      while (ex != null)
      {
        System.out.println ("SQLState: " + ex.getSQLState ());
        System.out.println ("Message:  " + ex.getMessage ());
        System.out.println ("Vendor:   " + ex.getErrorCode ());
        ex = ex.getNextException ();
        System.out.println ("");
      }
      System.exit(0);
    } //end catching SQLExceptions
    catch (java.lang.Exception ex)
    {
      System.out.println("!*******Exception caught*******!");
      System.out.println("WhoRUCovering");      
      System.exit(0);
    } //end catching other Exceptions
    
    final Frame coverF = new Frame("Covering?");
    final Panel     p  = new Panel();
    final Panel  btnP  = new Panel();
    final List  coverL = new List();
    Button    ok = new Button("Cover");
    Button   nok = new Button("Cancel");
    final int i2 = i;
    
    ok.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e)
      {
        String id = coverL.getSelectedItem();
        BatSQL bS = new BatSQL();
        String a = "insert into aidelog values ('C', \"" + id + "\", \"" + bd.getDate() + "\", " + bd.getStringHours() + bd.getStringMinutes() + ", 'I')";
        bS.update(a);
        a = "update AIDEDIN set COVERING='" + id + "' where USERID='" + w.getUserID() + "'";
        bS.update(a);
        bS.disconnect();
        coverF.dispose();
      }
    });
    nok.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e)
      {
        coverF.dispose();
      }
    });
    
    btnP.setLayout(new FlowLayout());
    btnP.add(ok);
    btnP.add(nok);
    
    p.setLayout(new BorderLayout());
    p.add(new Label("Who are you covering for?"), BorderLayout.NORTH);
    int j;
    for (j = 0; j <= i; j++)
    {
      coverL.add(userids[j]);
    }
    p.add(coverL, BorderLayout.CENTER);
    p.add(btnP, BorderLayout.SOUTH);
    
    coverL.select(0);
    
    coverF.setLayout(new FlowLayout());
    coverF.add(p);    
    coverF.pack();
    coverF.setLocation(200, 200);
    coverF.show();

  } //end of WhoRUCovering
コード例 #14
0
  public NslDimValue(
      NslFrame nsl_display_frame,
      String var_sel_full_name,
      NslVariableInfo var_sel_info,
      String plot_type_name,
      boolean replace_canvas) {
    super(nsl_display_frame, "Enter Values", true);

    /* these variables are needed in the action method */
    this.nsl_display_frame = nsl_display_frame;
    this.var_sel_full_name = var_sel_full_name;
    this.var_sel_info = var_sel_info;
    this.plot_type_name = plot_type_name;
    this.replace_canvas = replace_canvas;

    num_dims = (var_sel_info.getCountDimensions());

    if ((num_dims == 0) || (num_dims == 1) || (num_dims == 2) || (num_dims >= 4)) {
      System.err.println("Error: NslDimValue: should not have gotten here in the code.");
      return;
    }

    Panel p = new Panel();
    if (num_dims == 3) {
      if (NslDimInput.dim_choice.equals("HI")) {
        addEnterOneValue(p, "J");
      } else if (NslDimInput.dim_choice.equals("HJ")) {
        addEnterOneValue(p, "I");
      } else if (NslDimInput.dim_choice.equals("IJ")) {
        addEnterOneValue(p, "H");
      } else {
        System.err.println("Error: NslDimVal: bad input choice.");
        dispose();
        return;
      }
    } // end if (num_dims==3)
    else if (num_dims == 4) {
      if (NslDimInput.dim_choice.equals("GH")) {
        addEnterTwoValues(p, "I", "J");
      } else if (NslDimInput.dim_choice.equals("GI")) {
        addEnterTwoValues(p, "H", "J");
      } else if (NslDimInput.dim_choice.equals("GJ")) {
        addEnterTwoValues(p, "H", "I");
      } else if (NslDimInput.dim_choice.equals("HI")) {
        addEnterTwoValues(p, "G", "J");
      } else if (NslDimInput.dim_choice.equals("HJ")) {
        addEnterTwoValues(p, "G", "I");
      } else if (NslDimInput.dim_choice.equals("IJ")) {
        addEnterTwoValues(p, "G", "H");
      } else {
        System.err.println("Error: NslDimVal:bad input choice");
        dispose();
        return;
      }
    } // end if (num_dims==4)

    add("Center", p);

    Button b;
    Panel p4 = new Panel();
    p4.setLayout(new GridLayout(1, 5));
    p4.add(b = new Button("<Back"));
    b.addActionListener(this);
    p4.add(new Label(""));
    p4.add(b = new Button("Cancel"));
    b.addActionListener(this);
    p4.add(new Label(""));
    p4.add(b = new Button("Next>"));
    b.addActionListener(this);
    add("South", p4);
    setSize(450, 180);
  } // end constructor
コード例 #15
0
  paintboard1(String s) {
    super(s);
    addMouseMotionListener(this);
    addMouseListener(this);

    paintInfo = new Vector();

    /* 各工具按钮及选择项 */
    // 颜色选择
    ColChoice = new Choice();
    ColChoice.add("black");
    ColChoice.add("red");
    ColChoice.add("blue");
    ColChoice.add("green");
    ColChoice.addItemListener(this);
    // 画笔大小选择
    SizeChoice = new Choice();
    SizeChoice.add("1");
    SizeChoice.add("3");
    SizeChoice.add("5");
    SizeChoice.add("7");
    SizeChoice.add("9");
    SizeChoice.addItemListener(this);
    // 橡皮大小选择
    EraserChoice = new Choice();
    EraserChoice.add("5");
    EraserChoice.add("9");
    EraserChoice.add("13");
    EraserChoice.add("17");
    EraserChoice.addItemListener(this);
    // //////////////////////////////////////////////////
    toolPanel = new Panel();

    clear = new Button("清除");
    eraser = new Button("橡皮");
    pen = new Button("画笔");
    drLine = new Button("画直线");
    drCircle = new Button("画圆形");
    drRect = new Button("画矩形");

    openPic = new Button("打开图画");
    savePic = new Button("保存图画");

    colchooser = new Button("显示调色板");

    // 各组件事件监听
    clear.addActionListener(this);
    eraser.addActionListener(this);
    pen.addActionListener(this);
    drLine.addActionListener(this);
    drCircle.addActionListener(this);
    drRect.addActionListener(this);
    openPic.addActionListener(this);
    savePic.addActionListener(this);
    colchooser.addActionListener(this);

    颜色 = new Label("画笔颜色", Label.CENTER);
    大小B = new Label("画笔大小", Label.CENTER);
    大小E = new Label("橡皮大小", Label.CENTER);
    // 面板添加组件
    toolPanel.add(openPic);
    toolPanel.add(savePic);

    toolPanel.add(pen);
    toolPanel.add(drLine);
    toolPanel.add(drCircle);
    toolPanel.add(drRect);

    toolPanel.add(颜色);
    toolPanel.add(ColChoice);
    toolPanel.add(大小B);
    toolPanel.add(SizeChoice);
    toolPanel.add(colchooser);

    toolPanel.add(eraser);
    toolPanel.add(大小E);
    toolPanel.add(EraserChoice);

    toolPanel.add(clear);
    // 工具面板到APPLET面板
    add(toolPanel, BorderLayout.NORTH);

    setBounds(230, 50, 900, 650);
    setVisible(true);
    validate();
    // dialog for save and load

    openPicture = new FileDialog(this, "打开图画", FileDialog.LOAD);
    openPicture.setVisible(false);
    savePicture = new FileDialog(this, "保存图画", FileDialog.SAVE);
    savePicture.setVisible(false);

    openPicture.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            openPicture.setVisible(false);
          }
        });

    savePicture.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            savePicture.setVisible(false);
          }
        });

    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });
  }
コード例 #16
0
ファイル: GenericDialog.java プロジェクト: aschain/ImageJA
 /** Displays this dialog box. */
 public void showDialog() {
   if (macro) {
     dispose();
     recorderOn = Recorder.record && Recorder.recordInMacros;
   } else {
     if (pfr != null) // prepare preview (not in macro mode): tell the PlugInFilterRunner to listen
     pfr.setDialog(this);
     Panel buttons = new Panel();
     buttons.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 0));
     cancel = new Button(cancelLabel);
     cancel.addActionListener(this);
     cancel.addKeyListener(this);
     if (yesNoCancel) {
       okLabel = yesLabel;
       no = new Button(noLabel);
       no.addActionListener(this);
       no.addKeyListener(this);
     }
     okay = new Button(okLabel);
     okay.addActionListener(this);
     okay.addKeyListener(this);
     boolean addHelp = helpURL != null;
     if (addHelp) {
       help = new Button(helpLabel);
       help.addActionListener(this);
       help.addKeyListener(this);
     }
     if (IJ.isMacintosh()) {
       if (addHelp) buttons.add(help);
       if (yesNoCancel) buttons.add(no);
       if (!hideCancelButton) buttons.add(cancel);
       buttons.add(okay);
     } else {
       buttons.add(okay);
       if (yesNoCancel) buttons.add(no);
       ;
       if (!hideCancelButton) buttons.add(cancel);
       if (addHelp) buttons.add(help);
     }
     c.gridx = 0;
     c.gridy = y;
     c.anchor = GridBagConstraints.EAST;
     c.gridwidth = 2;
     c.insets = new Insets(15, 0, 0, 0);
     grid.setConstraints(buttons, c);
     add(buttons);
     if (IJ.isMacintosh()) setResizable(false);
     pack();
     setup();
     if (centerDialog) GUI.center(this);
     setVisible(true);
     recorderOn = Recorder.record;
     IJ.wait(50); // work around for Sun/WinNT bug
   }
   /* For plugins that read their input only via dialogItemChanged, call it at least once */
   if (!wasCanceled && dialogListeners != null && dialogListeners.size() > 0) {
     resetCounters();
     ((DialogListener) dialogListeners.elementAt(0)).dialogItemChanged(this, null);
     recorderOn = false;
   }
   resetCounters();
 }
コード例 #17
0
    public BandAdjuster() {

      super("Threshold Colour");
      if (instance != null) {
        instance.toFront();
        return;
      }
      imp = WindowManager.getCurrentImage();
      if (imp == null) {
        IJ.beep();
        IJ.showStatus("No image");
        return;
      }
      IJ.run("Select None");
      thread = new Thread(this, "BandAdjuster");
      WindowManager.addWindow(this);
      instance = this;
      IJ.register(PasteController.class);

      ij = IJ.getInstance();
      Font font = new Font("SansSerif", Font.PLAIN, 10);
      GridBagLayout gridbag = new GridBagLayout();
      GridBagConstraints c = new GridBagConstraints();
      setLayout(gridbag);

      int y = 0;
      c.gridx = 0;
      c.gridy = y;
      c.gridwidth = 1;
      c.weightx = 0;
      c.insets = new Insets(5, 0, 0, 0);
      labelh = new Label("Hue", Label.CENTER);
      add(labelh, c);

      c.gridx = 1;
      c.gridy = y++;
      c.gridwidth = 1;
      c.weightx = 0;
      c.insets = new Insets(7, 0, 0, 0);
      labelf = new Label("Filter type", Label.RIGHT);
      add(labelf, c);

      // plot
      c.gridx = 0;
      c.gridy = y;
      c.gridwidth = 1;
      c.fill = c.BOTH;
      c.anchor = c.CENTER;
      c.insets = new Insets(0, 5, 0, 0);
      add(plot, c);

      // checkboxes
      panelh = new Panel();
      filterTypeH = new CheckboxGroup();
      bandPassH = new Checkbox("Pass");
      bandPassH.setCheckboxGroup(filterTypeH);
      bandPassH.addItemListener(this);
      panelh.add(bandPassH);
      bandStopH = new Checkbox("Stop");
      bandStopH.setCheckboxGroup(filterTypeH);
      bandStopH.addItemListener(this);
      panelh.add(bandStopH);
      bandPassH.setState(true);
      c.gridx = 1;
      c.gridy = y++;
      c.gridwidth = 2;
      c.insets = new Insets(5, 0, 0, 0);
      add(panelh, c);

      // minHue slider
      minSlider = new Scrollbar(Scrollbar.HORIZONTAL, 0, 1, 0, sliderRange);
      c.gridx = 0;
      c.gridy = y++;
      c.gridwidth = 1;
      c.weightx = IJ.isMacintosh() ? 90 : 100;
      c.fill = c.HORIZONTAL;
      c.insets = new Insets(5, 5, 0, 0);

      add(minSlider, c);
      minSlider.addAdjustmentListener(this);
      minSlider.setUnitIncrement(1);

      // minHue slider label
      c.gridx = 1;
      c.gridwidth = 1;
      c.weightx = IJ.isMacintosh() ? 10 : 0;
      c.insets = new Insets(5, 0, 0, 0);
      label1 = new Label("       ", Label.LEFT);
      label1.setFont(font);
      add(label1, c);

      // maxHue sliderHue
      maxSlider = new Scrollbar(Scrollbar.HORIZONTAL, 0, 1, 0, sliderRange);
      c.gridx = 0;
      c.gridy = y;
      c.gridwidth = 1;
      c.weightx = 100;
      c.insets = new Insets(5, 5, 0, 0);
      add(maxSlider, c);
      maxSlider.addAdjustmentListener(this);
      maxSlider.setUnitIncrement(1);

      // maxHue slider label
      c.gridx = 1;
      c.gridwidth = 1;
      c.gridy = y++;
      c.weightx = 0;
      c.insets = new Insets(5, 0, 0, 0);
      label2 = new Label("       ", Label.LEFT);
      label2.setFont(font);
      add(label2, c);

      // =====
      c.gridx = 0;
      c.gridy = y++;
      c.gridwidth = 1;
      c.weightx = 0;
      c.insets = new Insets(10, 0, 0, 0);
      labels = new Label("Saturation", Label.CENTER);
      add(labels, c);

      // plot
      c.gridx = 0;
      c.gridy = y;
      c.gridwidth = 1;
      c.fill = c.BOTH;
      c.anchor = c.CENTER;
      c.insets = new Insets(0, 5, 0, 0);
      add(splot, c);

      // checkboxes
      panels = new Panel();
      filterTypeS = new CheckboxGroup();
      bandPassS = new Checkbox("Pass");
      bandPassS.setCheckboxGroup(filterTypeS);
      bandPassS.addItemListener(this);
      panels.add(bandPassS);
      bandStopS = new Checkbox("Stop");
      bandStopS.setCheckboxGroup(filterTypeS);
      bandStopS.addItemListener(this);
      panels.add(bandStopS);
      bandPassS.setState(true);
      c.gridx = 1;
      c.gridy = y++;
      c.gridwidth = 2;
      c.insets = new Insets(5, 0, 0, 0);
      add(panels, c);

      // minSat slider
      minSlider2 = new Scrollbar(Scrollbar.HORIZONTAL, 0, 1, 0, sliderRange);
      c.gridx = 0;
      c.gridy = y++;
      c.gridwidth = 1;
      c.weightx = IJ.isMacintosh() ? 90 : 100;
      c.fill = c.HORIZONTAL;
      c.insets = new Insets(5, 5, 0, 0);
      add(minSlider2, c);
      minSlider2.addAdjustmentListener(this);
      minSlider2.setUnitIncrement(1);

      // minSat slider label
      c.gridx = 1;
      c.gridwidth = 1;
      c.weightx = IJ.isMacintosh() ? 10 : 0;
      c.insets = new Insets(5, 0, 0, 0);
      label3 = new Label("       ", Label.LEFT);
      label3.setFont(font);
      add(label3, c);

      // maxSat slider
      maxSlider2 = new Scrollbar(Scrollbar.HORIZONTAL, 0, 1, 0, sliderRange);
      c.gridx = 0;
      c.gridy = y++;
      c.gridwidth = 1;
      c.weightx = 100;
      c.insets = new Insets(5, 5, 0, 0);
      add(maxSlider2, c);
      maxSlider2.addAdjustmentListener(this);
      maxSlider2.setUnitIncrement(1);

      // maxSat slider label
      c.gridx = 1;
      c.gridwidth = 1;
      c.weightx = 0;
      c.insets = new Insets(5, 0, 0, 0);
      label4 = new Label("       ", Label.LEFT);
      label4.setFont(font);
      add(label4, c);

      // =====
      c.gridx = 0;
      c.gridwidth = 1;
      c.gridy = y++;
      c.weightx = 0;
      c.insets = new Insets(10, 0, 0, 0);
      labelb = new Label("Brightness", Label.CENTER);
      add(labelb, c);

      c.gridx = 0;
      c.gridwidth = 1;
      c.gridy = y;
      c.fill = c.BOTH;
      c.anchor = c.CENTER;
      c.insets = new Insets(0, 5, 0, 0);
      add(bplot, c);

      // checkboxes
      panelb = new Panel();
      filterTypeB = new CheckboxGroup();
      bandPassB = new Checkbox("Pass");
      bandPassB.setCheckboxGroup(filterTypeB);
      bandPassB.addItemListener(this);
      panelb.add(bandPassB);
      bandStopB = new Checkbox("Stop");
      bandStopB.setCheckboxGroup(filterTypeB);
      bandStopB.addItemListener(this);
      panelb.add(bandStopB);
      bandPassB.setState(true);
      c.gridx = 1;
      c.gridy = y++;
      c.gridwidth = 2;
      c.insets = new Insets(5, 0, 0, 0);
      add(panelb, c);

      // minBri slider
      minSlider3 = new Scrollbar(Scrollbar.HORIZONTAL, 0, 1, 0, sliderRange);
      c.gridx = 0;
      c.gridy = y++;
      c.gridwidth = 1;
      c.weightx = IJ.isMacintosh() ? 90 : 100;
      c.fill = c.HORIZONTAL;
      c.insets = new Insets(5, 5, 0, 0);
      add(minSlider3, c);
      minSlider3.addAdjustmentListener(this);
      minSlider3.setUnitIncrement(1);

      // minBri slider label
      c.gridx = 1;
      c.gridwidth = 1;
      c.weightx = IJ.isMacintosh() ? 10 : 0;
      c.insets = new Insets(5, 0, 0, 0);
      label5 = new Label("       ", Label.LEFT);
      label5.setFont(font);
      add(label5, c);

      // maxBri slider
      maxSlider3 = new Scrollbar(Scrollbar.HORIZONTAL, 0, 1, 0, sliderRange);
      c.gridx = 0;
      c.gridy = y++;
      c.gridwidth = 1;
      c.weightx = 100;
      c.insets = new Insets(5, 5, 0, 0);
      add(maxSlider3, c);
      maxSlider3.addAdjustmentListener(this);
      maxSlider3.setUnitIncrement(1);

      // maxBri slider label
      c.gridx = 1;
      c.gridwidth = 1;
      c.weightx = 0;
      c.insets = new Insets(5, 0, 0, 0);
      label6 = new Label("       ", Label.LEFT);
      label6.setFont(font);
      add(label6, c);

      // =====
      panelt = new Panel();
      threshold = new Checkbox("Threshold");
      threshold.addItemListener(this);
      panelt.add(threshold);

      invert = new Checkbox("Invert");
      invert.addItemListener(this);
      panelt.add(invert);

      c.gridx = 0;
      c.gridy = y++;
      c.gridwidth = 2;
      c.insets = new Insets(0, 0, 0, 0);
      add(panelt, c);

      // buttons
      panel = new Panel();
      // panel.setLayout(new GridLayout(2, 2, 0, 0));
      originalB = new Button("Original");
      originalB.setEnabled(false);
      originalB.addActionListener(this);
      originalB.addKeyListener(ij);
      panel.add(originalB);

      filteredB = new Button("Filtered");
      filteredB.setEnabled(false);
      filteredB.addActionListener(this);
      filteredB.addKeyListener(ij);
      panel.add(filteredB);

      stackB = new Button("Stack");
      stackB.addActionListener(this);
      stackB.addKeyListener(ij);
      panel.add(stackB);

      helpB = new Button("Help");
      helpB.addActionListener(this);
      helpB.addKeyListener(ij);
      panel.add(helpB);

      c.gridx = 0;
      c.gridy = y++;
      c.gridwidth = 2;
      c.insets = new Insets(0, 0, 0, 0);
      add(panel, c);

      panelMode = new Panel();

      sampleB = new Button("Sample");
      sampleB.addActionListener(this);
      sampleB.addKeyListener(ij);
      panelMode.add(sampleB);

      colourMode = new CheckboxGroup();
      hsb = new Checkbox("HSB");
      hsb.setCheckboxGroup(colourMode);
      hsb.addItemListener(this);
      panelMode.add(hsb);
      hsb.setState(true);
      rgb = new Checkbox("RGB");
      rgb.setCheckboxGroup(colourMode);
      rgb.addItemListener(this);
      panelMode.add(rgb);

      c.gridx = 0;
      c.gridy = y++;
      c.gridwidth = 2;
      c.insets = new Insets(0, 0, 0, 0);
      add(panelMode, c);

      addKeyListener(ij); // ImageJ handles keyboard shortcuts
      pack();
      GUI.center(this);
      setVisible(true);

      ip = setup(imp);
      if (ip == null) {
        imp.unlock();
        IJ.beep();
        IJ.showStatus("RGB image cannot be thresholded");
        return;
      }
      thread.start();
    }
コード例 #18
0
ファイル: GuiClient.java プロジェクト: x-mel/eva
  public GuiClient() {
    setLayout(new FlowLayout());

    /** ** We define the textfields and buttons****** */
    lbIP = new Label("Enter the IP address of the server: "); // Construct Label
    add(lbIP);

    tfIP = new TextField(110); // Construct TextField
    add(tfIP); // "super" Frame adds TextField
    tfIP.setText("10.16.31.163"); // Set a default value

    tfIP.addActionListener(this);
    // Hitting Enter on TextField fires ActionEvent
    // tfInput (TextField) registers this instance as ActionEvent listener

    lblInput = new Label("Enter a link below: ");
    add(lblInput);

    tfInput = new TextField(110);
    add(tfInput);
    tfInput.setText("http://vodlocker.com/budq9rt5wt0e");
    tfInput.addActionListener(this);

    lblOutput = new Label("The download link is below: ");
    add(lblOutput);

    tfOutput = new TextField(110);
    tfOutput.setEditable(false); // read-only
    add(tfOutput);

    /** ************Stream************** */
    Butstr = new Button("Stream"); // construct Button
    add(Butstr); // "super" Frame adds Button

    Butstr.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            streamvidlink(getvidlink());
            tfOutput.setText("The video is being streamed");
          }
        });

    /** ************Download************** */
    Butdow = new Button("Download");
    add(Butdow);

    Butdow.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            downvidlink(getvidlink());
            tfOutput.setText("The video is being downloaded");
          }
        });

    /** ************QR CODE************** */
    Butqr = new Button("Qr Code");
    add(Butqr);

    Butqr.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // we load the qrvidlink() function that saves the image locally
            qrvidlink();
            try {
              // we display the image that is saved
              Runtime.getRuntime().exec("display qrcode.png");
              tfOutput.setText("The Qr code will be generated");
            } catch (Exception ex) {
              System.out.println("Qr Code failed: " + ex);
            }
          }
        });

    setTitle("Client"); // "super" Frame sets title
    setSize(900, 400); // "super" Frame sets initial window size
    setVisible(true); // "super" Frame shows
  }