Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

GoToPageDialog.java 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. * $Id$
  3. * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
  4. * For details on use and redistribution please refer to the
  5. * LICENSE file included with these sources.
  6. */
  7. /*
  8. * originally contributed by
  9. * Juergen Verwohlt: Juergen.Verwohlt@jCatalog.com,
  10. * Rainer Steinkuhle: Rainer.Steinkuhle@jCatalog.com,
  11. * Stanislav Gorkhover: Stanislav.Gorkhover@jCatalog.com
  12. */
  13. package org.apache.fop.viewer;
  14. import java.awt.*;
  15. import javax.swing.*;
  16. import java.awt.event.*;
  17. public class GoToPageDialog extends JDialog {
  18. JPanel panel1 = new JPanel();
  19. GridBagLayout gridBagLayout1 = new GridBagLayout();
  20. JLabel pgNbLabel = new JLabel();
  21. JTextField pgNbField = new JTextField();
  22. JButton okButton = new JButton();
  23. JButton cancelButton = new JButton();
  24. int pageNumber = -1;
  25. public GoToPageDialog(Frame frame, String title, boolean modal) {
  26. super(frame, title, modal);
  27. try {
  28. jbInit();
  29. pack();
  30. } catch (Exception ex) {
  31. //log.error("GoToPageDialog: Konstruktor: "
  32. // + ex.getMessage(), ex);
  33. }
  34. }
  35. public GoToPageDialog() {
  36. this(null, "", false);
  37. }
  38. void jbInit() throws Exception {
  39. panel1.setLayout(gridBagLayout1);
  40. pgNbLabel.setText("Page number");
  41. okButton.setText("Ok");
  42. okButton.addActionListener(new java.awt.event.ActionListener() {
  43. public void actionPerformed(ActionEvent e) {
  44. okButton_actionPerformed(e);
  45. }
  46. });
  47. cancelButton.setText("Cancel");
  48. cancelButton.addActionListener(new java.awt.event.ActionListener() {
  49. public void actionPerformed(ActionEvent e) {
  50. cancelButton_actionPerformed(e);
  51. }
  52. });
  53. panel1.setMinimumSize(new Dimension(250, 78));
  54. getContentPane().add(panel1);
  55. panel1.add(pgNbLabel,
  56. new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
  57. GridBagConstraints.WEST,
  58. GridBagConstraints.NONE,
  59. new Insets(10, 10, 10, 5), 0, 0));
  60. panel1.add(pgNbField,
  61. new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0,
  62. GridBagConstraints.WEST,
  63. GridBagConstraints.BOTH,
  64. new Insets(10, 5, 10, 10), 0, 0));
  65. panel1.add(okButton,
  66. new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0,
  67. GridBagConstraints.EAST,
  68. GridBagConstraints.NONE,
  69. new Insets(0, 0, 10, 5), 0, 0));
  70. panel1.add(cancelButton,
  71. new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0,
  72. GridBagConstraints.WEST,
  73. GridBagConstraints.NONE,
  74. new Insets(0, 10, 10, 10), 0, 0));
  75. }
  76. void okButton_actionPerformed(ActionEvent e) {
  77. try {
  78. pageNumber = Integer.parseInt(pgNbField.getText());
  79. dispose();
  80. } catch (Exception ex) {
  81. pgNbField.setText("???");
  82. }
  83. }
  84. void cancelButton_actionPerformed(ActionEvent e) {
  85. pageNumber = -1;
  86. dispose();
  87. }
  88. public int getPageNumber() {
  89. return pageNumber;
  90. }
  91. }