コード例 #1
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);
  }
コード例 #2
0
    private void makePanel(Dimension size) {
      JPanel buttonPanel = new JPanel(new GridLayout(1, 2, 5, 5));
      newButton = new JButton("New");
      newButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent actionEvent) {
              lineBuilder.clear();
              lineBuilder.setArmed(true);
              pauseButton.setText("Pause");
              pauseButton.setEnabled(true);
              endButton.setEnabled(true);
              newButton.setEnabled(false);
              ((Component) wwd).setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
            }
          });
      buttonPanel.add(newButton);
      newButton.setEnabled(true);

      pauseButton = new JButton("Pause");
      pauseButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent actionEvent) {
              lineBuilder.setArmed(!lineBuilder.isArmed());
              pauseButton.setText(!lineBuilder.isArmed() ? "Resume" : "Pause");
              ((Component) wwd).setCursor(Cursor.getDefaultCursor());
            }
          });
      buttonPanel.add(pauseButton);
      pauseButton.setEnabled(false);

      endButton = new JButton("End");
      endButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent actionEvent) {
              lineBuilder.setArmed(false);
              newButton.setEnabled(true);
              pauseButton.setEnabled(false);
              pauseButton.setText("Pause");
              endButton.setEnabled(false);
              ((Component) wwd).setCursor(Cursor.getDefaultCursor());
            }
          });
      buttonPanel.add(endButton);
      endButton.setEnabled(false);

      JPanel pointPanel = new JPanel(new GridLayout(0, 1, 0, 10));
      pointPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

      this.pointLabels = new JLabel[20];
      for (int i = 0; i < this.pointLabels.length; i++) {
        this.pointLabels[i] = new JLabel("");
        pointPanel.add(this.pointLabels[i]);
      }

      // Put the point panel in a container to prevent scroll panel from stretching the vertical
      // spacing.
      JPanel dummyPanel = new JPanel(new BorderLayout());
      dummyPanel.add(pointPanel, BorderLayout.NORTH);

      // Put the point panel in a scroll bar.
      JScrollPane scrollPane = new JScrollPane(dummyPanel);
      scrollPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
      if (size != null) scrollPane.setPreferredSize(size);

      // Add the buttons, scroll bar and inner panel to a titled panel that will resize with the
      // main window.
      JPanel outerPanel = new JPanel(new BorderLayout());
      outerPanel.setBorder(
          new CompoundBorder(
              BorderFactory.createEmptyBorder(9, 9, 9, 9), new TitledBorder("Line")));
      outerPanel.setToolTipText("Line control and info");
      outerPanel.add(buttonPanel, BorderLayout.NORTH);
      outerPanel.add(scrollPane, BorderLayout.CENTER);
      this.add(outerPanel, BorderLayout.CENTER);
    }