KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > calipso > reportgenerator > userinterface > JasperReportOrientationUI


1 package com.calipso.reportgenerator.userinterface;
2
3 import com.calipso.reportgenerator.common.ReportGeneratorConfiguration;
4 import com.calipso.reportgenerator.common.LanguageTraslator;
5
6 import javax.swing.*;
7 import java.awt.*;
8 import java.awt.event.ActionListener JavaDoc;
9 import java.awt.event.ActionEvent JavaDoc;
10
11 /**
12  * Define la orientacion de la hoja al realizar la impresion
13  */

14
15 public class JasperReportOrientationUI extends JDialog implements ActionListener JavaDoc {
16
17   private ButtonGroup group;
18   private JRadioButton btLandscape;
19   private JRadioButton btPortrait;
20   private JButton btAccept;
21   private JButton btCancel;
22   private boolean hasCanceled = false;
23
24   public JasperReportOrientationUI(JFrame frame, boolean modal, ReportGeneratorConfiguration conf) throws HeadlessException {
25     super(frame, modal);
26     Image icon = conf.getImage("icon");
27     if(icon != null) {
28       frame.setIconImage(icon);
29     }
30     getContentPane().setLayout(new BorderLayout());
31     getContentPane().add(getCenterPanel(), BorderLayout.CENTER);
32     getContentPane().add(getSouthPanel(), BorderLayout.SOUTH);
33     java.awt.Dimension JavaDoc screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
34     setLocation((screenSize.width - getPreferredSize().width) / 2, (screenSize.height - getPreferredSize().height) / 2);
35     pack();
36   }
37
38   private JPanel getSouthPanel() {
39     JPanel panel = new JPanel(new FlowLayout());
40     btAccept = new JButton(LanguageTraslator.traslate("112"));
41     btAccept.addActionListener(this);
42     btCancel = new JButton(LanguageTraslator.traslate("113"));
43     btCancel.addActionListener(this);
44     panel.add(btAccept);
45     panel.add(btCancel);
46     return panel;
47   }
48
49   private JPanel getCenterPanel() {
50     JPanel panel = new JPanel(new FlowLayout());
51     group = new ButtonGroup();
52     btLandscape = new JRadioButton(LanguageTraslator.traslate("359"));
53     btLandscape.setSelected(false);
54     btPortrait = new JRadioButton(LanguageTraslator.traslate("360"));
55     btPortrait.setSelected(true);
56     group.add(btLandscape);
57     group.add(btPortrait);
58     panel.add(btLandscape);
59     panel.add(btPortrait);
60     return panel;
61   }
62
63   public boolean isLandscape() {
64     if(btLandscape.isSelected()) {
65       return true;
66     }
67     return false;
68   }
69
70   public boolean getHasCanceled() {
71     return hasCanceled;
72   }
73
74   public void actionPerformed(ActionEvent JavaDoc e) {
75     this.dispose();
76     if(e.getSource() == btCancel) {
77       hasCanceled = true;
78     }
79   }
80 }
81
Popular Tags