Пример #1
0
  public SudokuGUI(String x) {
    setTitle(x);
    textfield1.setEditable(false);
    button5.setEnabled(false);
    button10.setEnabled(false);
    button13.setEnabled(false);
    button12.setEnabled(false);
    button15.setEnabled(false);
    button18.setEnabled(false);
    setLayout(new GridLayout(6, 4, 4, 4));
    setLocation(350, 300);

    button1.addMouseListener(this);
    button2.addMouseListener(this);
    button3.addMouseListener(this);
    button4.addMouseListener(this);
    button6.addMouseListener(this);
    button7.addMouseListener(this);
    button8.addMouseListener(this);
    button9.addMouseListener(this);
    button11.addMouseListener(this);
    button14.addMouseListener(this);
    button16.addMouseListener(this);
    button17.addMouseListener(this);
    button19.addMouseListener(this);
    button20.addMouseListener(this);
    textfield2.addMouseListener(this);

    add(button1);
    add(button2);
    add(button3);
    add(button4);
    add(button5);
    add(button6);
    add(button7);
    add(button8);
    add(button9);
    add(button10);
    add(button11);
    add(button12);
    add(button13);
    add(button14);
    add(button15);
    add(button16);
    add(button17);
    add(button18);
    add(button19);
    add(button20);
    add(textfield1);
    add(textfield2);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setSize(700, 400);
  }
Пример #2
0
  @Override
  public void installUI(final JComponent c) {
    super.installUI(c);

    radioButton = (JRadioButton) c;

    // Default settings
    SwingUtils.setOrientation(c);
    radioButton.setOpaque(false);

    // Initial check state
    checkIcon = radioButton.isSelected() ? CHECK_STATES.size() - 1 : 0;

    // Updating border and icon
    updateBorder();
    updateIcon(radioButton);

    // Background fade animation
    bgTimer =
        new WebTimer(
            "WebRadioButtonUI.bgUpdater",
            40,
            new ActionListener() {
              @Override
              public void actionPerformed(final ActionEvent e) {
                if (rollover && bgDarkness < MAX_DARKNESS) {
                  bgDarkness++;
                  c.repaint();
                } else if (!rollover && bgDarkness > 0) {
                  bgDarkness--;
                  c.repaint();
                } else {
                  bgTimer.stop();
                }
              }
            });
    mouseAdapter =
        new MouseAdapter() {
          @Override
          public void mouseEntered(final MouseEvent e) {
            rollover = true;
            if (isAnimated()) {
              bgTimer.start();
            } else {
              bgDarkness = MAX_DARKNESS;
              c.repaint();
            }
          }

          @Override
          public void mouseExited(final MouseEvent e) {
            rollover = false;
            if (isAnimated()) {
              bgTimer.start();
            } else {
              bgDarkness = 0;
              c.repaint();
            }
          }
        };
    radioButton.addMouseListener(mouseAdapter);

    // Selection changes animation
    checkTimer =
        new WebTimer(
            "WebRadioButtonUI.iconUpdater",
            40,
            new ActionListener() {
              @Override
              public void actionPerformed(final ActionEvent e) {
                if (checking && checkIcon < CHECK_STATES.size() - 1) {
                  checkIcon++;
                  c.repaint();
                } else if (!checking && checkIcon > 0) {
                  checkIcon--;
                  c.repaint();
                } else {
                  checkTimer.stop();
                }
              }
            });
    itemListener =
        new ItemListener() {
          @Override
          public void itemStateChanged(final ItemEvent e) {
            if (animated) {
              if (radioButton.isSelected()) {
                checking = true;
                checkTimer.start();
              } else {
                checking = false;
                checkTimer.start();
              }
            } else {
              checkTimer.stop();
              checkIcon = radioButton.isSelected() ? CHECK_STATES.size() - 1 : 0;
              c.repaint();
            }
          }
        };
    radioButton.addItemListener(itemListener);
  }