コード例 #1
0
ファイル: SettingsTab.java プロジェクト: NathanR78/ATLauncher
  public SettingsTab() {
    RelocalizationManager.addListener(this);
    setLayout(new BorderLayout());

    tabbedPane = new JTabbedPane(JTabbedPane.TOP);
    tabbedPane.setBackground(App.THEME.getBaseColor());

    tabbedPane.setFont(App.THEME.getDefaultFont().deriveFont(17.0F));
    for (Tab tab : this.tabs) {
      this.tabbedPane.addTab(tab.getTitle(), (JPanel) tab);
    }
    tabbedPane.setBackground(App.THEME.getTabBackgroundColor());
    tabbedPane.setOpaque(true);

    add(tabbedPane, BorderLayout.CENTER);

    bottomPanel = new JPanel();
    bottomPanel.add(saveButton);

    add(bottomPanel, BorderLayout.SOUTH);
    saveButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            if (javaSettingsTab.isValidJavaPath()
                && javaSettingsTab.isValidJavaParamaters()
                && networkSettingsTab.isValidConcurrentConnections()
                && networkSettingsTab.isValidProxyPort()
                && networkSettingsTab.canConnectWithProxy()
                && toolsSettingsTab.isValidServerCheckerWait()) {
              boolean reloadLocalizationTable = generalSettingsTab.reloadLocalizationTable();
              boolean reloadPacksPanel = generalSettingsTab.needToReloadPacksPanel();
              boolean restartServerChecker = toolsSettingsTab.needToRestartServerChecker();
              generalSettingsTab.save();
              javaSettingsTab.save();
              networkSettingsTab.save();
              loggingSettingsTab.save();
              toolsSettingsTab.save();
              App.settings.saveProperties();
              SettingsManager.post();
              if (reloadLocalizationTable) {
                RelocalizationManager.post();
              }
              if (reloadPacksPanel) {
                App.settings.reloadPacksPanel();
              }
              if (restartServerChecker) {
                App.settings.startCheckingServers();
              }
              App.TOASTER.pop("Settings Saved");
            }
          }
        });
  }
コード例 #2
0
ファイル: CityAndPrice.java プロジェクト: zhurui536/logistics
  public CityAndPrice() {
    font = new FontFactory();
    setLayout(new BorderLayout(0, 0));

    JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.LEFT);
    tabbedPane.setOpaque(false);
    tabbedPane.setFont(font.getTabbeFont());
    add(tabbedPane, BorderLayout.CENTER);

    JPanel panel = new City();
    panel.setOpaque(false);
    tabbedPane.addTab("", null, panel, "所有城市");

    JPanel panel_1 = new Price();
    panel_1.setOpaque(false);
    tabbedPane.addTab("", null, panel_1, "城际运费");
  }
コード例 #3
0
  private void makeFrame(final Editor editor) {
    dialog = new JFrame(title);
    dialog.setMinimumSize(new Dimension(750, 500));
    tabbedPane = new JTabbedPane();

    makeAndShowTab(false, true);

    tabbedPane.addTab("Libraries", null, librariesContributionTab.panel, "Libraries");
    tabbedPane.setMnemonicAt(0, KeyEvent.VK_1);

    tabbedPane.addTab("Modes", null, modesContributionTab.panel, "Modes");
    tabbedPane.setMnemonicAt(1, KeyEvent.VK_2);

    tabbedPane.addTab("Tools", null, toolsContributionTab.panel, "Tools");
    tabbedPane.setMnemonicAt(2, KeyEvent.VK_3);

    tabbedPane.addTab("Examples", null, examplesContributionTab.panel, "Examples");
    tabbedPane.setMnemonicAt(3, KeyEvent.VK_4);

    tabbedPane.addTab("Updates", null, updatesContributionTab.panel, "Updates");
    tabbedPane.setMnemonicAt(4, KeyEvent.VK_5);

    tabbedPane.setUI(new SpacedTabbedPaneUI());
    tabbedPane.setBackground(new Color(0x132638));
    tabbedPane.setOpaque(true);

    for (int i = 0; i < 5; i++) {
      tabbedPane.setToolTipTextAt(i, null);
    }

    makeAndSetTabComponents();

    tabbedPane.addChangeListener(
        new ChangeListener() {

          @Override
          public void stateChanged(ChangeEvent e) {
            for (int i = 0; i < 4; i++) {
              tabLabels[i].setBackground(new Color(0x2d4251));
              tabLabels[i].setForeground(Color.WHITE);
            }
            updateTabPanel.setBackground(new Color(0x2d4251));
            updateTabLabel.setForeground(Color.WHITE);
            int currentIndex = tabbedPane.getSelectedIndex();
            if (currentIndex != 4) {
              tabbedPane
                  .getTabComponentAt(tabbedPane.getSelectedIndex())
                  .setBackground(new Color(0xe0fffd));
              tabbedPane
                  .getTabComponentAt(tabbedPane.getSelectedIndex())
                  .setForeground(Color.BLACK);
            } else {
              updateTabPanel.setBackground(new Color(0xe0fffd));
              updateTabLabel.setForeground(Color.BLACK);
            }
            getActiveTab().contributionListPanel.scrollPane.requestFocusInWindow();
            //        // When the tab is changed update status to the current selected panel
            //        ContributionPanel currentPanel = getActiveTab().contributionListPanel
            //          .getSelectedPanel();
            //        if (currentPanel != null) {
            //          getActiveTab().contributionListPanel.setSelectedPanel(currentPanel);
            //        }
          }
        });

    //    tabbedPane.setSize(450, 400);
    setLayout();

    restartButton = new JButton(Language.text("contrib.restart"));
    restartButton.setVisible(false);
    restartButton.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {

            Iterator<Editor> iter = editor.getBase().getEditors().iterator();
            while (iter.hasNext()) {
              Editor ed = iter.next();
              if (ed.getSketch().isModified()) {
                int option =
                    Messages.showYesNoQuestion(
                        editor,
                        title,
                        Language.text("contrib.unsaved_changes"),
                        Language.text("contrib.unsaved_changes.prompt"));

                if (option == JOptionPane.NO_OPTION) return;
                else break;
              }
            }

            // Thanks to http://stackoverflow.com/a/4160543
            StringBuilder cmd = new StringBuilder();
            cmd.append(
                System.getProperty("java.home")
                    + File.separator
                    + "bin"
                    + File.separator
                    + "java ");
            for (String jvmArg : ManagementFactory.getRuntimeMXBean().getInputArguments()) {
              cmd.append(jvmArg + " ");
            }
            cmd.append("-cp ")
                .append(ManagementFactory.getRuntimeMXBean().getClassPath())
                .append(" ");
            cmd.append(Base.class.getName());

            try {
              Runtime.getRuntime().exec(cmd.toString());
              System.exit(0);
            } catch (IOException e) {
              e.printStackTrace();
            }
          }
        });

    Toolkit.setIcon(dialog);
    registerDisposeListeners();

    dialog.pack();
    dialog.setLocationRelativeTo(null);
  }
コード例 #4
0
  public BreakpointHitEditor(
      final Debugger debugger,
      final DebuggerPane debuggerPane,
      final BreakpointHitNode breakpointHitNode) {
    super(new BorderLayout());
    setOpaque(false);
    JTabbedPane tabbedPane = new JTabbedPane();
    tabbedPane.setOpaque(false);
    JPanel breakpointHitExecutionPane = new JPanel(new GridBagLayout());
    breakpointHitExecutionPane.setBorder(BorderFactory.createEmptyBorder(2, 5, 5, 5));
    breakpointHitExecutionPane.setOpaque(false);
    hit = breakpointHitNode.getUserObject();
    int y = 0;
    breakpointHitExecutionPane.add(
        new JLabel("Query:"),
        new GridBagConstraints(
            0,
            y++,
            1,
            1,
            0,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(0, 0, 0, 0),
            0,
            0));
    SqlTextArea sqlTextArea = new SqlTextArea();
    String sql = hit.getSQL();
    String parameterDescription = hit.getParameterDescription();
    if (parameterDescription != null) {
      sql += "\n -> " + parameterDescription;
    }
    sqlTextArea.setText(sql + "\n");
    sqlTextArea.setCaretPosition(0);
    breakpointHitExecutionPane.add(
        new RTextScrollPane(sqlTextArea),
        new GridBagConstraints(
            0,
            y++,
            1,
            1,
            1,
            1,
            GridBagConstraints.WEST,
            GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 0),
            0,
            0));
    if (hit.isBeforeExecution()) {
      replaceCheckbox = new JCheckBox("Replace with statement");
      replaceCheckbox.setOpaque(false);
      replaceCheckbox.addItemListener(
          new ItemListener() {
            @Override
            public void itemStateChanged(ItemEvent e) {
              adjustStates();
            }
          });
      breakpointHitExecutionPane.add(
          replaceCheckbox,
          new GridBagConstraints(
              0,
              y++,
              1,
              1,
              0,
              0,
              GridBagConstraints.WEST,
              GridBagConstraints.NONE,
              new Insets(5, 0, 0, 0),
              0,
              0));
      replaceTextArea = new SqlTextArea();
      replacePane = new RTextScrollPane(replaceTextArea);
      breakpointHitExecutionPane.add(
          replacePane,
          new GridBagConstraints(
              0,
              y++,
              1,
              1,
              1,
              1,
              GridBagConstraints.WEST,
              GridBagConstraints.BOTH,
              new Insets(2, 20, 0, 0),
              0,
              0));
    }
    JPanel executionTypePane = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
    // For now, this choice is not exposed.
    executionTypePane.setVisible(hit.isBeforeExecution());
    executionTypePane.setOpaque(false);
    ButtonGroup executionTypeGroup = new ButtonGroup();

    final JRadioButton executeTypeNoneRadioButton = new JRadioButton("Execute");
    executeTypeNoneRadioButton.setOpaque(false);
    executeTypeNoneRadioButton.setSelected(true);
    executionTypeGroup.add(executeTypeNoneRadioButton);
    executionTypePane.add(executeTypeNoneRadioButton);

    final JRadioButton executeTypeBreakRadioButton = new JRadioButton("Execute and break");
    executeTypeBreakRadioButton.setOpaque(false);
    executionTypeGroup.add(executeTypeBreakRadioButton);
    executionTypePane.add(executeTypeBreakRadioButton);

    final JRadioButton executeTypeSkipRadioButton = new JRadioButton("Skip");
    executeTypeSkipRadioButton.setOpaque(false);
    executionTypeGroup.add(executeTypeSkipRadioButton);
    executionTypePane.add(executeTypeSkipRadioButton);

    final JRadioButton executeTypeFailRadioButton = new JRadioButton("Throw exception");
    executeTypeFailRadioButton.setOpaque(false);
    executionTypeGroup.add(executeTypeFailRadioButton);
    executionTypePane.add(executeTypeFailRadioButton);

    breakpointHitExecutionPane.add(
        executionTypePane,
        new GridBagConstraints(
            0,
            y++,
            1,
            1,
            0,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 0, 0, 0),
            0,
            0));
    JPanel buttonPane = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0));
    buttonPane.setOpaque(false);
    buttonPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 0, 5));
    JButton applyButton = new JButton("Proceed");
    applyButton.setOpaque(false);
    applyButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            if (hit.isBeforeExecution()) {
              String replacementSQL = null;
              ExecutionType type = RUN;
              if (executeTypeNoneRadioButton.isSelected()) {
                type = RUN;
                replacementSQL = replaceCheckbox.isSelected() ? replaceTextArea.getText() : null;
              } else if (executeTypeBreakRadioButton.isSelected()) {
                type = STEP;
                replacementSQL = replaceCheckbox.isSelected() ? replaceTextArea.getText() : null;
              } else if (executeTypeSkipRadioButton.isSelected()) {
                type = SKIP;
              } else if (executeTypeFailRadioButton.isSelected()) {
                type = FAIL;
              }

              hit.setExecutionType(type, replacementSQL);
            } else {
              hit.setExecutionType(RUN, null);
            }
            debuggerPane.proceedBreakpointHit(breakpointHitNode);
          }
        });
    buttonPane.add(applyButton);
    breakpointHitExecutionPane.add(
        buttonPane,
        new GridBagConstraints(
            0,
            y,
            1,
            1,
            1,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(0, 0, 0, 0),
            0,
            0));
    adjustStates();
    tabbedPane.addTab("Execution", breakpointHitExecutionPane);
    tabbedPane.addTab(
        "Editor",
        new EditorsPane(
            new QueryExecutorCreator() {
              @Override
              public QueryExecutor createQueryExecutor() {
                return debugger.createBreakpointHitStatementExecutor(hit.getThreadID());
              }
            },
            false));
    add(tabbedPane);
  }
コード例 #5
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);

    // =========================================================================================
  }
コード例 #6
0
ファイル: ClientGUI.java プロジェクト: pdickey6/SimpleChat
  private void SetupUI(String loginID) {
    chatFrame = new JFrame("Chat " + loginID);
    PrivateMessageDialog = new JDialog(chatFrame, true);
    PvtMsgPanel = new javax.swing.JPanel();
    SendPrivate = new javax.swing.JButton();
    PrivateInput = new javax.swing.JTextArea();
    PvtUserId = new javax.swing.JTextField();
    RecipientLabel = new javax.swing.JLabel();
    MessageLabel = new javax.swing.JLabel();
    MainWindowTabs = new javax.swing.JTabbedPane();
    ChatWindow = new javax.swing.JPanel();
    ChatDisplayScroll = new javax.swing.JScrollPane();
    MessageDisplay = new javax.swing.JTextArea();
    MessageScroll = new javax.swing.JScrollPane();
    MessageInput = new javax.swing.JTextArea();
    Send = new javax.swing.JButton();
    PrivateMsg = new javax.swing.JButton();
    DrawPadButton = new javax.swing.JButton();
    Availability = new javax.swing.JToggleButton();
    SettingsWindow = new javax.swing.JPanel();
    settingsChatPanel = new javax.swing.JPanel();
    SetChannelButton = new javax.swing.JButton();
    ChannelToSetTo = new javax.swing.JTextField();
    ForwardTo = new javax.swing.JTextField();
    ForwardButton = new javax.swing.JButton();
    blockPanel = new javax.swing.JPanel();
    WhoIBlockButton = new javax.swing.JButton();
    BlockButton = new javax.swing.JButton();
    WhoBlocksMeButton = new javax.swing.JButton();
    UnblockButton = new javax.swing.JButton();
    UserToChangeBlock = new javax.swing.JTextField();
    networkPanel = new javax.swing.JPanel();
    PortInput = new javax.swing.JTextField();
    SetPortButton = new javax.swing.JButton();
    HostInput = new javax.swing.JTextField();
    SetHostButton = new javax.swing.JButton();
    GetHost = new javax.swing.JButton();
    GetPort = new javax.swing.JButton();

    // Customize Form
    Send.setBackground(Color.decode("#16A085"));
    SendPrivate.setBackground(Color.decode("#16A085"));
    Availability.setBackground(Color.decode("#2ECC71"));
    MessageDisplay.setEditable(false);
    PrivateMessageDialog.setSize(405, 335);

    chatFrame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    chatFrame.setBackground(new java.awt.Color(52, 73, 94));

    MainWindowTabs.setBackground(new java.awt.Color(44, 62, 80));
    MainWindowTabs.setOpaque(true);

    // Netbeans
    PvtMsgPanel.setBackground(new java.awt.Color(52, 73, 94));
    SendPrivate.setText("Send");
    PrivateInput.setBackground(new java.awt.Color(127, 140, 141));
    PrivateInput.setColumns(20);
    PrivateInput.setFont(new java.awt.Font("Arial", 0, 13));
    PrivateInput.setLineWrap(true);
    PrivateInput.setRows(5);
    PvtUserId.setBackground(new java.awt.Color(127, 140, 141));
    RecipientLabel.setForeground(new java.awt.Color(240, 240, 240));
    RecipientLabel.setText("Recipient Id:");
    MessageLabel.setForeground(new java.awt.Color(240, 240, 240));
    MessageLabel.setText("Message:");

    javax.swing.GroupLayout PvtMsgPanelLayout = new javax.swing.GroupLayout(PvtMsgPanel);
    PvtMsgPanel.setLayout(PvtMsgPanelLayout);
    PvtMsgPanelLayout.setHorizontalGroup(
        PvtMsgPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                PvtMsgPanelLayout.createSequentialGroup()
                    .addContainerGap()
                    .addGroup(
                        PvtMsgPanelLayout.createParallelGroup(
                                javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(PvtUserId)
                            .addGroup(
                                PvtMsgPanelLayout.createParallelGroup(
                                        javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(
                                        SendPrivate,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        128,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGroup(
                                        PvtMsgPanelLayout.createParallelGroup(
                                                javax.swing.GroupLayout.Alignment.TRAILING, false)
                                            .addComponent(
                                                PrivateInput,
                                                javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(
                                                PvtMsgPanelLayout.createSequentialGroup()
                                                    .addComponent(RecipientLabel)
                                                    .addGap(310, 310, 310))))
                            .addComponent(MessageLabel))
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
    PvtMsgPanelLayout.setVerticalGroup(
        PvtMsgPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                PvtMsgPanelLayout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(RecipientLabel)
                    .addGap(1, 1, 1)
                    .addComponent(
                        PvtUserId,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        javax.swing.GroupLayout.DEFAULT_SIZE,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addComponent(MessageLabel)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(
                        PrivateInput,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        168,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(
                        SendPrivate,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        35,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

    javax.swing.GroupLayout PrivateMessageDialogLayout =
        new javax.swing.GroupLayout(PrivateMessageDialog.getContentPane());
    PrivateMessageDialog.getContentPane().setLayout(PrivateMessageDialogLayout);
    PrivateMessageDialogLayout.setHorizontalGroup(
        PrivateMessageDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(
                PvtMsgPanel,
                javax.swing.GroupLayout.DEFAULT_SIZE,
                javax.swing.GroupLayout.DEFAULT_SIZE,
                Short.MAX_VALUE));
    PrivateMessageDialogLayout.setVerticalGroup(
        PrivateMessageDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                PrivateMessageDialogLayout.createSequentialGroup()
                    .addComponent(
                        PvtMsgPanel,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        javax.swing.GroupLayout.DEFAULT_SIZE,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 3, Short.MAX_VALUE)));

    MainWindowTabs.setBackground(new java.awt.Color(52, 73, 94));
    ChatWindow.setBackground(new java.awt.Color(52, 73, 94));
    ChatWindow.setPreferredSize(new java.awt.Dimension(430, 600));
    ChatWindow.setVerifyInputWhenFocusTarget(false);

    ChatDisplayScroll.setAutoscrolls(true);
    MessageDisplay.setEditable(false);
    MessageDisplay.setBackground(new java.awt.Color(127, 140, 141));
    MessageDisplay.setColumns(20);
    MessageDisplay.setFont(new java.awt.Font("Arial", 0, 13));
    MessageDisplay.setLineWrap(true);
    MessageDisplay.setRows(5);
    ChatDisplayScroll.setViewportView(MessageDisplay);

    MessageInput.setBackground(new java.awt.Color(127, 140, 141));
    MessageInput.setColumns(2);
    MessageInput.setLineWrap(true);
    MessageInput.setRows(3);
    MessageScroll.setViewportView(MessageInput);

    Send.setText("Send");
    PrivateMsg.setText("Private Message");
    DrawPadButton.setText("Draw Pad");
    Availability.setText("Available");

    javax.swing.GroupLayout ChatWindowLayout = new javax.swing.GroupLayout(ChatWindow);
    ChatWindow.setLayout(ChatWindowLayout);
    ChatWindowLayout.setHorizontalGroup(
        ChatWindowLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                ChatWindowLayout.createSequentialGroup()
                    .addContainerGap()
                    .addGroup(
                        ChatWindowLayout.createParallelGroup(
                                javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(
                                ChatDisplayScroll, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(
                                javax.swing.GroupLayout.Alignment.TRAILING,
                                ChatWindowLayout.createSequentialGroup()
                                    .addComponent(MessageScroll)
                                    .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(
                                        Send,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        85,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(
                                javax.swing.GroupLayout.Alignment.TRAILING,
                                ChatWindowLayout.createSequentialGroup()
                                    .addComponent(
                                        DrawPadButton,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        122,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(
                                        PrivateMsg,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        146,
                                        Short.MAX_VALUE)
                                    .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(
                                        Availability,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        122,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addContainerGap()));
    ChatWindowLayout.setVerticalGroup(
        ChatWindowLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                ChatWindowLayout.createSequentialGroup()
                    .addGap(7, 7, 7)
                    .addComponent(
                        ChatDisplayScroll,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        289,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(
                        ChatWindowLayout.createParallelGroup(
                                javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(
                                MessageScroll,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                67,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(
                                Send,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                Short.MAX_VALUE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(
                        ChatWindowLayout.createParallelGroup(
                                javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(DrawPadButton)
                            .addComponent(PrivateMsg)
                            .addComponent(Availability))
                    .addContainerGap()));

    MainWindowTabs.addTab("Chat", ChatWindow);
    SettingsWindow.setBackground(new java.awt.Color(52, 73, 94));
    settingsChatPanel.setBackground(new java.awt.Color(52, 73, 94));
    settingsChatPanel.setBorder(
        javax.swing.BorderFactory.createTitledBorder(
            new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED),
            "Chat",
            javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
            javax.swing.border.TitledBorder.DEFAULT_POSITION,
            null,
            new java.awt.Color(240, 240, 240)));

    SetChannelButton.setText("Set Channel");
    SetChannelButton.setBorderPainted(false);
    ChannelToSetTo.setBackground(new java.awt.Color(127, 140, 141));
    ForwardTo.setBackground(new java.awt.Color(127, 140, 141));

    ForwardButton.setText("Forward");
    ForwardButton.setBorderPainted(false);

    javax.swing.GroupLayout settingsChatPanelLayout =
        new javax.swing.GroupLayout(settingsChatPanel);
    settingsChatPanel.setLayout(settingsChatPanelLayout);
    settingsChatPanelLayout.setHorizontalGroup(
        settingsChatPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                settingsChatPanelLayout
                    .createSequentialGroup()
                    .addContainerGap(80, Short.MAX_VALUE)
                    .addGroup(
                        settingsChatPanelLayout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addGroup(
                                javax.swing.GroupLayout.Alignment.LEADING,
                                settingsChatPanelLayout
                                    .createSequentialGroup()
                                    .addComponent(
                                        ChannelToSetTo,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        151,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(SetChannelButton))
                            .addGroup(
                                javax.swing.GroupLayout.Alignment.LEADING,
                                settingsChatPanelLayout
                                    .createSequentialGroup()
                                    .addComponent(
                                        ForwardTo,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        151,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(
                                        ForwardButton,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        Short.MAX_VALUE)))
                    .addContainerGap(68, Short.MAX_VALUE)));
    settingsChatPanelLayout.setVerticalGroup(
        settingsChatPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                settingsChatPanelLayout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addGroup(
                        settingsChatPanelLayout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(
                                ChannelToSetTo,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(SetChannelButton))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(
                        settingsChatPanelLayout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(ForwardButton)
                            .addComponent(
                                ForwardTo,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

    blockPanel.setBackground(new java.awt.Color(52, 73, 94));
    blockPanel.setBorder(
        javax.swing.BorderFactory.createTitledBorder(
            new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED),
            "Block",
            javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
            javax.swing.border.TitledBorder.DEFAULT_POSITION,
            null,
            new java.awt.Color(240, 240, 240)));
    blockPanel.setForeground(new java.awt.Color(255, 255, 255));

    WhoIBlockButton.setText("My Blocks");
    BlockButton.setBorderPainted(false);
    BlockButton.setText("Block");
    WhoBlocksMeButton.setText("Blocks Me");
    UnblockButton.setText("Unblock");
    UnblockButton.setActionCommand("Unblock");
    UnblockButton.setBorderPainted(false);

    UserToChangeBlock.setBackground(new java.awt.Color(127, 140, 141));

    javax.swing.GroupLayout blockPanelLayout = new javax.swing.GroupLayout(blockPanel);
    blockPanel.setLayout(blockPanelLayout);
    blockPanelLayout.setHorizontalGroup(
        blockPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                javax.swing.GroupLayout.Alignment.TRAILING,
                blockPanelLayout
                    .createSequentialGroup()
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(
                        UserToChangeBlock,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        151,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(
                        blockPanelLayout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(
                                blockPanelLayout
                                    .createSequentialGroup()
                                    .addComponent(
                                        BlockButton,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        75,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(WhoIBlockButton))
                            .addGroup(
                                blockPanelLayout
                                    .createSequentialGroup()
                                    .addComponent(
                                        UnblockButton,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        75,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(WhoBlocksMeButton)))
                    .addGap(23, 23, 23)));
    blockPanelLayout.setVerticalGroup(
        blockPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                blockPanelLayout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addGroup(
                        blockPanelLayout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(
                                blockPanelLayout
                                    .createSequentialGroup()
                                    .addGroup(
                                        blockPanelLayout
                                            .createParallelGroup(
                                                javax.swing.GroupLayout.Alignment.BASELINE)
                                            .addComponent(BlockButton)
                                            .addComponent(WhoIBlockButton))
                                    .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addGroup(
                                        blockPanelLayout
                                            .createParallelGroup(
                                                javax.swing.GroupLayout.Alignment.BASELINE)
                                            .addComponent(UnblockButton)
                                            .addComponent(WhoBlocksMeButton)))
                            .addGroup(
                                blockPanelLayout
                                    .createSequentialGroup()
                                    .addGap(13, 13, 13)
                                    .addComponent(
                                        UserToChangeBlock,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

    networkPanel.setBackground(new java.awt.Color(52, 73, 94));
    networkPanel.setBorder(
        javax.swing.BorderFactory.createTitledBorder(
            new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED),
            "Network",
            javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
            javax.swing.border.TitledBorder.DEFAULT_POSITION,
            null,
            new java.awt.Color(240, 240, 240)));

    PortInput.setBackground(new java.awt.Color(127, 140, 141));
    SetPortButton.setText("Set Port");
    HostInput.setBackground(new java.awt.Color(127, 140, 141));
    SetHostButton.setText("Set Host");
    GetHost.setText("Get Host");
    GetPort.setText("Get Port");

    javax.swing.GroupLayout networkPanelLayout = new javax.swing.GroupLayout(networkPanel);
    networkPanel.setLayout(networkPanelLayout);
    networkPanelLayout.setHorizontalGroup(
        networkPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                javax.swing.GroupLayout.Alignment.TRAILING,
                networkPanelLayout
                    .createSequentialGroup()
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(
                        networkPanelLayout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(PortInput)
                            .addComponent(
                                HostInput,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                151,
                                javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(
                        networkPanelLayout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(
                                networkPanelLayout
                                    .createSequentialGroup()
                                    .addGap(6, 6, 6)
                                    .addComponent(
                                        SetHostButton,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        Short.MAX_VALUE))
                            .addGroup(
                                networkPanelLayout
                                    .createSequentialGroup()
                                    .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(
                                        SetPortButton,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        79,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(
                        networkPanelLayout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(
                                GetPort,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                Short.MAX_VALUE)
                            .addComponent(GetHost))
                    .addGap(25, 25, 25)));
    networkPanelLayout.setVerticalGroup(
        networkPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                networkPanelLayout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addGroup(
                        networkPanelLayout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(
                                PortInput,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(SetPortButton)
                            .addComponent(GetPort))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(
                        networkPanelLayout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(
                                HostInput,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(SetHostButton)
                            .addComponent(GetHost))
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

    javax.swing.GroupLayout SettingsWindowLayout = new javax.swing.GroupLayout(SettingsWindow);
    SettingsWindow.setLayout(SettingsWindowLayout);
    SettingsWindowLayout.setHorizontalGroup(
        SettingsWindowLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                SettingsWindowLayout.createSequentialGroup()
                    .addContainerGap()
                    .addGroup(
                        SettingsWindowLayout.createParallelGroup(
                                javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(
                                networkPanel,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                Short.MAX_VALUE)
                            .addComponent(
                                settingsChatPanel,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                Short.MAX_VALUE)
                            .addComponent(
                                blockPanel,
                                javax.swing.GroupLayout.Alignment.TRAILING,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                Short.MAX_VALUE))
                    .addContainerGap()));
    SettingsWindowLayout.setVerticalGroup(
        SettingsWindowLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                SettingsWindowLayout.createSequentialGroup()
                    .addGap(20, 20, 20)
                    .addComponent(
                        networkPanel,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        javax.swing.GroupLayout.DEFAULT_SIZE,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(33, 33, 33)
                    .addComponent(
                        blockPanel,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        javax.swing.GroupLayout.DEFAULT_SIZE,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(31, 31, 31)
                    .addComponent(
                        settingsChatPanel,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        javax.swing.GroupLayout.DEFAULT_SIZE,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(34, Short.MAX_VALUE)));

    MainWindowTabs.addTab("Settings", SettingsWindow);

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(chatFrame.getContentPane());
    chatFrame.getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addComponent(
                        MainWindowTabs,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        413,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 0, Short.MAX_VALUE)));
    layout.setVerticalGroup(
        layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(
                MainWindowTabs,
                javax.swing.GroupLayout.PREFERRED_SIZE,
                439,
                javax.swing.GroupLayout.PREFERRED_SIZE));

    // ##################### Listeners #####################

    // display scrollbar vertical update
    ChatDisplayScroll.getVerticalScrollBar()
        .addAdjustmentListener(
            new AdjustmentListener() {
              public void adjustmentValueChanged(AdjustmentEvent event) {
                event.getAdjustable().setValue(event.getAdjustable().getMaximum());
              }
            });

    MessageInput.addKeyListener(
        new KeyListener() {
          @Override
          public void keyPressed(KeyEvent arg0) {
            int keyCode = arg0.getKeyCode();
            if (keyCode == 10) { // enter key
              String message = MessageInput.getText();
              if (message != null && message.length() > 0) {
                client.handleMessageFromClientUI(message);
                MessageInput.setText("");
                arg0.consume();
              }
            }
          }

          @Override
          public void keyTyped(KeyEvent arg0) {}

          @Override
          public void keyReleased(KeyEvent arg0) {}
        });

    SetChannelButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String command = SetChannelButton.getActionCommand();
            if (command == "Set Channel") {
              // get new channel
              String channel = ChannelToSetTo.getText();
              if (channel.length() > 0) {
                client.handleMessageFromClientUI("#setchannel " + channel);
                ChannelToSetTo.setText("");
                MainWindowTabs.setSelectedIndex(0);
              }
            }
          }
        });

    SetPortButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String command = SetPortButton.getActionCommand();
            if (command == "Set Port") {
              // get new port
              String port = PortInput.getText();
              if (port.length() > 0) {
                client.connectionClosed();
                client.handleMessageFromClientUI("#setport " + port);
                MainWindowTabs.setSelectedIndex(0);
                PortInput.setText("");
              }
            }
          }
        });

    GetPort.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String command = GetPort.getActionCommand();
            if (command == "Get Port") {
              client.handleMessageFromClientUI("#getport");
              MainWindowTabs.setSelectedIndex(0);
            }
          }
        });

    SetHostButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String command = SetHostButton.getActionCommand();
            if (command == "Set Host") {
              // get new host
              String host = HostInput.getText();
              if (host.length() > 0) {
                client.connectionClosed();
                client.handleMessageFromClientUI("#sethost " + host);
                MainWindowTabs.setSelectedIndex(0);
                HostInput.setText("");
              }
            }
          }
        });

    GetHost.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String command = GetHost.getActionCommand();
            if (command == "Get Host") {
              client.handleMessageFromClientUI("#gethost");
              MainWindowTabs.setSelectedIndex(0);
            }
          }
        });

    WhoIBlockButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String command = WhoIBlockButton.getActionCommand();
            if (command == "My Blocks") {
              client.handleMessageFromClientUI("#whoiblock");
              MainWindowTabs.setSelectedIndex(0);
            }
          }
        });

    WhoBlocksMeButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String command = WhoBlocksMeButton.getActionCommand();
            if (command == "Blocks Me") {
              client.handleMessageFromClientUI("#whoblocksme");
              MainWindowTabs.setSelectedIndex(0);
            }
          }
        });

    BlockButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String command = BlockButton.getActionCommand();
            if (command == "Block") {
              // get blockee
              String blockee = UserToChangeBlock.getText();
              if (blockee.length() > 0) {
                client.handleMessageFromClientUI("#block " + blockee);
                UserToChangeBlock.setText("");
                MainWindowTabs.setSelectedIndex(0);
              }
            }
          }
        });

    UnblockButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String command = UnblockButton.getActionCommand();
            if (command == "Unblock") {
              // get unblockee
              String unblockee = UserToChangeBlock.getText();
              client.handleMessageFromClientUI("#unblock " + unblockee);
              UserToChangeBlock.setText("");
              MainWindowTabs.setSelectedIndex(0);
            }
          }
        });

    ForwardButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String command = ForwardButton.getActionCommand();
            if (command == "Forward") {
              // get new monitor
              String monitor = ForwardTo.getText();
              if (monitor.length() > 0) {
                client.handleMessageFromClientUI("#forward " + monitor);
                ForwardTo.setText("");
                MainWindowTabs.setSelectedIndex(0);
              }
            } else if (command == "Stop Forwarding") {
              client.handleMessageFromClientUI("#endforward");
            }
          }
        });

    Availability.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            if (Availability.isSelected()) {
              client.handleMessageFromClientUI("#notavailable");
              Availability.setText("Unavailable");
              Availability.setBackground(Color.decode("#E74C3C"));
              ForwardButton.setEnabled(false);
              MessageInput.setEnabled(false);
              DrawPadButton.setEnabled(false);
              PrivateMsg.setEnabled(false);
              Send.setEnabled(false);
            } else {
              client.handleMessageFromClientUI("#available");
              Availability.setText("Available");
              Availability.setBackground(Color.decode("#2ECC71"));
              ForwardButton.setEnabled(true);
              MessageInput.setEnabled(true);
              DrawPadButton.setEnabled(true);
              PrivateMsg.setEnabled(true);
              Send.setEnabled(true);
            }
          }
        });

    Send.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String command = Send.getActionCommand();
            if (command == "Send") {
              String message = MessageInput.getText();
              if (message != null && message.length() > 0) {
                client.handleMessageFromClientUI(message);
                MessageInput.setText("");
              }
            }
          }
        });

    DrawPadButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String command = DrawPadButton.getActionCommand();
            if (command == "Draw Pad") {
              drawPad = new ChatDrawPad();
              new OpenDrawPad(drawPad, self);
            }
          }
        });

    PrivateMsg.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String command = PrivateMsg.getActionCommand();
            if (command == "Private Message") {
              PrivateMessageDialog.setVisible(true);
            }
          }
        });

    SendPrivate.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String command = SendPrivate.getActionCommand();
            if (command == "Send") {
              String recipId = PvtUserId.getText();
              String msg = PrivateInput.getText();
              if (recipId.length() > 0 && msg.length() > 0)
                client.handleMessageFromClientUI("#private " + recipId + " " + msg);
              PvtUserId.setText("");
              PrivateInput.setText("");
              PrivateMessageDialog.setVisible(false);
            }
          }
        });

    // Display the window.
    chatFrame.pack();
    chatFrame.setVisible(true);
  }