示例#1
52
 /**
  * Show the given message in a dialog box or independent window, depending on whether the source
  * component is contained in a Frame or not.
  *
  * @param c The Controller that calls this method, or null if it is not called by a Controller.
  *     (The Controller, if any, will be notified when the error message is cleared.)
  * @param message The message to display.
  */
 public void setErrorMessage(Controller c, String message) {
   if (popup != null) clearErrorMessage();
   if (message == null) return;
   errorSource = c;
   errorMessage = message;
   Component parent = source;
   while (parent != null && !(parent instanceof Frame)) parent = parent.getParent();
   if (parent != null) popup = new Dialog((Frame) parent, "Error Message", true); // modal dialog
   else popup = new Frame("Error Message"); // independent window
   popup.setBackground(Color.white);
   popup.add(new MC(message), BorderLayout.CENTER);
   Panel buttonBar = new Panel();
   buttonBar.setLayout(new FlowLayout(FlowLayout.RIGHT, 10, 10));
   Button OK = new Button("    OK    ");
   OK.addActionListener(this);
   buttonBar.add(OK);
   popup.add(buttonBar, BorderLayout.SOUTH);
   popup.pack();
   if (parent == null) popup.setLocation(100, 80);
   else popup.setLocation(parent.getLocation().x + 50, parent.getLocation().y + 30);
   popup.addWindowListener(
       new WindowAdapter() {
         public void windowClosing(WindowEvent evt) {
           popup.dispose();
         }
       });
   popup.show(); // make the dialog visible.
 }
示例#2
0
 /**
  * Notify any DialogListeners of changes having occurred If a listener returns false, do not call
  * further listeners and disable the OK button and preview Checkbox (if it exists). For
  * PlugInFilters, this ensures that the PlugInFilterRunner, which listens as the last one, is not
  * called if the PlugInFilter has detected invalid parameters. Thus, unnecessary calling the
  * run(ip) method of the PlugInFilter for preview is avoided in that case.
  */
 private void notifyListeners(AWTEvent e) {
   if (dialogListeners == null) return;
   boolean everythingOk = true;
   for (int i = 0; everythingOk && i < dialogListeners.size(); i++)
     try {
       resetCounters();
       if (!((DialogListener) dialogListeners.elementAt(i)).dialogItemChanged(this, e))
         everythingOk = false;
     } // disable further listeners if false (invalid parameters) returned
     catch (Exception err) { // for exceptions, don't cover the input by a window but
       IJ.beep(); // show them at in the "Log"
       IJ.log(
           "ERROR: "
               + err
               + "\nin DialogListener of "
               + dialogListeners.elementAt(i)
               + "\nat "
               + (err.getStackTrace()[0])
               + "\nfrom "
               + (err.getStackTrace()[1])); // requires Java 1.4
     }
   boolean workaroundOSXbug = IJ.isMacOSX() && okay != null && !okay.isEnabled() && everythingOk;
   if (previewCheckbox != null) previewCheckbox.setEnabled(everythingOk);
   if (okay != null) okay.setEnabled(everythingOk);
   if (workaroundOSXbug) repaint(); // OSX 10.4 bug delays update of enabled until the next input
 }
示例#3
0
  public void addClient() {
    client =
        new Canvas() {
          public void paint(Graphics g) {
            super.paint(g);
          }
        };
    client.setBackground(new Color(30, 220, 40));
    clientCont.add(client);
    clientCont.validate();
    final ComponentAccessor acc = AWTAccessor.getComponentAccessor();
    WindowIDProvider pid = (WindowIDProvider) acc.getPeer(client);
    log.fine("Added XEmbed server(Canvas) with X window ID " + pid.getWindow());
    Rectangle toFocusBounds = toFocus.getBounds();
    toFocusBounds.setLocation(toFocus.getLocationOnScreen());
    f.validate();

    // KDE doesn't accept clicks on title as activation - click below title
    Rectangle fbounds = f.getBounds();
    fbounds.y += f.getInsets().top;
    fbounds.height -= f.getInsets().top;

    Process proc =
        startClient(
            new Rectangle[] {
              fbounds,
              dummy.getBounds(),
              toFocusBounds,
              new Rectangle(b_modal.getLocationOnScreen(), b_modal.getSize()),
              new Rectangle(10, 130, 20, 20)
            },
            pid.getWindow());
    new ClientWatcher(client, proc, clientCont).start();
  }
示例#4
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;
  }
  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();
      }
    }
  }
示例#6
0
  // 생성자
  public OuterEventClass() {
    InnerEventClass IEC;

    // Layout manager설정
    setLayout(new BorderLayout());
    // 윈도우 창 닫기 이벤트를 자기자신의 객체에 붙여버림
    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent we) {
            System.exit(0);
          }
        });

    but1 = new Button("왼쪽 버튼");
    but2 = new Button("아래쪽 버튼");
    txtA = new TextArea();

    // inner 클래스 인스턴스
    IEC = new InnerEventClass();

    // 버튼에 감지 기능 추가
    but1.addActionListener(IEC);
    but2.addActionListener(IEC);

    // 프레임에 버튼 추가
    add("North", but1);
    add("South", but2);
    add("Center", txtA);
  }
示例#7
0
  void action() {
    Panel p = new Panel();

    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent we) {
            System.exit(0);
          }
        });

    but1 = new Button("버튼-1");
    but2 = new Button("버튼-2");

    // 버튼에 감지 기능 추가
    but1.addActionListener(this);
    but2.addActionListener(this);

    p.add(but1);
    p.add(but2);

    add(p, "North");

    tf = new TextField();
    add(tf, "South");
    setSize(150, 100);
    setVisible(true);
  }
示例#8
0
 public void init() {
   add(t);
   start.addActionListener(new StartL());
   add(start);
   onOff.addActionListener(new OnOffL());
   add(onOff);
 }
示例#9
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);
  }
示例#10
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);
  }
示例#11
0
    // 이벤트 발생시 동작되는 메소드
    public void actionPerformed(ActionEvent e) {
      // 객체의 소스를 얻어와 버튼 객체화 시킴
      Button but = (Button) e.getSource();
      String lab = but.getLabel();

      if (lab.equals("왼쪽 버튼")) txtA.setText(txtA.getText() + " 왼쪽 버튼이 눌렸어요" + "\n");
      else txtA.setText(txtA.getText() + " 아래쪽 버튼이 눌렸어요" + "\n");
    }
示例#12
0
  public void init() {
    colorNo = 0;
    Button b = new Button("change");
    b.addActionListener(this);
    add(b);

    addMouseListener(this);
  }
示例#13
0
 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);
 }
示例#14
0
 private void startGame() {
   timer.setDelay(INITIAL_DELAY);
   timer.setPaused(false);
   start_newgame_butt.setLabel("Start New Game");
   pause_resume_butt.setEnabled(true);
   pause_resume_butt.setLabel("Pause");
   pause_resume_butt.validate();
   sounds.playSoundtrack();
 }
 public void init() {
   a = new TextArea("", 15, 50);
   add(a);
   Button t = new Button("Translate");
   add(t);
   b = new TextArea("", 15, 50);
   add(b);
   t.addActionListener(this);
 }
示例#16
0
 public static void main(String[] args) {
   Frame f = new Frame("Test");
   Button b = new Button("Press me!");
   Monitor bh = new Monitor();
   b.addActionListener(bh);
   f.add(b, BorderLayout.CENTER);
   f.pack();
   f.setVisible(true);
 }
示例#17
0
  // Label lyes,lno;
  public void init() {
    byes = new Button("Yes");
    bno = new Button("No");
    add(byes);
    add(bno);

    bno.addActionListener(this);
    byes.addActionListener(this);
  }
示例#18
0
 public SimpleCapture() {
   super("Simple Capture Program");
   add(stopButton = new Button("Stop"), BorderLayout.WEST);
   stopButton.addActionListener(this);
   add(quitButton = new Button("Quit"), BorderLayout.EAST);
   quitButton.addActionListener(this);
   pack();
   setVisible(true);
 }
示例#19
0
 MyF2() {
   Frame f = new Frame("graphics");
   Button b = new Button("line");
   f.add(m);
   f.add(b);
   b.addActionListener(this);
   f.setSize(400, 400);
   f.setLayout(new GridLayout(2, 1));
   f.setVisible(true);
 }
示例#20
0
 public void init() {
   tekstvak = new TextField("", 30);
   knop = new Button("Ok");
   knop2 = new Button("Reset");
   knop.addActionListener(new KnopListener2());
   knop2.addActionListener(new KnopListener());
   add(tekstvak);
   add(knop);
   add(knop2);
 }
示例#21
0
  /**
   * 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);
  }
  // Color gre;
  Rules(String se) {
    email = se;
    conti = new Button("Continue");
    rules = new Button("ClicK Here For Rules");
    p1 = new JOptionPane();
    Icon image = new ImageIcon("books.jpg");
    Icon image1 = new ImageIcon("girl.jpg");
    Icon image2 = new ImageIcon("uit.jpg");
    gl = new GridBagLayout();
    gbc = new GridBagConstraints();
    conti.addActionListener(this);
    rules.addActionListener(this);
    // gre=new Color(117,102,185);
    p = new Panel();
    p2 = new Panel();
    p3 = new Panel();
    p4 = new Panel();
    f = new Frame();
    pic = new JLabel(image);
    pic1 = new JLabel(image1);
    pic2 = new JLabel(image2);
    gbc.anchor = GridBagConstraints.SOUTHWEST;
    gl.setConstraints(pic1, gbc);
    gbc.anchor = GridBagConstraints.SOUTHEAST;
    gl.setConstraints(pic, gbc);
    Insets is = new Insets(30, 30, 30, 30);
    gbc.insets = is;
    gbc.ipadx = 14;
    gbc.ipady = 8;
    gl.setConstraints(rules, gbc);
    gl.setConstraints(conti, gbc);
    p2.setLayout(gl);
    p4.add(pic2);
    p2.add(pic);
    p3.setLayout(gl);
    p3.add(pic1);
    p.add(conti);
    p.add(rules);
    p.setLayout(gl);
    f.add(p4, "North");
    f.add(p3, "East");
    f.add(p2, "West");

    f.add(p, "Center");
    f.setTitle("RULES BOOK");
    // f.setBackground(gre);
    f.setVisible(true);
    f.setSize(900, 600);
    f.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent we) {
            System.exit(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();
  }
示例#24
0
  /** This method performs actions in response to the drinks display button being pressed. */
  public void actionPerformed(ActionEvent e) {
    Button btn;
    String cmd;
    int idx;

    btn = (Button) e.getSource();
    cmd = btn.getActionCommand();
    idx = Integer.parseInt(cmd);

    mCtrl.displayDrinks(idx);
  }
 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);
   }
 }
示例#26
0
文件: Life.java 项目: dragon66/icafe
 public void actionPerformed(ActionEvent e) {
   firstTime = false;
   if (e.getSource().equals(start)) {
     if (t != null) {
       stop();
       start.setLabel("START");
     } else {
       start();
       start.setLabel("STOP");
     }
   }
 }
示例#27
0
文件: Newt.java 项目: xrisjc/newt
    public FractalGeneratorSettingsDialog() {
      super(Newt.this);
      setTitle(DIALOG_TITLE);
      setModal(false);
      setSize(DIALOG_WIDTH, DIALOG_HEIGHT);
      setLayout(new BorderLayout());
      addWindowListener(new DialogEventHandler());

      // create a panel with <Set> and <Close> buttons and add
      // it to the "South" of the dialog box.
      Panel p = new Panel(new FlowLayout());
      Button b = new Button(SET_BUTTON_TEXT);
      b.addActionListener(this);
      p.add(b);

      b = new Button(CLOSE_BUTTON_TEXT);
      b.addActionListener(this);
      p.add(b);
      add("South", p);

      // create a panel for the text fields with a grid layout
      p = new Panel(new GridLayout(5, 2));

      p.add(new Label(MAXITR_LABEL_TEXT, LABEL_ALIGNMENT));
      tfMaxItr = new TextField(fractalGenerator.getMaxItr() + "");
      tfMaxItr.addActionListener(this);
      p.add(tfMaxItr);

      p.add(new Label(MINX_LABEL_TEXT, LABEL_ALIGNMENT));
      tfMinX = new TextField(fractalGenerator.getMinX() + "");
      tfMinX.addActionListener(this);
      p.add(tfMinX);

      p.add(new Label(MAXX_LABEL_TEXT, LABEL_ALIGNMENT));
      tfMaxX = new TextField(fractalGenerator.getMaxX() + "");
      tfMaxX.addActionListener(this);
      p.add(tfMaxX);

      p.add(new Label(MINY_LABEL_TEXT, LABEL_ALIGNMENT));
      tfMinY = new TextField(fractalGenerator.getMinY() + "");
      tfMinY.addActionListener(this);
      p.add(tfMinY);

      p.add(new Label(MAXY_LABEL_TEXT, LABEL_ALIGNMENT));
      tfMaxY = new TextField(fractalGenerator.getMaxY() + "");
      tfMaxY.addActionListener(this);
      p.add(tfMaxY);

      add("Center", p);

      // Everything's ready, show the dialog box.
      setVisible(true);
    }
 //
 // Constructor.
 //
 public ReloginPanel(VncViewer v) {
   viewer = v;
   setLayout(new FlowLayout(FlowLayout.CENTER));
   reloginButton = new Button("Login again");
   add(reloginButton);
   reloginButton.addActionListener(this);
   if (viewer.inSeparateFrame) {
     closeButton = new Button("Close window");
     add(closeButton);
     closeButton.addActionListener(this);
   }
 }
示例#29
0
 public ToeTestNew() {
   setTitle("Toe Test");
   Panel p = new Panel();
   p.setLayout(new GridLayout(2, 2));
   p.add(new Label("Rows", Label.CENTER));
   p.add(rows);
   p.add(new Label("Columns", Label.CENTER));
   p.add(cols);
   add(p, BorderLayout.NORTH);
   Button b = new Button("go");
   b.addActionListener(new BL());
   add(b, BorderLayout.SOUTH);
 }
示例#30
0
  public RoundedRectTestFrame() {
    super("RoundedRectTest");
    canvas = new PrintCanvas();
    add("Center", canvas);

    Button b = new Button("Print");
    b.setActionCommand("print");
    b.addActionListener(this);
    add("South", b);

    pack();
    setVisible(true);
  }