01: package com.calipso.reportgenerator.userinterface;
02:
03: import com.calipso.reportgenerator.common.ReportGeneratorConfiguration;
04: import com.calipso.reportgenerator.common.LanguageTraslator;
05:
06: import javax.swing.*;
07: import java.awt.*;
08: import java.awt.event.ActionListener;
09: import java.awt.event.ActionEvent;
10:
11: /**
12: * Define la orientacion de la hoja al realizar la impresion
13: */
14:
15: public class JasperReportOrientationUI extends JDialog implements
16: ActionListener {
17:
18: private ButtonGroup group;
19: private JRadioButton btLandscape;
20: private JRadioButton btPortrait;
21: private JButton btAccept;
22: private JButton btCancel;
23: private boolean hasCanceled = false;
24:
25: public JasperReportOrientationUI(JFrame frame, boolean modal,
26: ReportGeneratorConfiguration conf) throws HeadlessException {
27: super (frame, modal);
28: Image icon = conf.getImage("icon");
29: if (icon != null) {
30: frame.setIconImage(icon);
31: }
32: getContentPane().setLayout(new BorderLayout());
33: getContentPane().add(getCenterPanel(), BorderLayout.CENTER);
34: getContentPane().add(getSouthPanel(), BorderLayout.SOUTH);
35: java.awt.Dimension screenSize = java.awt.Toolkit
36: .getDefaultToolkit().getScreenSize();
37: setLocation((screenSize.width - getPreferredSize().width) / 2,
38: (screenSize.height - getPreferredSize().height) / 2);
39: pack();
40: }
41:
42: private JPanel getSouthPanel() {
43: JPanel panel = new JPanel(new FlowLayout());
44: btAccept = new JButton(LanguageTraslator.traslate("112"));
45: btAccept.addActionListener(this );
46: btCancel = new JButton(LanguageTraslator.traslate("113"));
47: btCancel.addActionListener(this );
48: panel.add(btAccept);
49: panel.add(btCancel);
50: return panel;
51: }
52:
53: private JPanel getCenterPanel() {
54: JPanel panel = new JPanel(new FlowLayout());
55: group = new ButtonGroup();
56: btLandscape = new JRadioButton(LanguageTraslator
57: .traslate("359"));
58: btLandscape.setSelected(false);
59: btPortrait = new JRadioButton(LanguageTraslator.traslate("360"));
60: btPortrait.setSelected(true);
61: group.add(btLandscape);
62: group.add(btPortrait);
63: panel.add(btLandscape);
64: panel.add(btPortrait);
65: return panel;
66: }
67:
68: public boolean isLandscape() {
69: if (btLandscape.isSelected()) {
70: return true;
71: }
72: return false;
73: }
74:
75: public boolean getHasCanceled() {
76: return hasCanceled;
77: }
78:
79: public void actionPerformed(ActionEvent e) {
80: this .dispose();
81: if (e.getSource() == btCancel) {
82: hasCanceled = true;
83: }
84: }
85: }
|