コード例 #1
0
  public FPGACommanderListWindow(
      String Title, Color fg, boolean count, FPGACommanderListModel model) {
    super((count) ? Title + " (0)" : Title);
    this.Title = Title;
    setResizable(true);
    setAlwaysOnTop(false);
    setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
    Color bg = Color.black;

    textArea.setBackground(bg);
    textArea.setForeground(fg);
    textArea.setSelectionBackground(fg);
    textArea.setSelectionForeground(bg);
    textArea.setFont(new Font("monospaced", Font.PLAIN, FontSize));
    textArea.setModel(model);
    textArea.setCellRenderer(model.getMyRenderer(count));
    textArea.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    model.addListDataListener(this);

    JScrollPane textMessages = new JScrollPane(textArea);
    textMessages.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    textMessages.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    add(textMessages);
    setLocationRelativeTo(null);
    textArea.addKeyListener(this);
    pack();
    addWindowListener(this);
    this.count = count;
    this.model = model;
  }
コード例 #2
0
ファイル: TestListPanel.java プロジェクト: oschrenk/jts
 private void jbInit() throws Exception {
   setSize(200, 250);
   setLayout(borderLayout2);
   list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
   list.setSelectionBackground(Color.GRAY);
   add(jScrollPane1, BorderLayout.CENTER);
   jScrollPane1.getViewport().add(list, null);
 }
コード例 #3
0
  // 构造函数
  public FindHelpList(final Vector<Point> test) {
    setContentPane(c1);
    setLayout(null);
    int pointsize; // 附近点的个数
    if (test.size() <= 100) pointsize = 100;
    else pointsize = 101;
    temtest = new Vector<Point>();
    for (int i = 0; i < pointsize; i++) temtest.add(test.elementAt(i)); // 把附近的100个点加入temtests容器中
    word = new Vector<String>();
    word.add("点击显示邻近的100个点和边");
    for (int i = 1; i < pointsize; i++)
      word.add(test.elementAt(i).getName() + "    NO." + i); // 把附近100个点的地名加入word容器中
    list = new JList<String>();
    list.setSelectionBackground(null);
    list.setForeground(Color.blue);
    JScrollPane scrollPane = new JScrollPane(list); // 创建滚动面板对象,设置显示内容为list
    scrollPane.setOpaque(false);
    scrollPane.getViewport().setOpaque(false);
    // list.setForeground(Color.WHITE);
    list.setBackground(new Color(0, 0, 0, 0));
    scrollPane.setLocation(0, 0);
    scrollPane.setSize(285, 470);
    add(scrollPane);
    list.setListData(word); // 将word加入list中
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    // 为list添加监视器
    list.addListSelectionListener(
        new ListSelectionListener() {

          @Override
          public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
              // TODO 自动生成的方法存根
              int selectedIndex = list.getSelectedIndex(); // 获取选择地点的下标
              if (selectedIndex < 0) return;
              Point selectedPoint = test.elementAt(selectedIndex); // 根据下表查找地点的坐标
              try {
                new historyfile("searchname", selectedPoint.getNum(), 0); // 把该地点加入到历史记录
              } catch (IOException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
              }
              // int x=selectedPoint.getX();
              // int y=selectedPoint.getY();
              MainFrame.getMainFrame().setNearPointVec(temtest); // 设置附近一百个点是temtest里面的一百个点
              MainFrame.getMainFrame().focusOnPoint(selectedPoint, false); // 定位到选择的点
              MainFrame.getMainFrame().setShowNear(); // 显示附近的点
            }
          }
        });

    this.setSize(300, 500);
    this.setLocationRelativeTo(null);
    this.setTitle("NearPoint Search");
    this.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
    this.setVisible(true);
  }
コード例 #4
0
  private JScrollPane getClusterList() {
    if (clustList == null) {
      clustList = new JList();

      clustList.setSelectionBackground(new Color(83, 126, 126));
      clustList.setSelectionForeground(Color.BLACK);
      clustList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
      clustList.setFont(
          new Font(
              clustList.getFont().getName(),
              clustList.getFont().getStyle(),
              clustList.getFont().getSize() + 1));

      String[] clustStr = new String[numClusters];
      for (int i = 0; i < numClusters; i++) {
        clustStr[i] = "Cluster " + (i + 1);
      }

      clustList.setListData(clustStr);

      clustList.addListSelectionListener(
          new ListSelectionListener() {
            public void valueChanged(ListSelectionEvent e) {
              if (clustInfo != null && clustList.getSelectedIndex() >= 0) {
                if (!e.getValueIsAdjusting()) {
                  ((clustTableModel) clustInfo.getModel())
                      .setData(infos.infoCluster[clustList.getSelectedIndex()].statClust);
                  clustInfo.tableChanged(new TableModelEvent(clustInfo.getModel()));
                  clustDet.setCluster(clustList.getSelectedIndex());
                  String cur =
                      DESCR_LABEL.replaceFirst(
                          "X", Integer.toString(clustList.getSelectedIndex() + 1));
                  cur = cur.replaceFirst("Y", Integer.toString(numClusters));
                  desctText.setText(
                      cur.replaceFirst(
                          "Z", Integer.toString(infos.numElem[clustList.getSelectedIndex()])));
                }
              }
            }
          });
    }
    clustList.setSelectedIndex(0);

    JScrollPane p =
        new JScrollPane(
            clustList,
            ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    p.setPreferredSize(new Dimension(120, 115));
    return p;
  }
コード例 #5
0
    private MyCheckboxTreeCellRenderer(
        final SelectionManager selectionManager,
        Map<VirtualFile, String> modulesSet,
        final Project project,
        final JTree tree,
        final Collection<VirtualFile> roots) {
      super(new BorderLayout());
      mySelectionManager = selectionManager;
      myModulesSet = modulesSet;
      myRoots = roots;
      setBackground(tree.getBackground());
      myColoredRenderer =
          new ColoredTreeCellRenderer() {
            @Override
            public void customizeCellRenderer(
                JTree tree,
                Object value,
                boolean selected,
                boolean expanded,
                boolean leaf,
                int row,
                boolean hasFocus) {
              append(value.toString());
            }
          };
      myFictive = new JBList();
      myFictive.setBackground(tree.getBackground());
      myFictive.setSelectionBackground(UIUtil.getListSelectionBackground());
      myFictive.setSelectionForeground(UIUtil.getListSelectionForeground());

      myTextRenderer =
          new WithModulesListCellRenderer(project, myModulesSet) {
            @Override
            protected void putParentPath(Object value, FilePath path, FilePath self) {
              if (myRoots.contains(self.getVirtualFile())) {
                super.putParentPath(value, path, self);
              }
            }
          };
      myTextRenderer.setBackground(tree.getBackground());

      myCheckbox = new JCheckBox();
      myCheckbox.setBackground(tree.getBackground());
      myEmpty = new JLabel("");

      add(myCheckbox, BorderLayout.WEST);
      add(myTextRenderer, BorderLayout.CENTER);
      myCheckbox.setVisible(true);
    }
コード例 #6
0
    protected Component buildPage() {
      JList listBox = SwingComponentFactory.buildList(this.buildSelectedNodesListModel());
      listBox.setBorder(BorderFactory.createEmptyBorder());
      listBox.setCellRenderer(new DisplayableListCellRenderer());

      listBox.setBackground(UIManager.getColor("Panel.background"));
      listBox.setForeground(UIManager.getColor("List.foreground"));
      listBox.setSelectionBackground(UIManager.getColor("ScrollPane.background"));
      listBox.setSelectionForeground(listBox.getForeground());

      JScrollPane scrollPane = new JScrollPane(listBox);
      scrollPane.setBorder(new EmptyBorder(5, 0, 0, 0));
      scrollPane.getVerticalScrollBar().setUnitIncrement(10);
      scrollPane.setViewportBorder(BorderFactory.createEmptyBorder());

      return scrollPane;
    }
コード例 #7
0
 <T> JList createJList(String title, List<T> data) {
   JList list = new JList();
   list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
   list.setDragEnabled(false);
   // HACK find a way to modify napkin's color, not the component's
   int c = 200;
   list.setSelectionBackground(new Color(c, c, c));
   list.setBorder(BorderFactory.createTitledBorder(title));
   if (data != null) {
     List<T> objects = new ArrayList<T>(data);
     Collections.sort(
         objects,
         new Comparator<T>() {
           @Override
           public int compare(T arg0, T arg1) {
             return arg0.toString().compareTo(arg1.toString());
           }
         });
     list.setListData(objects.toArray());
   }
   return list;
 }
コード例 #8
0
ファイル: DelStop.java プロジェクト: rockking1379/Mailroom
 public void setSelectionBackground(Color newValue) {
   sourceList.setSelectionBackground(newValue);
   destList.setSelectionBackground(newValue);
 }
コード例 #9
0
  /** Create the panel. */
  public ArtistInfoPanel(final ArtistNode a) {
    super();
    NumberFormat nf1 = NumberFormat.getInstance();

    // Own settings
    setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0)));
    setBackground(Color.DARK_GRAY);
    setLayout(new BorderLayout(0, 0));
    Utils.fixSize(this, size);

    // COMPONENTS

    // listener
    MouseListener ML_CLOSE =
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            GroovesharkConnector.getInstance().stop();
            NavigationPanel.getInstance().hideArtistInfoBox();
          }
        };

    MouseListener ML_CONFIRM =
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            GroovesharkConnector.getInstance().stop();
            GUI.getInstance().search(a);
            NavigationPanel.getInstance().hideArtistInfoBox();
          }
        };

    // Name panel
    // =========================================================================================
    JPanel namePanel = new JPanel();
    namePanel.setBackground(Color.DARK_GRAY);

    // Name panel / Scrobble label

    this.add(namePanel, BorderLayout.NORTH);
    namePanel.setLayout(new GridLayout(0, 2, 0, 0));

    JPanel upperleftPanel = new JPanel();
    upperleftPanel.setBackground(Color.DARK_GRAY);
    namePanel.add(upperleftPanel);
    upperleftPanel.setLayout(new BorderLayout(0, 0));

    // Name panel / Name label

    JLabel nameTxt = new JLabel(a.getName());
    upperleftPanel.add(nameTxt, BorderLayout.NORTH);
    nameTxt.setForeground(Color.WHITE);
    nameTxt.setHorizontalAlignment(SwingConstants.LEFT);
    nameTxt.setFont(new Font("Tahoma", Font.BOLD, 16));
    JLabel playTxt =
        new JLabel(
            "("
                + nf1.format(a.getScrobbles())
                + " scrobbled tracks, "
                + nf1.format(a.getListener())
                + " listeners)");
    upperleftPanel.add(playTxt, BorderLayout.SOUTH);
    playTxt.setForeground(Color.WHITE);
    playTxt.setHorizontalAlignment(SwingConstants.LEFT);
    playTxt.setFont(new Font("Tahoma", Font.ITALIC, 13));

    JPanel closePanel = new JPanel();
    closePanel.setBackground(Color.DARK_GRAY);
    namePanel.add(closePanel);
    closePanel.setLayout(null);

    CloseButton btnX = new CloseButton("x");
    btnX.resizeButton(20, 20);
    btnX.setBounds(429, 0, 20, 20);
    btnX.addMouseListener(ML_CLOSE);
    closePanel.add(btnX);
    // =========================================================================================

    // content panel
    // =========================================================================================
    JTabbedPane contentPanel = new JTabbedPane(JTabbedPane.LEFT);
    contentPanel.setLayout(new BorderLayout(0, 0));
    contentPanel.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
    contentPanel.setOpaque(true);
    contentPanel.setBackground(Color.DARK_GRAY);
    contentPanel.setForeground(Color.BLACK);

    // content panel / biography panel

    JScrollPane bioPanel = new JScrollPane();
    bioPanel.setLayout(new ScrollPaneLayout());

    // content panel / biography panel / biography TextArea

    JTextArea bioArea = new SanTextbox(Utils.deleteHTMLfromText(a.getWikiFull()));
    bioArea.setBorder(new LineBorder(new Color(0, 0, 0)));
    bioArea.setBounds(new Rectangle(500, 300));
    bioArea.setBackground(Color.DARK_GRAY);
    bioArea.setForeground(Color.WHITE);
    bioArea.setEditable(false);
    bioArea.setWrapStyleWord(true);
    bioArea.setLineWrap(true);
    bioArea.setSelectionColor(bioArea.getBackground());

    Font f = new Font(Font.SANS_SERIF, Font.PLAIN, 12);
    GridBagConstraints gbc_bioArea = new GridBagConstraints();
    gbc_bioArea.insets = new Insets(0, 0, 5, 0);
    gbc_bioArea.fill = GridBagConstraints.BOTH;
    gbc_bioArea.gridx = 0;
    gbc_bioArea.gridy = 0;
    FontMetrics fm = bioArea.getFontMetrics(f);
    bioArea.setSize(width, fm.getHeight() * bioArea.getLineCount());

    bioPanel.getViewport().setView(bioArea);
    VTextIcon contentIcon = new VTextIcon(contentPanel, "biography", VTextIcon.ROTATE_LEFT);

    // content panel / popular content panel

    JPanel popularPanel = new JPanel();
    popularPanel.setLayout(new GridLayout(1, 0));

    // content panel / popular content panel / container panel

    JPanel container = new JPanel();
    container.setLayout(new BorderLayout());

    // content panel / popular content panel / tracks panel
    JPanel tracksPanel = new JPanel();
    tracksPanel.setLayout(new GridLayout(Settings.TRACKFETCH, 0));
    tracksPanel.setBorder(
        new TitledBorder(
            new BevelBorder(BevelBorder.LOWERED, null, null, null, null),
            "top tracks:",
            TitledBorder.LEADING,
            TitledBorder.TOP,
            null,
            null));
    ContentTrackField.resetList();

    Iterator<Track> t = a.getTopTracks().iterator();

    // content panel / popular content panel / tracks panel / tracks
    for (int z = 0; t.hasNext(); z++) {
      Track track = t.next();
      JLabel feld = new ContentTrackField(track.getListeners());
      Dimension feldd = new Dimension(500, (20 - 3 * z));
      feld.setSize(feldd);
      Font fontor = new Font("Tahoma", z < 2 ? Font.BOLD : Font.PLAIN, 19 - z);
      feld.setFont(fontor);
      feld.setText(track.getName() + " (" + nf1.format(track.getListeners()) + " listeners)");
      tracksPanel.add(feld);
    }
    ContentTrackField.recalc();

    container.add(tracksPanel, BorderLayout.CENTER);

    // content panel / popular content panel / albums panel
    JPanel albumsPanel = new JPanel();
    albumsPanel.setSize(500, 100);
    albumsPanel.setLayout(new GridLayout(Settings.ALBUMFETCH, 0));
    albumsPanel.setBorder(
        new TitledBorder(
            new BevelBorder(BevelBorder.LOWERED, null, null, null, null),
            "top albums:",
            TitledBorder.LEADING,
            TitledBorder.TOP,
            null,
            null));
    ContentAlbumField.resetList();

    Iterator<Album> albI = a.getTopAlbums().iterator();

    // content panel / popular content panel / albums panel / albums
    for (int z = 0; albI.hasNext(); z++) {
      Album album = albI.next();
      JLabel feld = new ContentAlbumField(album.getListeners());
      Dimension feldd = new Dimension(500, (20 - 3 * z));
      feld.setSize(feldd);
      Font fontor = new Font("Tahoma", z < 2 ? Font.BOLD : Font.PLAIN, 19 - 2 * z);
      feld.setFont(fontor);
      feld.setText(album.getName());
      albumsPanel.add(feld);
    }
    ContentAlbumField.recalc();

    container.add(albumsPanel, BorderLayout.SOUTH);

    popularPanel.add(container);
    VTextIcon popularIcon = new VTextIcon(contentPanel, "popular content", VTextIcon.ROTATE_LEFT);

    // content panel / blogpost panel

    JScrollPane postPanel = new JScrollPane();
    postPanel.setLayout(new ScrollPaneLayout());
    postPanel.getVerticalScrollBar().setBlockIncrement(1);
    postPanel.setSize(500, 300);
    VTextIcon blogIcon = new VTextIcon(contentPanel, "blog posts", VTextIcon.ROTATE_LEFT);

    // content panel / blogpost panel / posts list

    JList<BlogPost> list = new JList<BlogPost>();
    DefaultListModel<BlogPost> model = new DefaultListModel<BlogPost>();
    BlogPost[] posts = Utils.sortBlogPostArray(a.getRelatedHypemPosts(), Settings.Sort.BYLIKES);
    if (posts != null) {
      for (BlogPost b : posts) {
        model.addElement(b);
      }
      list.setCellRenderer(new BlogPostListCellRenderer());
    } else {
      list.setSelectionBackground(Color.WHITE);
      list.setBorder(null);
    }
    list.setFixedCellHeight(150);
    list.setModel(model);

    postPanel.getViewport().setView(list);

    // composing the tab order for the content panel
    // 1. popular content, 2. biography, 3. blog posts
    contentPanel.addTab(TABLENGTH, popularIcon, popularPanel);
    contentPanel.addTab(TABLENGTH, contentIcon, bioPanel);
    contentPanel.addTab(TABLENGTH, blogIcon, postPanel);

    // adding the content panel to the main panel
    this.add(contentPanel, BorderLayout.CENTER);
    // =========================================================================================

    // west panel
    // =========================================================================================
    JPanel panel = new JPanel();
    panel.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
    panel.setBackground(Color.DARK_GRAY);
    panel.setLayout(new BorderLayout(0, 0));

    // west panel / image panel

    JPanel imagePanel = new ImagePanel(a.getLargeImage());
    imagePanel.setBackground(Color.DARK_GRAY);

    panel.add(imagePanel, BorderLayout.CENTER);

    // west panel / tags panel
    JPanel tagsPanel = new JPanel();
    tagsPanel.setLayout(new BorderLayout(0, 0));
    tagsPanel.setBorder(
        new TitledBorder(
            new BevelBorder(BevelBorder.LOWERED, null, null, null, null),
            "tags:",
            TitledBorder.LEADING,
            TitledBorder.TOP,
            null,
            null));
    tagsPanel.setForeground(Color.WHITE);
    tagsPanel.setBackground(Color.DARK_GRAY);

    // west panel / image panel / textfield

    JTextArea tagField = new SanTextbox();
    tagField.setWrapStyleWord(true);
    tagField.setEnabled(false);
    tagField.setEditable(false);
    tagField.setLineWrap(true);
    tagField.setBorder(null);
    tagField.setBackground(null);
    tagField.setForeground(Color.WHITE);

    StringBuilder sb = new StringBuilder();
    for (Iterator<String> i = a.getTags().iterator(); i.hasNext(); ) {
      sb.append(i.next());
      if (i.hasNext()) sb.append(", ");
    }
    tagField.setText(sb.toString());
    tagField.setColumns(10);

    tagsPanel.add(tagField);

    panel.add(tagsPanel, BorderLayout.SOUTH);

    this.add(panel, BorderLayout.WEST);

    // =========================================================================================

    // south panel
    // =========================================================================================
    JPanel musicPanel = new JPanel();
    musicPanel.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
    // get tracks for element creation
    ArrayList<Track> tracks = (ArrayList<Track>) a.getTopTracks();
    musicPanel.setLayout(new GridLayout(0, 2));
    musicPanel.setBackground(Color.DARK_GRAY);

    // south panel / track play elements (according to artist node information)

    JPanel musicElementsPanel = new JPanel();
    musicElementsPanel.setSize(500, 300);
    musicElementsPanel.setBackground(Color.DARK_GRAY);
    musicPanel.add(musicElementsPanel);
    musicElementsPanel.setLayout(new GridLayout(0, 1));

    if (tracks != null && tracks.size() > 0) {
      for (int i = 0; i < 5; i++) {
        TrackPlayElement element = new TrackPlayElement(a.getName(), tracks.get(i).getName());
        if (element != null) {
          element.setForeground(Color.WHITE);
          musicElementsPanel.add(element);
        }
      }
    }

    JPanel buttonsPanel = new JPanel();
    buttonsPanel.setLayout(null);

    JButton confirmButton = new JButton("<html>Save this artist & do another search</html>");
    confirmButton.setBounds(337, 9, 100, 100);
    confirmButton.addMouseListener(ML_CONFIRM);
    buttonsPanel.add(confirmButton);

    JButton abortButton = new JButton("Go back");
    abortButton.setBounds(337, 120, 99, 23);
    abortButton.addMouseListener(ML_CLOSE);
    buttonsPanel.add(abortButton);

    buttonsPanel.setBackground(Color.DARK_GRAY);

    musicPanel.add(buttonsPanel);

    this.add(musicPanel, BorderLayout.SOUTH);
    Dimension d = new Dimension(500, 150);
    Utils.fixSize(musicPanel, d);

    // =========================================================================================
  }
コード例 #10
0
ファイル: TestWav.java プロジェクト: lmbvarela/cat200-9-2010
  private void makeFrame(String[] audioFiles) {
    // the following makes sure that our application exits when
    // the user closes its window
    setDefaultCloseOperation(EXIT_ON_CLOSE);

    JPanel contentPane = (JPanel) getContentPane();
    contentPane.setBorder(new EmptyBorder(6, 10, 10, 10));

    // Specify the layout manager with nice spacing
    contentPane.setLayout(new BorderLayout(8, 8));

    // Create the left side with combobox and scroll list
    JPanel leftPane = new JPanel();
    {
      leftPane.setLayout(new BorderLayout(8, 8));

      fileList = new JList(audioFiles);
      fileList.setForeground(new Color(140, 171, 226));
      fileList.setBackground(new Color(0, 0, 0));
      fileList.setSelectionBackground(new Color(87, 49, 134));
      fileList.setSelectionForeground(new Color(140, 171, 226));
      JScrollPane scrollPane = new JScrollPane(fileList);
      scrollPane.setColumnHeaderView(new JLabel("Audio files"));
      leftPane.add(scrollPane, BorderLayout.CENTER);
    }
    contentPane.add(leftPane, BorderLayout.CENTER);

    // Create the center with image, text label, and slider
    JPanel centerPane = new JPanel();
    {
      centerPane.setLayout(new BorderLayout(8, 8));

      infoLabel = new JLabel("  ");
      infoLabel.setHorizontalAlignment(SwingConstants.CENTER);
      infoLabel.setForeground(new Color(140, 171, 226));
      centerPane.add(infoLabel, BorderLayout.CENTER);
    }
    contentPane.add(centerPane, BorderLayout.EAST);

    // Create the toolbar with the buttons
    JPanel toolbar = new JPanel();
    {
      toolbar.setLayout(new GridLayout(1, 0));

      JButton button = new JButton("Play");
      button.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              play();
            }
          });
      toolbar.add(button);

      button = new JButton("Stop");
      button.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              stop();
            }
          });
      toolbar.add(button);

      button = new JButton("Pause");
      button.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              pause();
            }
          });
      toolbar.add(button);

      button = new JButton("Resume");
      button.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              resume();
            }
          });
      toolbar.add(button);
    }

    contentPane.add(toolbar, BorderLayout.NORTH);

    // building is done - arrange the components
    pack();

    // place this frame at the center of the screen and show
    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
    setLocation(d.width / 2 - getWidth() / 2, d.height / 2 - getHeight() / 2);
    setVisible(true);
  }
コード例 #11
0
  private void scan_all_flashes() {

    int total_ints = 0;
    int total_ankets = 0;
    int[] ank_ints_counts = new int[100];
    int[] ank_ids = new int[100];

    File[] roots = {};
    if (OSValidator.isWindows()) roots = File.listRoots();
    else if (OSValidator.isUnix()) roots = new File("/media").listFiles();
    else if (OSValidator.isMac()) roots = new File("/Volumes").listFiles();

    File[][] xml_files = new File[100][1000];
    // int f_count = 0;
    String userID = login_edit.getText(), userPSWD = "default";
    for (File root : roots) {
      // System.out.println(root.getAbsolutePath());
      if (new File(root.getAbsolutePath() + "/msmart.flag").exists()) {
        //					StringBuilder strs = new StringBuilder();
        //					Scanner scns = null;
        //					try {
        //						scns = new Scanner(new File(root.getAbsolutePath()+"/msmart.flag"));
        //						while(scns.hasNextLine()) {
        //							strs.append(scns.nextLine());
        //						}
        //					} catch (FileNotFoundException e) {
        //						e.printStackTrace();
        //					}
        //					String settings = strs.toString();
        //
        //					MSS_RQ_TableDescriptor NewsTDesc = new MSS_RQ_TableDescriptor(new
        // String[]{"USERID","PSWD"},
        //							new Class[]{String.class,String.class});
        //				    MSS_RQ_XMLtoTableDescriptor NewsT_XML_Desc = new MSS_RQ_XMLtoTableDescriptor(new
        // String[]{"USERID","PSWD"});
        //				    MSS_RQ_CxListFiller NewsUpdater = new
        // MSS_RQ_CxListFiller(NewsTDesc,NewsT_XML_Desc,NewsServiceElementData.class);
        //				    userID = NewsUpdater.requestLocalData_FromRoot(settings, 0);
        //				    userPSWD = NewsUpdater.requestLocalData_FromRoot(settings, 1);
        //

        // here find all saved interiews in all ankets
        File dir = new File(root.getAbsolutePath() + "/capital/");
        if (dir.isDirectory()) {
          File[] subdirs = dir.listFiles();
          for (File d : subdirs) {
            if (d.isDirectory()) {
              String anket_id = d.getName();
              int ank_id = Integer.parseInt(anket_id);
              status_lbl.append("Найдена папка анкеты " + ank_id + "\n");
              File[] files = d.listFiles();
              int total_ank_ints = 0;
              ank_ids[total_ankets] = ank_id;
              for (File f : files) {
                if (f.getAbsolutePath().endsWith(".xml")) {
                  xml_files[total_ankets][total_ank_ints++] = f;
                  total_ints++;
                }
              }
              // status_lbl.i
              status_lbl.append(
                  "Обнаружено " + total_ank_ints + " интервью  для анкеты " + ank_id + "\n");
              ank_ints_counts[total_ankets] = total_ank_ints;
              total_ankets++;
            }
          }
        }
      }
    }

    status_lbl.append("Всего обнаружено " + total_ints + " интервью. Чтение с карты...\n");
    JList panel_list = new JList();

    panel_list.setBackground(new Color(50, 60, 70));
    panel_list.setSelectionBackground(new Color(69, 149, 38));
    panel_list.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    panel_list.setLayoutOrientation(JList.HORIZONTAL_WRAP);
    panel_list.setVisibleRowCount(-1);
    // SP_CellRenderer renderer = new SP_CellRenderer();
    // panel_list.setCellRenderer(renderer);

    SP_ServerDispatcher servDisp = new SP_ServerDispatcher(panel_list);
    // servDisp;

    for (int i = 0; i < total_ankets; i++) {
      for (int j = 0; j < ank_ints_counts[i]; j++) {
        System.out.println(xml_files[i][j].getAbsolutePath());
        StringBuilder str = new StringBuilder();
        try {
          BufferedReader input = new BufferedReader(new FileReader(xml_files[i][j]));
          try {
            String line = null;
            while ((line = input.readLine()) != null) {
              str.append(line);
              str.append(System.getProperty("line.separator"));
            }
          } finally {
            input.close();
          }
        } catch (IOException e) {
          e.printStackTrace();
        }
        ArrayList<MSS_RQ_XML_Pattern> ptn;

        try {
          String interview = str.toString();

          if (OSValidator.isUnix()) interview = new String(str.toString().getBytes(), "cp1251");
          else if (OSValidator.isWindows())
            interview = new String(str.toString().getBytes(), "UTF-8");

          // interview = str.toString();
          // String ans = Base64.encodeBytes(interview.getBytes("CP1251"));
          String ans = Base64.encodeBytes(interview.getBytes());
          status_lbl.append("Отправка " + (j + 1) + " интервью " + ank_ids[i] + " анкеты ...\n");
          servDisp.saveDATA(Integer.parseInt(userID), userPSWD, ank_ids[i], ans);
          status_lbl.append("Отправлено.\n");

          System.out.println(interview);
        } catch (UnsupportedEncodingException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
      }
    }
    status_lbl.append("Отправка интервью на сервер завершена.\n");
  }