1 21 22 package com.izforge.izpack.panels; 23 24 import java.awt.event.ActionEvent ; 25 import java.awt.event.ActionListener ; 26 27 import javax.swing.ButtonGroup ; 28 import javax.swing.JRadioButton ; 29 import javax.swing.JScrollPane ; 30 import javax.swing.JTextArea ; 31 32 import com.izforge.izpack.gui.IzPanelLayout; 33 import com.izforge.izpack.gui.LabelFactory; 34 import com.izforge.izpack.installer.InstallData; 35 import com.izforge.izpack.installer.InstallerFrame; 36 import com.izforge.izpack.installer.IzPanel; 37 import com.izforge.izpack.installer.ResourceManager; 38 39 44 public class LicencePanel extends IzPanel implements ActionListener 45 { 46 47 50 private static final long serialVersionUID = 3691043187997552948L; 51 52 53 private String licence; 54 55 56 private JRadioButton yesRadio; 57 private JRadioButton noRadio; 58 59 65 public LicencePanel(InstallerFrame parent, InstallData idata) 66 { 67 super(parent, idata, new IzPanelLayout()); 68 loadLicence(); 70 71 73 add(LabelFactory.create(parent.langpack.getString("LicencePanel.info"), 74 parent.icons.getImageIcon("history"), LEADING), NEXT_LINE); 75 JTextArea textArea = new JTextArea (licence); 76 textArea.setCaretPosition(0); 77 textArea.setEditable(false); 78 textArea.setLineWrap(true); 79 textArea.setWrapStyleWord(true); 80 JScrollPane scroller = new JScrollPane (textArea); 81 scroller.setAlignmentX(LEFT_ALIGNMENT); 82 add(scroller, NEXT_LINE); 83 84 ButtonGroup group = new ButtonGroup (); 85 86 yesRadio = new JRadioButton (parent.langpack.getString("LicencePanel.agree"), false); 87 group.add(yesRadio); 88 add(yesRadio, NEXT_LINE); 89 yesRadio.addActionListener(this); 90 91 noRadio = new JRadioButton (parent.langpack.getString("LicencePanel.notagree"), true); 92 group.add(noRadio); 93 add(noRadio, NEXT_LINE); 94 noRadio.addActionListener(this); 95 96 setInitialFocus(noRadio); 97 getLayoutHelper().completeLayout(); 98 } 99 100 101 private void loadLicence() 102 { 103 try 104 { 105 String resNamePrifix = "LicencePanel.licence"; 107 licence = ResourceManager.getInstance().getTextResource(resNamePrifix); 108 } 109 catch (Exception err) 110 { 111 licence = "Error : could not load the licence text !"; 112 } 113 } 114 115 120 public void actionPerformed(ActionEvent e) 121 { 122 if (yesRadio.isSelected()) 123 parent.unlockNextButton(); 124 else 125 parent.lockNextButton(); 126 } 127 128 133 public boolean isValidated() 134 { 135 if (noRadio.isSelected()) 136 { 137 parent.exit(); 138 return false; 139 } 140 return (yesRadio.isSelected()); 141 } 142 143 144 public void panelActivate() 145 { 146 if (!yesRadio.isSelected()) parent.lockNextButton(); 147 } 148 } 149 | Popular Tags |