コード例 #1
0
    protected void initComponents() {
      int border = 2;
      this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
      this.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));

      // Description label
      JPanel descriptionPanel = new JPanel(new GridLayout(0, 1, 0, 0));
      descriptionPanel.setBorder(BorderFactory.createEmptyBorder(border, border, border, border));
      String text = thread.getRetrievable().getName();
      text = text.length() > 40 ? text.substring(0, 37) + "..." : text;
      descriptionLabel = new JLabel(text);
      descriptionPanel.add(descriptionLabel);
      this.add(descriptionPanel);

      // Progrees and cancel button
      JPanel progressPanel = new JPanel();
      progressPanel.setLayout(new BoxLayout(progressPanel, BoxLayout.X_AXIS));
      progressPanel.setBorder(BorderFactory.createEmptyBorder(border, border, border, border));
      progressBar = new JProgressBar(0, 100);
      progressBar.setPreferredSize(new Dimension(100, 16));
      progressPanel.add(progressBar);
      progressPanel.add(Box.createHorizontalStrut(8));
      cancelButton = new JButton("Cancel");
      cancelButton.setBackground(Color.RED);
      cancelButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent event) {
              cancelButtonActionPerformed(event);
            }
          });
      progressPanel.add(cancelButton);
      this.add(progressPanel);
    }
コード例 #2
0
  protected void initComponents() {
    int border = 6;
    this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    this.setBorder(
        new CompoundBorder(
            BorderFactory.createEmptyBorder(9, 9, 9, 9), new TitledBorder("Download")));
    this.setToolTipText("Layer imagery bulk download.");

    final JPanel locationPanel = new JPanel(new BorderLayout(5, 5));
    JLabel locationLabel = new JLabel(" Cache:");
    final JLabel locationName = new JLabel("");
    JButton locationButton = new JButton("...");
    locationPanel.add(locationLabel, BorderLayout.WEST);
    locationPanel.add(locationName, BorderLayout.CENTER);
    locationPanel.add(locationButton, BorderLayout.EAST);
    this.add(locationPanel);

    locationButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            JFileChooser fc = new JFileChooser();
            fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            fc.setMultiSelectionEnabled(false);
            int status = fc.showOpenDialog(locationPanel);
            if (status == JFileChooser.APPROVE_OPTION) {
              File file = fc.getSelectedFile();
              if (file != null) {
                locationName.setText(file.getPath());
                cache = new BasicDataFileStore(file);
                updateRetrievablePanels(selector.getSector());
              }
            }
          }
        });

    // Select sector button
    JPanel sectorPanel = new JPanel(new GridLayout(0, 1, 0, 0));
    sectorPanel.setBorder(BorderFactory.createEmptyBorder(border, border, border, border));
    selectButton = new JButton("Select sector");
    selectButton.setToolTipText("Press Select then press and drag button 1 on globe");
    selectButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            selectButtonActionPerformed(event);
          }
        });
    sectorPanel.add(selectButton);
    sectorLabel = new JLabel("-");
    sectorLabel.setPreferredSize(new Dimension(350, 16));
    sectorLabel.setHorizontalAlignment(JLabel.CENTER);
    sectorPanel.add(sectorLabel);
    this.add(sectorPanel);

    // Retrievable list combo and start button
    JPanel retrievablesPanel = new JPanel();
    retrievablesPanel.setLayout(new BoxLayout(retrievablesPanel, BoxLayout.Y_AXIS));
    retrievablesPanel.setBorder(BorderFactory.createEmptyBorder(border, border, border, border));

    // RetrievablePanel list
    for (JPanel panel : this.retrievables) {
      retrievablesPanel.add(panel);
    }
    this.add(retrievablesPanel);

    // Start button
    JPanel startPanel = new JPanel(new GridLayout(0, 1, 0, 0));
    startPanel.setBorder(BorderFactory.createEmptyBorder(border, border, border, border));
    startButton = new JButton("Start download");
    startButton.setEnabled(false);
    startButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            startButtonActionPerformed(event);
          }
        });
    startPanel.add(startButton);
    this.add(startPanel);

    // Download monitor panel
    monitorPanel = new JPanel();
    monitorPanel.setLayout(new BoxLayout(monitorPanel, BoxLayout.Y_AXIS));
    monitorPanel.setBorder(BorderFactory.createEmptyBorder(border, border, border, border));
    // this.add(monitorPanel);

    // Put the monitor panel in a scroll pane.
    JPanel dummyPanel = new JPanel(new BorderLayout());
    dummyPanel.add(monitorPanel, BorderLayout.NORTH);

    JScrollPane scrollPane = new JScrollPane(dummyPanel);
    scrollPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    scrollPane.setPreferredSize(new Dimension(350, 200));
    this.add(scrollPane);
  }