Пример #1
0
  private JPanel createStepPanel() {
    firstStepButton = new JButton("<<");
    firstStepButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent e) {
            gotoFirstStep();
          }
        });

    previousStepButton = new JButton("<");
    previousStepButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent e) {
            gotoPreviousStep();
          }
        });

    nextStepButton = new JButton(">");
    nextStepButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent e) {
            gotoNextStep();
          }
        });

    lastStepButton = new JButton(">>");
    lastStepButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent e) {
            gotoLastStep();
          }
        });

    stepPositionLabel = new JLabel("0/0");

    final JPanel stepPanel = new JPanel(new GridBagLayout());
    stepPanel.add(
        firstStepButton,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            1,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(2, 2, 2, 2),
            5,
            0));
    stepPanel.add(
        previousStepButton,
        new GridBagConstraints(
            1,
            0,
            1,
            1,
            1,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(2, 2, 2, 2),
            5,
            0));
    stepPanel.add(
        nextStepButton,
        new GridBagConstraints(
            2,
            0,
            1,
            1,
            1,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(2, 2, 2, 2),
            5,
            0));
    stepPanel.add(
        lastStepButton,
        new GridBagConstraints(
            3,
            0,
            1,
            1,
            1,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(2, 2, 2, 2),
            5,
            0));
    stepPanel.add(
        stepPositionLabel,
        new GridBagConstraints(
            4,
            0,
            1,
            1,
            1,
            0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(2, 2, 2, 2),
            5,
            0));
    stepPanel.setBorder(createTitledBorder("Step controls"));
    return stepPanel;
  }