예제 #1
0
파일: ImageJ.java 프로젝트: Jondeen/imagej1
  /**
   * If 'applet' is not null, creates a new ImageJ frame that runs as an applet. If 'mode' is
   * ImageJ.EMBEDDED and 'applet is null, creates an embedded (non-standalone) version of ImageJ.
   */
  public ImageJ(java.applet.Applet applet, int mode) {
    super("ImageJ");
    embedded = applet == null && (mode == EMBEDDED || mode == NO_SHOW);
    this.applet = applet;
    String err1 = Prefs.load(this, applet);
    if (IJ.isLinux()) {
      backgroundColor = new Color(240, 240, 240);
      setBackground(backgroundColor);
    }
    Menus m = new Menus(this, applet);
    String err2 = m.addMenuBar();
    m.installPopupMenu(this);
    setLayout(new GridLayout(2, 1));

    // Tool bar
    toolbar = new Toolbar();
    toolbar.addKeyListener(this);
    add(toolbar);

    // Status bar
    statusBar = new Panel();
    statusBar.setLayout(new BorderLayout());
    statusBar.setForeground(Color.black);
    statusBar.setBackground(backgroundColor);
    statusLine = new Label();
    statusLine.setFont(SansSerif12);
    statusLine.addKeyListener(this);
    statusLine.addMouseListener(this);
    statusBar.add("Center", statusLine);
    progressBar = new ProgressBar(120, 20);
    progressBar.addKeyListener(this);
    progressBar.addMouseListener(this);
    statusBar.add("East", progressBar);
    statusBar.setSize(toolbar.getPreferredSize());
    add(statusBar);

    IJ.init(this, applet);
    addKeyListener(this);
    addWindowListener(this);
    setFocusTraversalKeysEnabled(false);

    Point loc = getPreferredLocation();
    Dimension tbSize = toolbar.getPreferredSize();
    int ijWidth = tbSize.width + 10;
    int ijHeight = 100;
    setCursor(Cursor.getDefaultCursor()); // work-around for JDK 1.1.8 bug
    if (mode != NO_SHOW) {
      if (IJ.isWindows())
        try {
          setIcon();
        } catch (Exception e) {
        }
      setBounds(loc.x, loc.y, ijWidth, ijHeight); // needed for pack to work
      setLocation(loc.x, loc.y);
      pack();
      setResizable(!(IJ.isMacintosh() || IJ.isWindows())); // make resizable on Linux
      show();
    }
    if (err1 != null) IJ.error(err1);
    if (err2 != null) {
      IJ.error(err2);
      IJ.runPlugIn("ij.plugin.ClassChecker", "");
    }
    m.installStartupMacroSet();
    if (IJ.isMacintosh() && applet == null) {
      Object qh = null;
      qh = IJ.runPlugIn("MacAdapter", "");
      if (qh == null) IJ.runPlugIn("QuitHandler", "");
    }
    if (applet == null) IJ.runPlugIn("ij.plugin.DragAndDrop", "");
    String str = m.getMacroCount() == 1 ? " macro" : " macros";
    IJ.showStatus(version() + m.getPluginCount() + " commands; " + m.getMacroCount() + str);
    // if (applet==null && !embedded && Prefs.runSocketListener)
    //	new SocketListener();
    configureProxy();
    if (applet == null) loadCursors();
  }
예제 #2
0
 /**
  * 新增視窗物件 設定物件屬性 內容
  *
  * @param o 物件instances
  * @param reg 物件位置
  * @param name 物件名稱
  * @param value 物件標籤 或 內容
  */
 protected void addObject(Object o, Rectangle reg, String name, String value) {
   if (o instanceof Label) {
     ((Label) o).setText(value);
     ((Label) o).setName(name);
     ((Label) o).setBounds(reg);
     ((Label) o).addMouseListener(this);
     this.add((Label) o);
   } else if (o instanceof TextField) {
     ((TextField) o).setText(value);
     ((TextField) o).setName(name);
     ((TextField) o).setBounds(reg);
     ((TextField) o).addMouseListener(this);
     ((TextField) o).addTextListener(this);
     ((TextField) o).addKeyListener(this);
     if (value.equalsIgnoreCase("password")) ((TextField) o).setEchoChar('*');
     this.add((TextField) o);
   } else if (o instanceof Button) {
     int len = (int) ((float) reg.width / FONTWIDTH);
     ((Button) o).setLabel(StringUtil_.splitStringSpace(value, len));
     ((Button) o).setName(name);
     ((Button) o).setBounds(reg);
     ((Button) o).addMouseListener(this);
     this.add((Button) o);
   } else if (o instanceof TextArea) {
     ((TextArea) o).setText(value);
     ((TextArea) o).setName(name);
     ((TextArea) o).setBounds(reg);
     ((TextArea) o).addMouseListener(this);
     ((TextArea) o).addTextListener(this);
     ((TextArea) o).addKeyListener(this);
     this.add((TextArea) o);
   } else if (o instanceof Choice) {
     String[] values = value.split(",");
     for (int ii = 0; ii < values.length; ii++) ((Choice) o).addItem(values[ii]);
     ((Choice) o).setName(name);
     ((Choice) o).setBounds(reg);
     ((Choice) o).addMouseListener(this);
     ((Choice) o).addItemListener(this);
     this.add((Choice) o);
   } else if (o instanceof Checkbox) {
     ((Checkbox) o).setLabel(value);
     ((Checkbox) o).setName(name);
     ((Checkbox) o).setBounds(reg);
     ((Checkbox) o).addMouseListener(this);
     ((Checkbox) o).addItemListener(this);
     this.add((Checkbox) o);
   } else if (o instanceof CheckboxGroup) {
     String[] values = value.split(",");
     for (int ii = 0; ii < values.length; ii++) {
       Checkbox chk = new Checkbox();
       chk.setLabel(values[ii]);
       chk.setName(name + ii);
       chk.setBounds(reg);
       reg.y += 25;
       chk.addMouseListener(this);
       chk.addItemListener(this);
       chk.setCheckboxGroup((CheckboxGroup) o);
       this.add(chk);
     }
   } else if (o instanceof List) {
     String[] values = value.split(",");
     ((List) o).setName(name);
     ((List) o).setBounds(reg);
     ((List) o).addMouseListener(this);
     ((List) o).addItemListener(this);
     for (int ii = 0; ii < values.length; ii++) ((List) o).add(values[ii]);
     this.add(((List) o));
   }
 }
예제 #3
0
  public AboutDiaglog() {

    Panel infoPanel = new Panel(new GridLayout(4, 1));

    Label one = new Label("Application development, german translation:");
    Label two = new Label("D4r3T0B3");
    two.setForeground(Color.BLUE);
    two.addMouseListener(
        new MouseListener() {
          @Override
          public void mouseClicked(MouseEvent arg0) {
            try {
              new ProcessBuilder("explorer", "mailto:", "*****@*****.**").start();
            } catch (IOException e) {
              e.printStackTrace();
            }
          }

          @Override
          public void mouseEntered(MouseEvent arg0) {}

          @Override
          public void mouseExited(MouseEvent arg0) {}

          @Override
          public void mouseReleased(MouseEvent arg0) {}

          @Override
          public void mousePressed(MouseEvent arg0) {}
        });
    Label three = new Label("Slovak translation:");
    Label four = new Label("XDA-Developer Member: mGi00");
    four.setForeground(Color.BLUE);
    four.addMouseListener(
        new MouseListener() {
          @Override
          public void mouseClicked(MouseEvent arg0) {
            try {
              new ProcessBuilder(
                      "cmd", "/c", "start", "http://forum.xda-developers.com/member.php?u=2042465")
                  .start();
            } catch (IOException e) {
              e.printStackTrace();
            }
          }

          @Override
          public void mouseEntered(MouseEvent arg0) {}

          @Override
          public void mouseExited(MouseEvent arg0) {}

          @Override
          public void mouseReleased(MouseEvent arg0) {}

          @Override
          public void mousePressed(MouseEvent arg0) {}
        });

    infoPanel.add(one);
    infoPanel.add(two);
    infoPanel.add(three);
    infoPanel.add(four);

    Button ok = new Button("Close");
    ok.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            close();
          }
        });

    this.setLayout(new BorderLayout());
    this.add(infoPanel, BorderLayout.CENTER);
    this.add(ok, BorderLayout.SOUTH);

    this.setSize(300, 200);
    this.setTitle("About - Credits");
    this.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent we) {
            close();
          }
        });
    this.setVisible(true);
  }
예제 #4
0
  public p2() throws Exception {

    // setBorder(BorderFactory.createEtchedBorder(Color.lightGray, Color.DARK_GRAY));
    p = new JPanel();
    // setBackground(Color.white);
    p.setLayout(new GridLayout(11, 3));
    p.setBounds(0, 20, 309, 130);

    un = new JLabel("*  Username");
    ps1 = new JLabel("*  Password");
    ps2 = new JLabel("*  Confirm Password");
    fn = new JLabel("*  First Name");
    ln = new JLabel("   Last Name");
    eid = new JLabel("*  Email ID");
    mb = new JLabel("*  Mobile");
    cct = new JLabel("*  Current City");
    hquali = new JLabel("*  Highest Qualification");
    dob = new JLabel("   DOB");
    dober = new JLabel();
    dd = new JLabel("DD");
    mm = new JLabel("MM");
    yy = new JLabel("YY");
    member = new Label("     already a member?");
    member.addMouseListener(this);

    er1 = new Label("");
    er2 = new Label("");
    er3 = new Label("");
    er4 = new Label("");
    er5 = new Label("");
    er6 = new Label("");
    er7 = new Label("");
    er8 = new Label("");
    er9 = new Label("");
    er10 = new Label("");

    un1 = new JTextField(15);
    ps11 = new JPasswordField(15);
    ps21 = new JPasswordField(15);
    fn1 = new JTextField(15);
    ln1 = new JTextField(15);
    eid1 = new JTextField(15);
    mb1 = new JTextField(15);
    cct1 = new JTextField(15);
    hquali1 = new JTextField(15);
    dober1 = new JTextField(2);
    dober2 = new JTextField(2);
    dober3 = new JTextField(2);

    sub = new JButton("Sign up");
    sub.setBorderPainted(false);
    sub.setFocusable(true);
    sub.addActionListener(this);

    dober.setLayout(new FlowLayout());
    dober.add(dober1);
    dober.add(dd);
    dober.add(dober2);
    dober.add(mm);
    dober.add(dober3);
    dober.add(yy);

    p.add(fn);
    p.add(fn1);
    p.add(er1);
    p.add(ln);
    p.add(ln1);
    p.add(er2);
    p.add(un);
    p.add(un1);
    p.add(er3);
    p.add(ps1);
    p.add(ps11);
    p.add(er4);
    p.add(ps2);
    p.add(ps21);
    p.add(er5);
    p.add(eid);
    p.add(eid1);
    p.add(er6);
    p.add(mb);
    p.add(mb1);
    p.add(er7);
    p.add(cct);
    p.add(cct1);
    p.add(er8);
    p.add(hquali);
    p.add(hquali1);
    p.add(er9);
    p.add(dob);
    p.add(dober);
    p.add(er10);

    p.add(sub);
    p.add(member);
    add(p);
  }