예제 #1
0
  public IMChatListElement(Icon icon, String title, WebButton removeBtn) {
    this.removeBtn = removeBtn;

    // 图片和标题
    WebLabel titleLabel = new WebLabel(title, icon);
    titleLabel.setMargin(0, 0, 0, 4);
    titleLabel.setAlignmentX(WebLabel.LEFT_ALIGNMENT);
    titleLabel.setOpaque(false);
    titleLabel.setForeground(Color.WHITE);
    this.add(titleLabel, BorderLayout.CENTER);
    this.add(removeBtn, BorderLayout.LINE_END);

    setPainter(new ChatListElementPainter());
  }
예제 #2
0
  /** 成员搜索 content */
  private void initSeacher() {
    final WebPanel headerPl = new WebPanel();
    membersCount = new WebLabel("Members (0/0)");
    membersCount.setMargin(0, 5, 0, 0);
    WebButton searcherBtn =
        WebButton.createIconWebButton(
            IMImageUtil.getScaledInstance(SkinUtils.getImageIcon("searchNormal"), 18, 18),
            StyleConstants.smallRound,
            true);
    final WebTextField seacherTxt = new WebTextField("Find a contact...");
    seacherTxt.setForeground(Color.LIGHT_GRAY);
    seacherTxt.setVisible(false);
    headerPl.add(membersCount, BorderLayout.CENTER);
    headerPl.add(searcherBtn, BorderLayout.LINE_END);
    headerPl.add(seacherTxt, BorderLayout.PAGE_END);

    progressOverlay = new WebProgressOverlay();
    progressOverlay.setComponent(headerPl);
    content.add(progressOverlay, BorderLayout.PAGE_START);
    searcherBtn.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            if (!seacherTxt.isVisible()) {
              seacherTxt.setVisible(true);
              headerPl.revalidate();
              headerPl.repaint();
            } else if (seacherTxt.isVisible()) {
              seacherTxt.setVisible(false);
              headerPl.revalidate();
              headerPl.repaint();
            }
          }
        });
    seacherTxt.addFocusListener(
        new FocusListener() {

          @Override
          public void focusLost(FocusEvent e) {
            seacherTxt.setText("Find a contact...");
          }

          @Override
          public void focusGained(FocusEvent e) {
            seacherTxt.setText("");
          }
        });
  }
예제 #3
0
    private void initComponent() {
      // 小于一天就显示时间,否则就显示日期
      String time = DATE_FORMAT.format(msg.getDate());
      if (System.currentTimeMillis() - msg.getDate().getTime() < 24 * 3600 * 1000) {
        time = TIME_FORMAT.format(msg.getDate());
      }
      infoLabl = new WebLabel(msg.getSender().getNickname() + " " + time);
      infoLabl.setForeground(new Color(70, 160, 220));
      infoLabl.setMargin(5);
      contnetPane = new RichTextPane();
      contnetPane.setRichItems(msg.getContents());
      contnetPane.setEditable(false);

      add(infoLabl, BorderLayout.PAGE_START);
      add(contnetPane, BorderLayout.CENTER);
    }
예제 #4
0
  public WebFilePlate(File file, boolean decorated) {
    super(decorated);

    this.file = file;

    // setDrawFocus ( true );
    setMargin(0, 3, 0, 0);

    TableLayout tableLayout =
        new TableLayout(
            new double[][] {{TableLayout.FILL, TableLayout.PREFERRED}, {TableLayout.PREFERRED}});
    tableLayout.setHGap(0);
    tableLayout.setVGap(0);
    setLayout(tableLayout);

    // Displayed file name
    fileName = new WebLabel();
    fileName.setMargin(0, 0, 0, showRemoveButton ? 1 : 0);
    add(fileName, "0,0");

    // Updating current file name
    updateFileName();

    // Adding remove button if needed
    if (showRemoveButton) {
      add(getRemoveButton(), "1,0");
    }

    // Adding appear listener
    addAncestorListener(
        new AncestorAdapter() {
          @Override
          public void ancestorAdded(AncestorEvent event) {
            if (animator != null && animator.isRunning()) {
              animator.stop();
            }
            if (animate) {
              animator =
                  new WebTimer(
                      "WebFilePlate.fadeInTimer",
                      StyleConstants.animationDelay,
                      new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent e) {
                          opacity += 0.1f;
                          if (opacity < 1f) {
                            WebFilePlate.this.repaint();
                          } else {
                            opacity = 1f;
                            WebFilePlate.this.repaint();
                            animator.stop();
                          }
                        }
                      });
              animator.start();
            } else {
              opacity = 1f;
              WebFilePlate.this.repaint();
            }
          }
        });
  }
예제 #5
0
    /** 初始化组件 */
    private void initComponent() {
      WebLabel netSettingLbl = new WebLabel("Network Setting");
      WebLabel typeLbl = new WebLabel("Type:");
      WebLabel addressLbl = new WebLabel("Address:");
      WebLabel portLbl = new WebLabel("Port:");
      WebLabel usernameLbl = new WebLabel("Username:"******"Password:"******"Domain:");

      typeCbx = new WebComboBox();
      typeCbx.addItem("None");
      typeCbx.addItem("Http");
      typeCbx.addItem("Socks5");
      typeCbx.addItem("Browser");
      typeCbx.setDrawFocus(false);

      // field
      addressFld = new WebTextField();
      portFld = new WebTextField();
      usernameFld = new WebTextField();
      passwordFld = new WebTextField();
      domainFld = new WebTextField();

      // label margin
      netSettingLbl.setMargin(15);
      Insets insets = new Insets(5, 5, 5, 5);
      typeLbl.setMargin(5, 37, 5, 5);
      addressLbl.setMargin(5, 14, 5, 5);
      portLbl.setMargin(5, 27, 5, 5);
      usernameLbl.setMargin(insets);
      passwordLbl.setMargin(insets);
      domainLbl.setMargin(insets);

      // size
      Dimension d1 = new Dimension(80, 30);
      Dimension d2 = new Dimension(100, 30);
      Dimension d3 = new Dimension(50, 30);

      // field properties
      typeCbx.setPreferredSize(d1);
      usernameFld.setPreferredSize(d1);
      addressFld.setPreferredSize(d2);
      passwordFld.setPreferredSize(d2);
      portFld.setPreferredSize(d3);
      domainFld.setPreferredSize(d3);

      // group panel
      GroupPanel g1 =
          new GroupPanel(true, typeLbl, typeCbx, addressLbl, addressFld, portLbl, portFld);
      GroupPanel g2 =
          new GroupPanel(
              true, usernameLbl, usernameFld, passwordLbl, passwordFld, domainLbl, domainFld);
      g1.setPreferredSize(new Dimension(this.getWidth(), 30));

      // test button
      Dimension dBtn = new Dimension(80, 30);
      WebButton testBtn = new WebButton("Test");
      WebButton okBtn = new WebButton("OK");
      WebButton cancelBtn = new WebButton("Cancel");
      // size
      testBtn.setPreferredSize(dBtn);
      okBtn.setPreferredSize(dBtn);
      cancelBtn.setPreferredSize(dBtn);
      // action
      testBtn.setAction(view.getActionService().getActionMap(this).get("processTestAction"));
      okBtn.setAction(view.getActionService().getActionMap(this).get("processOKAction"));
      cancelBtn.setAction(view.getActionService().getActionMap(this).get("processCancelAction"));
      // reset text
      testBtn.setText("Test");
      okBtn.setText("OK");
      cancelBtn.setText("Cancel");

      // layout panel
      WebPanel testPl = new WebPanel();
      testPl.add(testBtn, BorderLayout.LINE_END);
      testPl.setOpaque(false);
      testPl.setMargin(20, 0, 5, 30);
      WebPanel confimBtnPl = new WebPanel();
      confimBtnPl.add(new GroupPanel(true, okBtn, cancelBtn), BorderLayout.LINE_END);
      confimBtnPl.setMargin(10, 0, 5, 30);
      confimBtnPl.setOpaque(false);

      // add to content
      add(new GroupPanel(false, netSettingLbl, g1, g2, testPl, confimBtnPl));
    }