Beispiel #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);
  }
Beispiel #2
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);
          }
        });
  }
  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);
  }