Exemple #1
0
  public D(String title) {
    super(title);
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    int frameWidth = 410;
    int frameHeight = 319;
    setSize(frameWidth, frameHeight);
    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
    int x = (d.width - getSize().width) / 2;
    int y = (d.height - getSize().height) / 2;
    setLocation(x, y);
    setResizable(false);
    Container cp = getContentPane();
    cp.setLayout(null);

    label1.setBounds(8, 8, 275, 76);
    label1.setText("Würfel");
    label1.setAlignment(Label.CENTER);
    label1.setFont(new Font("Dialog", Font.PLAIN, 60));
    cp.add(label1);
    l_1.setBounds(8, 88, 275, 145);
    l_1.setText("");
    l_1.setAlignment(Label.CENTER);
    l_1.setFont(new Font("Dialog", Font.PLAIN, 100));

    cp.add(l_1);
    b_1.setBounds(8, 248, 275, 25);
    b_1.setLabel("Würfeln");
    b_1.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            b_1_ActionPerformed(evt);
          }
        });
    cp.add(b_1);
    tf_von.setBounds(336, 80, 49, 25);
    cp.add(tf_von);
    tf_bis.setBounds(336, 120, 49, 25);
    cp.add(tf_bis);
    l_von.setBounds(296, 80, 35, 25);
    l_von.setText("Von:");
    cp.add(l_von);
    l_bis.setBounds(296, 120, 35, 25);
    l_bis.setText("Bis:");
    cp.add(l_bis);
    b_a.setBounds(296, 160, 89, 49);
    b_a.setLabel("Annehmen");
    b_a.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            b_a_ActionPerformed(evt);
          }
        });
    cp.add(b_a);

    setVisible(true);
  }
Exemple #2
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);
          }
        });
  }
Exemple #4
0
 /**
  * Called by the browser or applet viewer to inform this JApplet that it has been loaded into the
  * system. It is always called before the first time that the start method is called.
  */
 public void init() {
   // this is a workaround for a security conflict with some browsers
   // including some versions of Netscape & Internet Explorer which do
   // not allow access to the AWT system event queue which JApplets do
   // on startup to check access. May not be necessary with your browser.
   JRootPane rootPane = this.getRootPane();
   rootPane.putClientProperty("defeatSystemEventQueueCheck", Boolean.TRUE);
   setLayout(new FlowLayout(FlowLayout.CENTER, 10, 10));
   b1 = new Button("Choose this card");
   add(b1);
   b1.addActionListener(this);
   // provide any initialisation necessary for your JApplet
 }
Exemple #5
0
 public void init() {
   Panel p = new Panel();
   p.add(btCopy);
   p.add(btPaste);
   btCopy.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent event) {
           // 将一个多行文本域里的字符串封装成StringSelection对象
           StringSelection contents = new StringSelection(jtaCopyTo.getText());
           // 将StringSelection对象放入剪贴板
           clipboard.setContents(contents, null);
         }
       });
   btPaste.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent event) {
           // 如果剪贴板中包含stringFlavor内容
           if (clipboard.isDataFlavorAvailable(DataFlavor.stringFlavor)) {
             try {
               // 取出剪贴板中stringFlavor内容
               String content = (String) clipboard.getData(DataFlavor.stringFlavor);
               jtaPaste.append(content);
             } catch (Exception e) {
               e.printStackTrace();
             }
           }
         }
       });
   // 创建一个水平排列的Box容器
   Box box = new Box(BoxLayout.X_AXIS);
   // 将两个多行文本域放在Box容器中
   box.add(jtaCopyTo);
   box.add(jtaPaste);
   // 将按钮所在Panel、Box容器添加到Frame窗口中
   f.add(p, BorderLayout.SOUTH);
   f.add(box, BorderLayout.CENTER);
   f.pack();
   f.setVisible(true);
 }
Exemple #6
0
  Board() {
    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            exit();
          }
        });
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    setSize(screenSize);
    setLocation(0, 0);
    r3 = Math.sqrt(3);
    Button ng, eg, ab;
    ng = new Button("New Game");
    eg = new Button("Exit Game");
    ab = new Button("About");
    gold = new ImageIcon("./coin2.jpg").getImage();
    silver = new ImageIcon("./coin1.jpg").getImage();
    Panel pan = new Panel();
    pan.setLayout(new FlowLayout());
    pan.add(ng);
    pan.add(eg);
    pan.add(ab);
    setLayout(new BorderLayout());
    add(pan, BorderLayout.NORTH);

    newGame();
    ng.addActionListener(this);
    eg.addActionListener(this);
    ab.addActionListener(this);

    addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            int mx = e.getX(), my = e.getY();
            place(mx, my);
          }
        });
  }
Exemple #7
0
  public Deta_Ventas_r() {
    setBackground(Color.gray);
    setLayout(null);
    setSize(400, 400);
    l1 = new Label(" clave ");
    t1 = new TextField(36);
    l2 = new Label("Vendedor");
    t2 = new TextField(20);

    l3 = new Label("Cliente");
    t3 = new TextField(20);
    l4 = new Label("Fechas");
    t4 = new TextField(5);
    l5 = new Label("monto_final");
    t5 = new TextField(5);
    t4.setEditable(false);
    t5.setEditable(false);
    b = new Button("Registrar");
    add(l1);
    add(t1);
    add(l2);
    add(t2);
    add(l3);
    add(t3);
    add(l4);
    add(t4);
    add(l5);
    add(t5);
    add(b);
    l1.setBounds(24, 75, 71, 23);
    l2.setBounds(24, 103, 90, 23);
    l3.setBounds(24, 131, 90, 23);
    l4.setBounds(24, 159, 90, 23);
    l5.setBounds(24, 185, 90, 23);
    t1.setBounds(114, 75, 270, 23);
    t2.setBounds(114, 103, 270, 23);
    t3.setBounds(114, 131, 270, 23);
    t4.setBounds(114, 159, 270, 23);
    t5.setBounds(114, 185, 270, 23);
    b.setBounds(167, 215, 65, 23);
    b.addActionListener(this);
    setUndecorated(true);
    setLocation((Toolkit.getDefaultToolkit().getScreenSize().width / 2) - 200, 50);
    start();
  }
 /** Component initialization */
 private void jbInit() throws Exception {
   contentPane = (JPanel) this.getContentPane();
   contentPane.setLayout(bd);
   ThreadPanel tp1 = new ThreadPanel("Passengers", Color.blue);
   ThreadPanel tp2 = new ThreadPanel("Car(2)", Color.blue);
   ThreadPanel tp3 = new ThreadPanel("Car(3)", Color.blue);
   NumberCanvas nc1 = new NumberCanvas("Platform");
   NumberCanvas nc2 = new NumberCanvas("In Car(2)");
   NumberCanvas nc3 = new NumberCanvas("In Car(3)");
   Panel p1 = new Panel();
   p1.setLayout(new BorderLayout());
   Panel p2 = new Panel();
   p2.setLayout(new BorderLayout());
   Panel p3 = new Panel();
   p3.setLayout(new BorderLayout());
   p1.add(nc1, BorderLayout.CENTER);
   p1.add(tp1, BorderLayout.SOUTH);
   p2.add(nc2, BorderLayout.CENTER);
   p2.add(tp2, BorderLayout.SOUTH);
   p3.add(nc3, BorderLayout.CENTER);
   p3.add(tp3, BorderLayout.SOUTH);
   Panel grid = new Panel();
   grid.setLayout(new GridLayout(1, 3));
   grid.add(p1);
   grid.add(p2);
   grid.add(p3);
   contentPane.add(grid, BorderLayout.CENTER);
   // construct threads, monitor & go button
   final Controller c = new Controller(nc1);
   final PlatformAccess pa = new PlatformAccess();
   Button go = new Button("Go Now");
   go.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           c.goNow();
         }
       });
   contentPane.add(go, BorderLayout.SOUTH);
   tp1.start(new Passengers(c));
   tp2.start(new CoasterCar(2, c, pa, nc2));
   tp3.start(new CoasterCar(3, c, pa, nc3));
   this.setSize(new Dimension(470, 350));
   this.setTitle("Roller Coaster Laboratory Exercise");
 }
Exemple #9
0
 public LoginScreen(final Home hm) {
   setSize(600, 550);
   setLayout(null);
   this.hm = hm;
   name = new Label("Username : "******"Password :"******"login");
   login.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           try {
             if (isValidUser()) {
               hm.removeAll();
               hm.userId = nameText.getText();
               hm.p2 = new BaseApplet(hm);
               hm.p2.setBounds(0, 50, 600, 550);
               hm.add(hm.p2);
               hm.revalidate();
             } else {
               JOptionPane.showMessageDialog(
                   null, "Invalid Credentials", "Alert", JOptionPane.OK_OPTION);
             }
           } catch (Exception e1) {
             System.out.println("Error");
           }
         }
       });
   login.setBounds(200, 150, 100, 30);
   add(login);
 }
Exemple #10
0
  void launch() {
    f.setSize(800, 800);
    p.setLayout(null);

    l1.setBounds(600, 10, 150, 36);

    l2.setBounds(100, 30, 400, 70);
    l13.setBounds(2, 90, 1200, 20);

    l14.setBounds(80, 150, 250, 30);
    t1.setBounds(330, 150, 150, 30);
    b1.setBounds(500, 150, 100, 30);
    l15.setBounds(2, 200, 1200, 20);

    b6.setBounds(600, 50, 100, 30);
    l3.setBounds(100, 250, 100, 30);
    t2.setBounds(300, 250, 150, 30);
    l4.setBounds(100, 300, 150, 30);
    t3.setBounds(300, 300, 150, 30);
    l5.setBounds(100, 350, 150, 30);
    t4.setBounds(300, 350, 150, 30);
    l6.setBounds(100, 400, 100, 30);
    t5.setBounds(300, 400, 150, 30);
    l7.setBounds(100, 450, 100, 30);
    c1.setBounds(300, 450, 60, 30);
    c2.setBounds(400, 450, 60, 30);
    l8.setBounds(100, 500, 100, 30);
    t6.setBounds(300, 500, 150, 30);
    l9.setBounds(100, 550, 100, 30);
    t7.setBounds(300, 550, 150, 30);
    l10.setBounds(100, 600, 120, 30);
    t8.setBounds(300, 600, 150, 30);

    l11.setBounds(100, 650, 100, 30);
    t9.setBounds(300, 650, 150, 30);
    l12.setBounds(100, 700, 150, 30);
    t10.setBounds(300, 700, 150, 30);
    b2.setBounds(500, 400, 100, 30);
    b3.setBounds(500, 500, 100, 30);
    b4.setBounds(500, 600, 100, 30);
    b5.setBounds(650, 150, 100, 30);

    b1.addActionListener(this);
    b2.addActionListener(this);
    b3.addActionListener(this);
    b4.addActionListener(this);
    b5.addActionListener(this);
    b6.addActionListener(this);
    c1.addItemListener(this);
    c2.addItemListener(this);

    p.add(l1);
    p.add(l2);
    p.add(l13);
    p.add(l14);
    p.add(t1);
    p.add(b1);
    p.add(l15);
    p.add(b5);
    p.add(b6);

    f.add(p);

    f.setVisible(true);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  }
Exemple #11
0
 /**
  * Registriert einen ActionListener; Action-Events kommen, wenn sich der Wert des ParamFieldes
  * aendert
  */
 public void addActionListener(ActionListener list) {
   actionComponent.addActionListener(list);
 }
  public TestXEmbedServer(boolean manual) {

    // Enable testing extensions in XEmbed server
    System.setProperty("sun.awt.xembed.testing", "true");

    f = new Frame("Main frame");
    f.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            synchronized (TestXEmbedServer.this) {
              TestXEmbedServer.this.notifyAll();
            }
            dummy.dispose();
            f.dispose();
          }
        });

    f.setLayout(new BorderLayout());

    Container bcont = new Container();

    toFocus = new Button("Click to focus server");
    final TextField tf = new TextField(20);
    tf.setName("0");
    DragSource ds = new DragSource();
    final DragSourceListener dsl =
        new DragSourceAdapter() {
          public void dragDropEnd(DragSourceDropEvent dsde) {}
        };
    final DragGestureListener dgl =
        new DragGestureListener() {
          public void dragGestureRecognized(DragGestureEvent dge) {
            dge.startDrag(null, new StringSelection(tf.getText()), dsl);
          }
        };
    ds.createDefaultDragGestureRecognizer(tf, DnDConstants.ACTION_COPY, dgl);

    final DropTargetListener dtl =
        new DropTargetAdapter() {
          public void drop(DropTargetDropEvent dtde) {
            dtde.acceptDrop(DnDConstants.ACTION_COPY);
            try {
              tf.setText(
                  tf.getText()
                      + (String) dtde.getTransferable().getTransferData(DataFlavor.stringFlavor));
            } catch (Exception e) {
            }
          }
        };
    final DropTarget dt = new DropTarget(tf, dtl);

    Button b_add = new Button("Add client");
    b_add.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            addClient();
          }
        });
    Button b_remove = new Button("Remove client");
    b_remove.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (clientCont.getComponentCount() != 0) {
              clientCont.remove(clientCont.getComponentCount() - 1);
            }
          }
        });
    b_close = new JButton("Close modal dialog");
    b_close.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            modal_d.dispose();
          }
        });
    b_modal = new Button("Show modal dialog");
    b_modal.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            modal_d = new JDialog(f, "Modal dialog", true);
            modal_d.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
            modal_d.setBounds(0, 100, 200, 50);
            modal_d.getContentPane().add(b_close);
            modal_d.validate();
            modal_d.show();
          }
        });

    bcont.add(tf);
    bcont.add(toFocus);
    bcont.add(b_add);
    bcont.add(b_remove);
    bcont.add(b_modal);
    if (manual) {
      Button pass = new Button("Pass");
      pass.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              passed = true;
              synchronized (TestXEmbedServer.this) {
                TestXEmbedServer.this.notifyAll();
              }
            }
          });
      bcont.add(pass);
      Button fail = new Button("Fail");
      fail.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              passed = false;
              synchronized (TestXEmbedServer.this) {
                TestXEmbedServer.this.notifyAll();
              }
            }
          });
      bcont.add(fail);
    }
    b_modal.setName("2");
    bcont.setLayout(new FlowLayout());
    f.add(bcont, BorderLayout.NORTH);

    clientCont = Box.createVerticalBox();
    f.add(clientCont, BorderLayout.CENTER);

    dummy = new JFrame("Dummy");
    dummy.getContentPane().add(new JButton("Button"));
    dummy.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    dummy.setBounds(0, VERTICAL_POSITION, 100, 100);
    dummy.setVisible(true);

    f.setBounds(300, VERTICAL_POSITION, 800, 300);
    f.setVisible(true);
  }
Exemple #13
0
  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
  }
Exemple #14
0
  /** @param args */
  public static void main(String[] args) {
    JPanel boxPane = new JPanel(new BorderLayout());
    // boxPane.setLayout(new BoxLayout(boxPane, BoxLayout.LINE_AXIS));
    // boxPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
    // boxPane.add(Box.createVerticalGlue());
    Example1 ex = new Example1();
    // boxPane.add(ex);

    boxPane.add(Box.createRigidArea(new Dimension(10, 0)));
    Button btnStartStop = new Button("Start / Stop");
    btnStartStop.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent event) {
            log.info("Suspending / Resuming the simulation thread, current state = " + helper.stop);
            if (helper.stop == true) helper.unpause();
            else helper.pause();
          }
        });
    // btnStartStop.setMaximumSize(new Dimension(100, 100));
    boxPane.add(btnStartStop, BorderLayout.PAGE_START);

    JScrollPane worldScrollPane = new JScrollPane(ex);

    final JSplitPane splitPane =
        new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, worldScrollPane, boxPane);
    splitPane.setResizeWeight(0.5);
    splitPane.setOneTouchExpandable(true);
    splitPane.setContinuousLayout(true);

    worldScrollPane.addAncestorListener(
        new AncestorListener() {
          @Override
          public void ancestorRemoved(AncestorEvent arg0) {
            splitPane.repaint();
          }

          @Override
          public void ancestorMoved(AncestorEvent arg0) {
            splitPane.repaint();
          }

          @Override
          public void ancestorAdded(AncestorEvent arg0) {
            splitPane.repaint();
          }
        });

    JFrame f = new JFrame();
    f.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });
    f.add(splitPane, BorderLayout.CENTER);
    // f.add(boxPane);
    f.pack();
    f.setVisible(true);

    helper = new SimulationHelper(ex.getGraphics());

    helper.start();

    // layeredPane.setBorder(BorderFactory.createTitledBorder("Move the Mouse to Move Duke"));

  }
  void init(String[] names1, float[][][] pch1, int psfflag1) {
    setLayout(null);
    names = names1;
    pch = pch1;
    psfflag = psfflag1;
    ncurves = pch.length;
    nparams = 11;
    xpts = pch[0].length;
    ypts = pch[0][0].length;

    checkarray = new Checkbox[ncurves];
    include = new boolean[ncurves];
    namearray = new TextField[ncurves + 1];
    int1array = new TextField[ncurves + 1];
    intensity1 = new double[ncurves + 1];
    e1array = new TextField[ncurves + 1];
    n1array = new TextField[ncurves + 1];
    bright1 = new double[ncurves + 1];
    number1 = new double[ncurves + 1];
    int2array = new TextField[ncurves + 1];
    intensity2 = new double[ncurves + 1];
    e2array = new TextField[ncurves + 1];
    n2array = new TextField[ncurves + 1];
    bright2 = new double[ncurves + 1];
    number2 = new double[ncurves + 1];
    eccarray = new TextField[ncurves + 1];
    brightcc = new double[ncurves + 1];
    eminccarray = new TextField[ncurves + 1];
    brightmincc = new double[ncurves + 1];
    c2array = new TextField[ncurves + 1];
    c2 = new double[ncurves + 1];
    nmeas = new int[ncurves + 1];
    avg = new float[xpts][ypts];
    indices = new int[ncurves];
    beta = 0.05;

    getintbright();
    for (int i = 0; i < ncurves; i++) {
      include[i] = true;
      indices[i] = i;
    }
    updateavg();

    int starty = 60;
    int startx = 10;
    int yinc = 25;
    for (int i = 0; i <= ncurves; i++) {
      if (i != ncurves) {
        checkarray[i] = new Checkbox("", include[i]);
        checkarray[i].setBounds(startx, starty + i * yinc, 20, 20);
        checkarray[i].addItemListener(this);
        add(checkarray[i]);
      }

      namearray[i] = new TextField(names[i]);
      namearray[i].setBounds(startx + 30, starty + i * yinc, 200, 20);
      add(namearray[i]);

      int1array[i] = new TextField("" + (float) intensity1[i]);
      int1array[i].setBounds(startx + 30 + 210, starty + i * yinc, 40, 20);
      add(int1array[i]);

      e1array[i] = new TextField("" + (float) bright1[i]);
      e1array[i].setBounds(startx + 30 + 210 + 50, starty + i * yinc, 40, 20);
      add(e1array[i]);

      n1array[i] = new TextField("" + (float) number1[i]);
      n1array[i].setBounds(startx + 30 + 210 + 50 + 50, starty + i * yinc, 40, 20);
      add(n1array[i]);

      int2array[i] = new TextField("" + (float) intensity2[i]);
      int2array[i].setBounds(startx + 30 + 210 + 50 + 50 + 50, starty + i * yinc, 40, 20);
      add(int2array[i]);

      e2array[i] = new TextField("" + (float) bright2[i]);
      e2array[i].setBounds(startx + 30 + 210 + 50 + 50 + 50 + 50, starty + i * yinc, 40, 20);
      add(e2array[i]);

      n2array[i] = new TextField("" + (float) number2[i]);
      n2array[i].setBounds(startx + 30 + 210 + 50 + 50 + 50 + 50 + 50, starty + i * yinc, 40, 20);
      add(n2array[i]);

      eccarray[i] = new TextField("" + (float) brightcc[i]);
      eccarray[i].setBounds(
          startx + 30 + 210 + 50 + 50 + 50 + 50 + 50 + 50, starty + i * yinc, 40, 20);
      add(eccarray[i]);

      eminccarray[i] = new TextField("" + (float) brightmincc[i]);
      eminccarray[i].setBounds(
          startx + 30 + 210 + 50 + 50 + 50 + 50 + 50 + 50 + 50, starty + i * yinc, 40, 20);
      add(eminccarray[i]);

      c2[i] = 0.0;
      c2array[i] = new TextField("" + (float) c2[i]);
      c2array[i].setBounds(
          startx + 30 + 210 + 50 + 50 + 50 + 50 + 50 + 50 + 50 + 50, starty + i * yinc, 80, 20);
      add(c2array[i]);
    }

    namelabel = new Label("Filename");
    namelabel.setBounds(startx + 30, starty - 25, 100, 20);
    add(namelabel);

    intlabel = new Label("<Ig>");
    intlabel.setBounds(startx + 30 + 210, starty - 25, 40, 20);
    add(intlabel);

    brightlabel = new Label("<eg>");
    brightlabel.setBounds(startx + 30 + 210 + 50, starty - 25, 40, 20);
    add(brightlabel);

    nlabel = new Label("<Ng>");
    nlabel.setBounds(startx + 30 + 210 + 50 + 50, starty - 25, 40, 20);
    add(nlabel);

    int2label = new Label("<Ir>");
    int2label.setBounds(startx + 30 + 210 + 50 + 50 + 50, starty - 25, 40, 20);
    add(int2label);

    bright2label = new Label("<er>");
    bright2label.setBounds(startx + 30 + 210 + 50 + 50 + 50 + 50, starty - 25, 40, 20);
    add(bright2label);

    n2label = new Label("<Nr>");
    n2label.setBounds(startx + 30 + 210 + 50 + 50 + 50 + 50 + 50, starty - 25, 40, 20);
    add(n2label);

    brightcclabel = new Label("<ecc>");
    brightcclabel.setBounds(startx + 30 + 210 + 50 + 50 + 50 + 50 + 50 + 50, starty - 25, 40, 20);
    add(brightcclabel);

    brightccminlabel = new Label("min");
    brightccminlabel.setBounds(
        startx + 30 + 210 + 50 + 50 + 50 + 50 + 50 + 50 + 50, starty - 25, 40, 20);
    add(brightccminlabel);

    c2label = new Label("chi^2");
    c2label.setBounds(
        startx + 30 + 210 + 50 + 50 + 50 + 50 + 50 + 50 + 50 + 50, starty - 25, 80, 20);
    add(c2label);

    int buttonsx = startx + 30 + 210 + 50 + 50 + 50 + 50 + 50 + 50 + 50 + 50 + 90;

    fitavgbutton = new Button("Fit Avg");
    fitavgbutton.setBounds(buttonsx, starty - 25, 100, 40);
    fitavgbutton.addActionListener(this);
    add(fitavgbutton);

    fitglobalbutton = new Button("Fit Global");
    fitglobalbutton.setBounds(buttonsx, starty - 25 + 50, 100, 40);
    fitglobalbutton.addActionListener(this);
    add(fitglobalbutton);

    clearparamsbutton = new Button("Reset Fit Params");
    clearparamsbutton.setBounds(buttonsx, starty - 25 + 50 + 50, 100, 40);
    clearparamsbutton.addActionListener(this);
    add(clearparamsbutton);

    checkc2 = false;

    fitclass = new NLLSfit(this, 0.0001, 50, 0.1);
    globalfitclass = new NLLSglobalfit(this, 0.0001, 50, 0.1);
    pchfunc = new pch2D((int) ((double) xpts * 1.5), (int) ((double) ypts * 1.5), psfflag);
    avgfit = new float[xpts][ypts];
    fit = new float[ncurves][xpts][ypts];

    xvals = new float[ncurves][xpts][ypts];
    for (int i = 0; i < ncurves; i++) {
      for (int j = 0; j < xpts; j++) {
        for (int k = 0; k < ypts; k++) {
          xvals[i][j][k] = (float) k;
          fit[i][j][k] = 1.0f;
        }
      }
    }

    globalc2label = new Label("Global chi^2 = " + (float) 0.0);
    globalc2label.setBounds(buttonsx, starty - 25 + 50 + 50 + 50, 140, 20);
    add(globalc2label);

    dispcurvelabel = new Label("Display Fit #");
    dispcurvelabel.setBounds(buttonsx, starty - 25 + 50 + 50 + 50 + 30, 70, 20);
    add(dispcurvelabel);

    dispcurvechoice = new Choice();
    for (int i = 0; i < ncurves; i++) {
      dispcurvechoice.add("" + (i + 1));
    }
    dispcurve = 0;
    dispcurvechoice.select(0);
    dispcurvechoice.setBounds(buttonsx + 80, starty - 25 + 50 + 50 + 50 + 30, 40, 20);
    dispcurvechoice.addItemListener(this);
    add(dispcurvechoice);

    betalabel = new Label("Bleedthrough f");
    betalabel.setBounds(buttonsx, starty - 25 + 50 + 50 + 50 + 30 + 30, 100, 20);
    add(betalabel);
    betaval = new TextField("" + (float) beta);
    betaval.setBounds(buttonsx + 110, starty - 25 + 50 + 50 + 50 + 30 + 30, 40, 20);
    betaval.addActionListener(this);
    add(betaval);

    beta = Double.parseDouble(betaval.getText());
    updatebeta();

    undobutton = new Button("Undo Global Fit");
    undobutton.setBounds(buttonsx, starty - 25 + 50 + 50 + 50 + 30 + 30 + 50, 100, 40);
    undobutton.addActionListener(this);
    add(undobutton);

    geterrorsbutton = new Button("Get Errors");
    geterrorsbutton.setBounds(buttonsx, starty - 25 + 50 + 50 + 50 + 30 + 30 + 50 + 50, 100, 40);
    geterrorsbutton.addActionListener(this);
    add(geterrorsbutton);

    copylabel = new Label("copyright 2009 Jay Unruh ([email protected]) non-profit use only");
    copylabel.setBounds(10, 790, 400, 20);
    add(copylabel);

    n_b_label = new Label("N and B Analysis");
    n_b_label.setBounds(250, 10, 100, 20);
    add(n_b_label);

    pwavg = new PlotWindow3D("Avg", "kg", "kr", "Frequency", avg, 0);
    pwavg.setLogAxes(false, false, true);
    pwavg.draw();
    pwavg.addPoints(avgfit, true, 0);
    float[] temp = pwavg.getLimits();
    temp[4] = 1.0f;
    pwavg.setLimits(temp);

    float[][] temppch = new float[xpts][ypts];
    for (int i = 0; i < xpts; i++) {
      System.arraycopy(pch[dispcurve][i], 0, temppch[i], 0, ypts);
    }
    pwfit = new PlotWindow3D("Selected Curve", "kg", "kr", "Frequency", temppch, 0);
    pwfit.setLogAxes(false, false, true);
    pwfit.draw();
    pwfit.addPoints(fit[dispcurve], true, 0);
    float[] temp2 = pwfit.getLimits();
    temp2[4] = 1.0f;
    pwfit.setLimits(temp2);

    resetparams();
    repaint();
  }
Exemple #16
0
  // swing gui / constructor
  public Main(final Field f) {
    super("Sudoku Solver");
    URL iconURL = getClass().getResource("icon.png");
    ImageIcon img = new ImageIcon(iconURL);
    jFrame.setIconImage(img.getImage());
    Color darkBlue = new Color(51, 102, 153);
    Color lightBlue = new Color(18, 61, 104);

    grid = new JTextField[9][9];
    jGrid.setLayout(new GridLayout(9, 9));
    jGrid.setBorder(BorderFactory.createMatteBorder(5, 5, 5, 5, darkBlue));
    jGrid.setBackground(darkBlue);
    for (int i = 0; i < 9; i++) {
      for (int j = 0; j < 9; j++) {
        grid[i][j] = new JTextField();
        grid[i][j].setDocument(new JTextFieldLimit(1));
        grid[i][j].setFont(new Font("Arial", Font.PLAIN, 20));
        grid[i][j].setHorizontalAlignment(JTextField.CENTER);
        grid[i][j].setText("");
        grid[i][j].setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, lightBlue));
        if (j == 2 || j == 5) {
          grid[i][j].setBorder(BorderFactory.createMatteBorder(1, 1, 1, 5, lightBlue));
        }
        if (i == 2 || i == 5) {
          grid[i][j].setBorder(BorderFactory.createMatteBorder(1, 1, 5, 1, lightBlue));
        }
        if (i == 2 && j == 2) {
          grid[i][j].setBorder(BorderFactory.createMatteBorder(1, 1, 5, 5, lightBlue));
        }
        if (i == 5 && j == 2) {
          grid[i][j].setBorder(BorderFactory.createMatteBorder(1, 1, 5, 5, lightBlue));
        }
        if (i == 2 && j == 5) {
          grid[i][j].setBorder(BorderFactory.createMatteBorder(1, 1, 5, 5, lightBlue));
        }
        if (i == 5 && j == 5) {
          grid[i][j].setBorder(BorderFactory.createMatteBorder(1, 1, 5, 5, lightBlue));
        }
        jGrid.add(grid[i][j]);
      }
    }

    jButton.setLayout(new FlowLayout());
    jButton.setBackground(darkBlue);
    jButton.setPreferredSize(new Dimension(420, 45));

    jButton.add(solve);
    solve.setLabel("Solve");
    solve.setVisible(true);
    solve.setFont(new Font("HelveticaNeue", Font.PLAIN, 20));
    solve.setForeground(Color.BLACK);

    jButton.add(upload);
    upload.setLabel("Upload");
    upload.setVisible(true);
    upload.setFont(new Font("Arial", Font.PLAIN, 20));
    upload.setForeground(Color.BLACK);

    jButton.add(clear);
    clear.setLabel("Clear");
    clear.setVisible(true);
    clear.setFont(new Font("Arial", Font.PLAIN, 20));
    clear.setForeground(Color.BLACK);

    jGrid.setPreferredSize(new Dimension(400, 400));

    jFrame.setResizable(false);
    jFrame.setVisible(true);
    jFrame.setLocationRelativeTo(null);
    jFrame.setSize(420, 480);
    jFrame.setBackground(darkBlue);

    jFrame.add(jGrid, BorderLayout.PAGE_START);
    jFrame.add(jButton, BorderLayout.PAGE_END);

    ActionListener solvedClicked =
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            makeGridWhite();
            gridToModel(f);
            if (!errorFound(f)) {
              runSolve(f);
              makeGrid(f, false);
              solve.setEnabled(false);
            }
          }
        };

    ActionListener uploadClicked =
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            makeGridWhite();
            f.clearModel();
            makeGrid(f, true);
            solve.setEnabled(true);
            f.fromFile();
            makeGrid(f, true);
          }
        };

    ActionListener clearClicked =
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            makeGridWhite();
            f.clearModel();
            makeGrid(f, true);
            solve.setEnabled(true);
          }
        };

    solve.addActionListener(solvedClicked);
    upload.addActionListener(uploadClicked);
    clear.addActionListener(clearClicked);
  }
  public Display(String title) throws IOException {

    super(title);
    setLayout(new GridLayout(1, 3));
    JPanel options = new JPanel(new GridLayout(5, 1));
    JPanel numCircles = new JPanel((new GridLayout(1, 2)));
    addWindowListener(this);
    b = new Button("Load Image");
    c = new Button("filter");
    findCircles = new Button("Find");

    inputCircles = new JTextField("12");
    numCircles.add(inputCircles);
    numCircles.add(findCircles);
    options.add(b);
    options.add(c);
    add(options);

    filterBtn = new JRadioButton("Filtered");
    sobelBtn = new JRadioButton("Sobel");
    nonMaxBtn = new JRadioButton("Non Maximal");
    accumulator = new JRadioButton("Accumulator");
    whichRadius = new JSlider(JSlider.HORIZONTAL, rmin, 125, 14);

    whichRadius.setMajorTickSpacing(10);
    whichRadius.setMinorTickSpacing(1);
    whichRadius.setPaintTicks(true);
    whichRadius.setPaintLabels(true);
    whichRadius.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0));
    Font font = new Font("Serif", Font.ITALIC, 6);
    whichRadius.setFont(font);

    ButtonGroup rGroup = new ButtonGroup();
    rGroup.add(filterBtn);
    rGroup.add(sobelBtn);
    rGroup.add(nonMaxBtn);
    rGroup.add(accumulator);

    JPanel radioPanel = new JPanel(new GridLayout(0, 1));
    radioPanel.add(filterBtn);
    radioPanel.add(sobelBtn);
    radioPanel.add(nonMaxBtn);
    radioPanel.add(accumulator);

    options.add(radioPanel);
    options.add(numCircles);
    options.add(whichRadius);
    loadImage();
    add(lbl1);
    add(lbl2);
    b.addActionListener(this);
    c.addActionListener(this);

    filterBtn.addActionListener(this);
    sobelBtn.addActionListener(this);
    nonMaxBtn.addActionListener(this);
    findCircles.addActionListener(this);
    accumulator.addActionListener(this);

    whichRadius.addChangeListener(this);
  }
Exemple #18
0
  public void actionPerformed(ActionEvent ae) {

    String s1 = ae.getActionCommand();

    if (s1.equals("Calendar")) {
      // DatePicker dp=new DatePicker(f);
      // dp.displayDate();
      // f.getContentPane().add(p);

      b3.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
              t6.setText(new DatePicker(f).setPickedDate());
            }
          });

    } else if (s1.equals("LogOut")) {
      f.dispose();
      start p = new start();
      p.method();

    } else if (s1.equals("Search")) {

      try {
        String data = t1.getSelectedItem();
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        Connection con = DriverManager.getConnection("jdbc:odbc:raman1");
        Statement stm = con.createStatement();
        ResultSet rs = stm.executeQuery("select * from mprofile  where Manager_Id='" + data + "' ");
        while (rs.next()) {
          String a2 = rs.getString(1);
          t2.setText(a2);
          String a3 = rs.getString(2);
          t3.setText(a3);
          String a4 = rs.getString(3);
          t4.setText(a4);

          String a5 = rs.getString(4);
          t5.setText(a5);

          String a6 = rs.getString(6);
          t6.setText(a6);

          String a7 = rs.getString(7);
          t7.setText(a7);

          String a8 = rs.getString(8);
          t8.setText(a8);

          String a9 = rs.getString(9);
          t9.setText(a9);

          String a10 = rs.getString(10);
          t10.setText(a10);

          p.add(l3);
          p.add(t2);
          p.add(l4);
          p.add(t3);
          p.add(l5);
          p.add(t4);
          p.add(l6);
          p.add(t5);
          p.add(l7);
          p.add(c1);
          p.add(c2);
          p.add(l8);
          p.add(t6);
          p.add(l9);
          p.add(t7);
          p.add(l10);
          p.add(t8);
          p.add(l11);
          p.add(t9);
          p.add(l12);
          p.add(t10);
          p.add(b2);
          p.add(b3);
          p.add(b4);
        }
      } catch (Exception e) {
      }

    } else if (s1.equals("Update")) {

      String y2 = t2.getText();
      String y3 = t3.getText();
      String update_id = t4.getText();
      String y4 = t5.getText();
      String y6 = t6.getText();
      String y7 = t7.getText();
      String y8 = t8.getText();
      String y9 = t9.getText();
      String y10 = t10.getText();
      try {
        String y = t1.getSelectedItem();
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        Connection con = DriverManager.getConnection("jdbc:odbc:raman1");

        PreparedStatement ps =
            con.prepareStatement(
                "update mprofile  set Location=? , E_Mail_Id=? ,Contact_No =?, Address=?, D_O_B=?,Gender=?, Password=?, Manager_Id=?,manager_father=?,manager_name=? where  Manager_Id='"
                    + y
                    + "'  ");

        ps.setString(1, y10);
        ps.setString(2, y9);
        ps.setString(3, y8);
        ps.setString(4, y7);
        ps.setString(5, y6);
        ps.setString(6, g);
        ps.setString(7, y4);
        ps.setString(8, update_id);
        ps.setString(9, y3);
        ps.setString(10, y2);

        ps.executeUpdate();
        JOptionPane.showMessageDialog(p, "data has been updated");
        f.dispose();
        project p = new project();
        p.method();
      } catch (Exception e) {
        System.out.println(e);
      }
    } else if (s1.equals("Close")) {
      f.dispose();
    } else {
      f.dispose();
      project p = new project();
      p.method();
    }
  }
  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);
          }
        });
  }