示例#1
0
  /** Create the frame. */
  public SearchWindow() {
    try {
      for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
        LogWindow.addLog("1");
        if ("Nimbus".equals(info.getName())) {
          LogWindow.addLog("2");
          UIManager.setLookAndFeel(info.getClassName());
          break;
        }
      }
    } catch (Exception e) {
      LogWindow.addLog(e.getLocalizedMessage());
      // If Nimbus is not available, you can set the GUI to another look and feel.
    }
    progressBar = new JProgressBar();
    comboBox = new JComboBox();
    button = new JButton("Hunt");
    btnCancel = new JButton("Cancel");

    setResizable(false);
    setTitle("Search - LanHunt " + Constants.getVersion() + "");
    setIconImage(Gui.getIconImage());
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(100, 100, 686, 600);
    // setExtendedState(JFrame.MAXIMIZED_BOTH);
    contentPane = new JPanel();
    contentPane.setBackground(new Color(135, 206, 250));
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));

    // Create top menu panel
    topMenu = new JPanel();
    topMenu.setBackground(new Color(175, 238, 238));
    topMenu.setBounds(0, 11, 692, 38);
    topMenu.setLayout(null);
    JButton btn = new JButton("\u2190 back");
    btn.setBackground(new Color(176, 224, 230));
    btn.setIcon(null);
    btn.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            th.stop();
            mainWindow.showWindow();
            mainWindow.sWindow.setVisible(false);
          }
        });
    contentPane.setLayout(null);
    btn.setBounds(10, 8, 79, 27);
    topMenu.add(btn);

    contentPane.add(topMenu);

    textField = new JTextField();
    textField.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            search(textField.getText(), filter);
          }
        });
    textField.setBounds(95, 8, 347, 27);
    topMenu.add(textField);
    button.setFont(new Font("Tahoma", Font.PLAIN, 12));

    button.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            search(textField.getText(), filter);
          }
        });
    button.setBounds(564, 8, 95, 27);
    topMenu.add(button);

    comboBox.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            filter = comboBox.getSelectedIndex();
          }
        });
    comboBox.setBounds(452, 8, 106, 27);
    comboBox.addItem("All Files");
    comboBox.addItem("Video Files");
    comboBox.addItem("Audio Files");
    comboBox.addItem("Document Files");
    comboBox.addItem("Executable Files");
    topMenu.add(comboBox);
    JScrollPane jsp = new JScrollPane(contentPane);
    panel.setBackground(new Color(175, 238, 238));
    panel.setBounds(0, 53, 692, 61);

    contentPane.add(panel);
    panel.setLayout(null);
    // progressBar.setBackground(new Color(0, 153, 0));

    progressBar.setStringPainted(true);
    progressBar.setBounds(10, 13, 549, 23);
    panel.add(progressBar);
    btnCancel.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            stopSearch();
          }
        });

    btnCancel.setBounds(564, 11, 95, 25);
    btnCancel.setEnabled(false);
    panel.add(btnCancel);

    lblResultstatus.setBounds(10, 36, 344, 14);
    panel.add(lblResultstatus);

    resultPanel = new JPanel();
    resultPanel.setBackground(new Color(135, 206, 250));

    scrollPane = new JScrollPane(resultPanel);
    resultPanelLayout = new GridLayout(0, 1);
    resultPanel.setLayout(resultPanelLayout);
    lblMessage.setVerticalAlignment(SwingConstants.TOP);

    resultPanel.add(lblMessage);

    scrollPane.setBounds(5, 125, 667, 423);
    contentPane.add(scrollPane);

    setContentPane(jsp);
  }