示例#1
0
  public SwingInstall() {
    installer = new Install();
    osTasks = OperatingSystem.getOperatingSystem().getOSTasks(installer);

    appName = installer.getProperty("app.name");

    setTitle(appName + " installer");

    JPanel content = new JPanel(new WizardLayout());
    setContentPane(content);

    caption = new JLabel();
    caption.setFont(new Font("SansSerif", Font.BOLD, 18));

    ActionHandler actionHandler = new ActionHandler();

    cancelButton = new JButton("Cancel");
    cancelButton.setRequestFocusEnabled(false);
    cancelButton.addActionListener(actionHandler);
    prevButton = new JButton("Previous");
    prevButton.setRequestFocusEnabled(false);
    prevButton.addActionListener(actionHandler);
    nextButton = new JButton();
    nextButton.setRequestFocusEnabled(false);
    nextButton.addActionListener(actionHandler);

    content.add(caption);
    content.add(cancelButton);
    content.add(prevButton);
    content.add(nextButton);

    String clazz = OperatingSystem.getOperatingSystem().getClass().getName();
    String completedInfo = "done-" + clazz.substring(clazz.indexOf('$') + 1) + ".html";

    pages =
        new Component[] {
          chooseDirectory = new ChooseDirectory(),
          progress = new SwingProgress(),
          new TextPanel(completedInfo)
        };

    selectComponents = new SelectComponents();

    for (int i = 0; i < pages.length; i++) content.add(pages[i]);

    pageChanged();

    setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
    addWindowListener(new WindowHandler());

    Dimension screen = getToolkit().getScreenSize();
    pack();
    setLocation((screen.width - getSize().width) / 2, (screen.height - getSize().height) / 2);
    setVisible(true);
  }
示例#2
0
    private JPanel createCompPanel() {
      filesets = new Vector();

      int count = installer.getIntegerProperty("comp.count");
      JPanel panel = new JPanel(new GridLayout(count, 1));

      String osClass = OperatingSystem.getOperatingSystem().getClass().getName();
      osClass = osClass.substring(osClass.indexOf('$') + 1);

      for (int i = 0; i < count; i++) {
        String os = installer.getProperty("comp." + i + ".os");

        if (os != null && !osClass.equals(os)) continue;

        JCheckBox checkBox =
            new JCheckBox(
                installer.getProperty("comp." + i + ".name")
                    + " ("
                    + installer.getProperty("comp." + i + ".disk-size")
                    + "Mb)");
        checkBox.getModel().setSelected(true);
        checkBox.addActionListener(this);
        checkBox.setRequestFocusEnabled(false);

        filesets.addElement(new Integer(i));

        panel.add(checkBox);
      }

      Dimension dim = panel.getPreferredSize();
      dim.width = Integer.MAX_VALUE;
      panel.setMaximumSize(dim);

      return panel;
    }
示例#3
0
    ChooseDirectory() {
      super(new BorderLayout());

      osTaskDirs = new HashMap();

      JPanel directoryPanel =
          new JPanel(new VariableGridLayout(VariableGridLayout.FIXED_NUM_COLUMNS, 3, 12, 12));

      installDir =
          addField(
              directoryPanel,
              "Install program in:",
              OperatingSystem.getOperatingSystem().getInstallDirectory(appName));

      for (int i = 0; i < osTasks.length; i++) {
        OperatingSystem.OSTask osTask = osTasks[i];
        String label = osTask.getLabel();
        if (label != null) {
          JTextField field = addField(directoryPanel, label, osTask.getDirectory());
          osTaskDirs.put(osTask, field);
        }
      }
      ChooseDirectory.this.add(BorderLayout.NORTH, directoryPanel);
    }