01: /**
02: * $RCSfile: VALicensePanel.java,v $
03: * @creation 01/02/00
04: * @modification $Date: 2005/03/05 18:07:32 $
05: */package com.memoire.vainstall.gui;
06:
07: import java.awt.*;
08: import java.io.*;
09: import javax.swing.*;
10: import javax.swing.border.*;
11: import com.memoire.vainstall.VAGlobals;
12: import com.memoire.vainstall.VALicenseStep;
13:
14: /**
15: * @version $Id: VALicensePanel.java,v 1.6 2005/03/05 18:07:32 deniger Exp $
16: * @author Axel von Arnim
17: */
18:
19: public class VALicensePanel extends VAPanel implements VALicenseStep {
20: JTextArea taLicense_;
21: JRadioButton rdYes_, rdNo_;
22:
23: public VALicensePanel() {
24: super ();
25:
26: setLayout(new BoxLayout(this , BoxLayout.X_AXIS));
27:
28: JPanel pnMain = new JPanel();
29: pnMain.setBorder(new CompoundBorder(new EtchedBorder(),
30: new EmptyBorder(new Insets(5, 5, 5, 5))));
31: pnMain.setLayout(new BorderLayout());
32: JLabel lbTitle = new JLabel(VAGlobals.i18n("UI_License"));
33: lbTitle.setFont(lbTitle.getFont().deriveFont(Font.BOLD, 20));
34: lbTitle.setOpaque(true);
35: lbTitle.setBorder(new EmptyBorder(new Insets(5, 0, 5, 0)));
36: lbTitle.setBackground(pnMain.getBackground().darker());
37: lbTitle.setForeground(Color.white);
38:
39: taLicense_ = new JTextArea();
40: taLicense_.setEditable(false);
41: taLicense_.setFont(new Font("Monospaced", Font.PLAIN, 10));
42: JScrollPane spLicense = new JScrollPane(taLicense_);
43:
44: JPanel pnChoice = new JPanel();
45: pnChoice.setLayout(new BorderLayout());
46: pnChoice.add(BorderLayout.NORTH, new JLabel(VAGlobals
47: .i18n("UI_WantAcceptLicense")));
48: JPanel pnRadios = new JPanel();
49: rdYes_ = new JRadioButton(VAGlobals.i18n("Common_Yes"));
50: rdYes_.setSelected(false);
51: rdNo_ = new JRadioButton(VAGlobals.i18n("Common_No"));
52: rdNo_.setSelected(true);
53: ButtonGroup bg = new ButtonGroup();
54: bg.add(rdYes_);
55: bg.add(rdNo_);
56: pnRadios.add(rdYes_);
57: pnRadios.add(rdNo_);
58: pnChoice.add(BorderLayout.SOUTH, pnRadios);
59:
60: pnMain.add(BorderLayout.NORTH, lbTitle);
61: pnMain.add(BorderLayout.CENTER, spLicense);
62: pnMain.add(BorderLayout.SOUTH, pnChoice);
63:
64: JComponent pnImage = VAImagePanel.IMAGE_PANEL;
65: add(pnImage);
66: add(pnMain);
67: }
68:
69: public void setText(InputStream lic) {
70: StringBuffer text = new StringBuffer();
71: if (lic == null) {
72: text.append(VAGlobals.i18n("UI_NoLicense"));
73: } else {
74: try {
75: LineNumberReader in = new LineNumberReader(
76: new InputStreamReader(lic, "UTF-8"));
77: String line = in.readLine();
78: while (line != null) {
79: text.append(line).append("\n");
80: line = in.readLine();
81: }
82: in.close();
83: } catch (IOException e) {
84: text.append(e.getMessage());
85: }
86: }
87: taLicense_.setText(text.toString());
88: taLicense_.setCaretPosition(0);
89: }
90:
91: public boolean isLicenseAccepted() {
92: return rdYes_.isSelected();
93: }
94: }
|