KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > memoire > vainstall > gui > VALicensePanel


1 /**
2  * $RCSfile: VALicensePanel.java,v $
3  * @creation 01/02/00
4  * @modification $Date: 2005/03/05 18:07:32 $
5  */

6
7 package com.memoire.vainstall.gui;
8
9 import java.awt.*;
10 import java.io.*;
11 import javax.swing.*;
12 import javax.swing.border.*;
13 import com.memoire.vainstall.VAGlobals;
14 import com.memoire.vainstall.VALicenseStep;
15
16 /**
17  * @version $Id: VALicensePanel.java,v 1.6 2005/03/05 18:07:32 deniger Exp $
18  * @author Axel von Arnim
19  */

20
21 public class VALicensePanel
22        extends VAPanel
23        implements VALicenseStep
24 {
25   JTextArea taLicense_;
26   JRadioButton rdYes_, rdNo_;
27   
28   public VALicensePanel()
29   {
30     super();
31     
32     setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
33     
34     JPanel pnMain=new JPanel();
35     pnMain.setBorder(new CompoundBorder(new EtchedBorder(),
36                                         new EmptyBorder(new Insets(5, 5, 5, 5))));
37     pnMain.setLayout(new BorderLayout());
38     JLabel lbTitle=new JLabel(VAGlobals.i18n("UI_License"));
39     lbTitle.setFont(lbTitle.getFont().deriveFont(Font.BOLD, 20));
40     lbTitle.setOpaque(true);
41     lbTitle.setBorder(new EmptyBorder(new Insets(5, 0, 5, 0)));
42     lbTitle.setBackground(pnMain.getBackground().darker());
43     lbTitle.setForeground(Color.white);
44
45     taLicense_=new JTextArea();
46     taLicense_.setEditable(false);
47     taLicense_.setFont(new Font("Monospaced", Font.PLAIN, 10));
48     JScrollPane spLicense=new JScrollPane(taLicense_);
49
50     JPanel pnChoice=new JPanel();
51     pnChoice.setLayout(new BorderLayout());
52     pnChoice.add(BorderLayout.NORTH, new JLabel(
53       VAGlobals.i18n("UI_WantAcceptLicense")));
54     JPanel pnRadios=new JPanel();
55     rdYes_=new JRadioButton(VAGlobals.i18n("Common_Yes"));
56     rdYes_.setSelected(false);
57     rdNo_=new JRadioButton(VAGlobals.i18n("Common_No"));
58     rdNo_.setSelected(true);
59     ButtonGroup bg=new ButtonGroup();
60     bg.add(rdYes_);
61     bg.add(rdNo_);
62     pnRadios.add(rdYes_);
63     pnRadios.add(rdNo_);
64     pnChoice.add(BorderLayout.SOUTH, pnRadios);
65
66     pnMain.add(BorderLayout.NORTH, lbTitle);
67     pnMain.add(BorderLayout.CENTER, spLicense);
68     pnMain.add(BorderLayout.SOUTH, pnChoice);
69     
70     JComponent pnImage=VAImagePanel.IMAGE_PANEL;
71     add(pnImage);
72     add(pnMain);
73   }
74
75   public void setText(InputStream lic)
76   {
77     StringBuffer JavaDoc text=new StringBuffer JavaDoc();
78     if( lic==null ) {
79       text.append(VAGlobals.i18n("UI_NoLicense"));
80     } else {
81       try {
82         LineNumberReader in=new LineNumberReader(new InputStreamReader(lic, "UTF-8"));
83         String JavaDoc line=in.readLine();
84         while( line!=null ) {
85           text.append(line).append("\n");
86           line=in.readLine();
87         }
88         in.close();
89       } catch( IOException e ) {
90         text.append(e.getMessage());
91       }
92     }
93     taLicense_.setText(text.toString());
94     taLicense_.setCaretPosition(0);
95   }
96   
97   public boolean isLicenseAccepted()
98   {
99     return rdYes_.isSelected();
100   }
101 }
102
Popular Tags