コード例 #1
0
  /** Initializes the <tt>NewStatusMessageDialog</tt> by adding the buttons, fields, etc. */
  private void init() {
    JLabel messageLabel =
        new JLabel(GuiActivator.getResources().getI18NString("service.gui.NEW_STATUS_MESSAGE"));

    JPanel dataPanel = new TransparentPanel(new BorderLayout(5, 5));

    JTextArea infoArea =
        new JTextArea(GuiActivator.getResources().getI18NString("service.gui.STATUS_MESSAGE_INFO"));

    JLabel infoTitleLabel =
        new JLabel(GuiActivator.getResources().getI18NString("service.gui.NEW_STATUS_MESSAGE"));

    JPanel labelsPanel = new TransparentPanel(new GridLayout(0, 1));

    JButton okButton = new JButton(GuiActivator.getResources().getI18NString("service.gui.OK"));

    JPanel buttonsPanel = new TransparentPanel(new FlowLayout(FlowLayout.RIGHT));

    this.setTitle(GuiActivator.getResources().getI18NString("service.gui.NEW_STATUS_MESSAGE"));

    this.getRootPane().setDefaultButton(okButton);

    this.setPreferredSize(new Dimension(500, 200));

    infoArea.setEditable(false);
    infoArea.setLineWrap(true);
    infoArea.setWrapStyleWord(true);
    infoArea.setOpaque(false);

    dataPanel.add(messageLabel, BorderLayout.WEST);

    messageTextField.setText(presenceOpSet.getCurrentStatusMessage());
    dataPanel.add(messageTextField, BorderLayout.CENTER);

    infoTitleLabel.setHorizontalAlignment(JLabel.CENTER);
    infoTitleLabel.setFont(infoTitleLabel.getFont().deriveFont(Font.BOLD, 18.0f));

    labelsPanel.add(infoTitleLabel);
    labelsPanel.add(infoArea);
    labelsPanel.add(dataPanel);

    messagePanel = new TransparentPanel(new GridBagLayout());
    GridBagConstraints messagePanelConstraints = new GridBagConstraints();
    messagePanelConstraints.anchor = GridBagConstraints.NORTHWEST;
    messagePanelConstraints.fill = GridBagConstraints.NONE;
    messagePanelConstraints.gridx = 0;
    messagePanelConstraints.gridy = 0;
    messagePanelConstraints.insets = new Insets(5, 0, 5, 10);
    messagePanelConstraints.weightx = 0;
    messagePanelConstraints.weighty = 0;
    messagePanel.add(
        new ImageCanvas(ImageLoader.getImage(ImageLoader.RENAME_DIALOG_ICON)),
        messagePanelConstraints);

    messagePanelConstraints.anchor = GridBagConstraints.NORTH;
    messagePanelConstraints.fill = GridBagConstraints.HORIZONTAL;
    messagePanelConstraints.gridx = 1;
    messagePanelConstraints.insets = new Insets(0, 0, 0, 0);
    messagePanelConstraints.weightx = 1;
    messagePanel.add(labelsPanel, messagePanelConstraints);

    okButton.setName("ok");
    cancelButton.setName("cancel");

    okButton.setMnemonic(GuiActivator.getResources().getI18nMnemonic("service.gui.OK"));
    cancelButton.setMnemonic(GuiActivator.getResources().getI18nMnemonic("service.gui.CANCEL"));

    okButton.addActionListener(this);
    cancelButton.addActionListener(this);

    buttonsPanel.add(okButton);
    buttonsPanel.add(cancelButton);

    JPanel mainPanel = new TransparentPanel(new GridBagLayout());
    mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 10, 0, 10));

    GridBagConstraints mainPanelConstraints = new GridBagConstraints();
    mainPanelConstraints.anchor = GridBagConstraints.NORTH;
    mainPanelConstraints.fill = GridBagConstraints.BOTH;
    mainPanelConstraints.gridx = 0;
    mainPanelConstraints.gridy = 0;
    mainPanelConstraints.weightx = 1;
    mainPanelConstraints.weighty = 1;
    mainPanel.add(messagePanel, mainPanelConstraints);

    mainPanelConstraints.anchor = GridBagConstraints.SOUTHEAST;
    mainPanelConstraints.fill = GridBagConstraints.NONE;
    mainPanelConstraints.gridy = 1;
    mainPanelConstraints.weightx = 0;
    mainPanelConstraints.weighty = 0;
    mainPanel.add(buttonsPanel, mainPanelConstraints);

    this.getContentPane().add(mainPanel);
  }
コード例 #2
0
ファイル: SelectAvatarMenu.java プロジェクト: Echo-tcx/Jitsi
  /** Init visible components. */
  private void init() {
    TransparentPanel panel = new TransparentPanel(new BorderLayout());

    panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    // Title label
    JLabel titleLabel =
        new JLabel(GuiActivator.getResources().getI18NString("service.gui.avatar.RECENT_ICONS"));
    titleLabel.setFont(titleLabel.getFont().deriveFont(Font.BOLD));

    // fix for displaying text in menu
    // when using a dark OS theme (as default one in ubuntu)
    titleLabel.setForeground(new JMenuItem().getForeground());

    panel.add(titleLabel, BorderLayout.NORTH);

    // Init recent images grid
    TransparentPanel recentImagesGrid = new TransparentPanel();
    recentImagesGrid.setLayout(new GridLayout(0, IMAGES_PER_COLUMN));

    Dimension thumbsize = new Dimension(THUMB_WIDTH, THUMB_HEIGHT);
    for (int i = 0; i < MAX_STORED_IMAGES; i++) {
      this.recentImagesButtons[i] = new SIPCommButton(null);
      this.recentImagesButtons[i].setBorder(BorderFactory.createEtchedBorder());
      this.recentImagesButtons[i].setMaximumSize(thumbsize);
      this.recentImagesButtons[i].setMinimumSize(thumbsize);
      this.recentImagesButtons[i].setPreferredSize(thumbsize);
      this.recentImagesButtons[i].addActionListener(this);
      this.recentImagesButtons[i].setName("" + i);
      recentImagesGrid.add(this.recentImagesButtons[i]);
    }

    panel.add(recentImagesGrid, BorderLayout.CENTER);

    // Action buttons
    TransparentPanel buttonsPanel = new TransparentPanel();
    buttonsPanel.setLayout(new GridLayout(0, 1));

    // we use this menu item just to get its foreground color.
    Color linkColor = new JMenuItem().getForeground();

    addActionButton(
        buttonsPanel,
        this,
        GuiActivator.getResources().getI18NString("service.gui.avatar.CHOOSE_ICON"),
        CHOSE_BUTTON_NAME,
        linkColor);
    addActionButton(
        buttonsPanel,
        this,
        GuiActivator.getResources().getI18NString("service.gui.avatar.REMOVE_ICON"),
        REMOVE_BUTTON_NAME,
        linkColor);
    addActionButton(
        buttonsPanel,
        this,
        GuiActivator.getResources().getI18NString("service.gui.avatar.CLEAR_RECENT"),
        CLEAR_BUTTON_NAME,
        linkColor);

    panel.add(buttonsPanel, BorderLayout.SOUTH);

    this.setLayout(new BorderLayout());
    this.add(panel, BorderLayout.CENTER);
  }