Example usage for javax.swing JLabel setForeground

List of usage examples for javax.swing JLabel setForeground

Introduction

In this page you can find the example usage for javax.swing JLabel setForeground.

Prototype

@BeanProperty(preferred = true, visualUpdate = true, description = "The foreground color of the component.")
public void setForeground(Color fg) 

Source Link

Document

Sets the foreground color of this component.

Usage

From source file:savant.amino.AminoPlugin.java

/**
 * Create the user-interface which appears within the panel.
 *
 * @param panel provided by Savant/*w  w w  .  j  a v a2 s .  c o m*/
 */
@Override
public void init(JPanel panel) {
    panel.setLayout(new GridLayout(5, 4, 2, 2));

    // Create a label for each amino-acid.  For now, these are just for reference,
    // but we might make them into buttons to change the colour scheme.
    for (AminoAcid a : AminoAcid.values()) {
        JLabel label = new JLabel(a.name, SwingConstants.CENTER);
        label.setOpaque(true);
        label.setBackground(a.color);
        label.setForeground(a == AminoAcid.STOP ? Color.WHITE : Color.BLACK);
        panel.add(label);
    }

    // First time through, create canvasses for any existing gene tracks.  We
    // hook this onto a listener so that we'll know that Savant has fully loaded
    // the plugin before we try to do anything.
    PluginUtils.addPluginListener(new Listener<PluginEvent>() {
        @Override
        public void handleEvent(PluginEvent event) {
            if (event.getType() == PluginEvent.Type.LOADED && event.getPlugin() instanceof AminoPlugin) {
                PluginUtils.removePluginListener(this);
                TrackAdapter[] existingTracks = TrackUtils.getTracks(DataFormat.RICH_INTERVAL);
                for (TrackAdapter t : existingTracks) {
                    createCanvas(t);
                }
            }
        }
    });

    TrackUtils.addTrackListener(new Listener<TrackEvent>() {
        @Override
        public void handleEvent(TrackEvent event) {
            if (event.getType() == TrackEvent.Type.ADDED) {
                createCanvas(event.getTrack());
            }
        }
    });

    NavigationUtils.addLocationChangedListener(new Listener<LocationChangedEvent>() {
        @Override
        public void handleEvent(LocationChangedEvent event) {
            for (TrackAdapter t : TrackUtils.getTracks()) {
                if (t.getDataFormat() == DataFormat.RICH_INTERVAL) {
                    t.getLayerCanvas(AminoPlugin.this).repaint();
                }
            }
        }
    });
}

From source file:ui.panel.UIAccessKeySelect.java

public void runaccessKeySelect() {
    getAccessKeyData();// w w w  .j  a  va 2s. c  o m
    Panel p = new Panel();
    Button b = new Button();
    Label l = new Label();

    setLayout(new BorderLayout());

    JPanel pnlInstruction = p.createPanel(Layouts.flow);
    JLabel lblInstruction = l.createLabel("Access Keys");
    pnlInstruction.setBackground(CustomColor.LightBlue.returnColor());
    lblInstruction.setForeground(Color.white);
    lblInstruction.setFont(new Font("San Serif", Font.PLAIN, 18));
    pnlInstruction.add(lblInstruction);

    JPanel pnlBucketList = p.createPanel(Layouts.border);

    listBucket.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    JScrollPane scrollBucket = new JScrollPane(listBucket);
    Component[] BucketListComponents = { scrollBucket };
    pnlBucketList.add(scrollBucket, BorderLayout.CENTER);

    JPanel pnlButtons = p.createPanel(Layouts.flow);

    JButton btnBack = b.createButton("Back");
    JButton btnSelectElements = b.createButton("Next");
    JButton btnAdd = b.createButton("Generate Access Key");
    JButton btnRefresh = b.createButton("Refresh");

    pnlButtons.add(btnBack);
    pnlButtons.add(btnAdd);
    pnlButtons.add(btnRefresh);
    pnlButtons.add(btnSelectElements);

    add(pnlInstruction, BorderLayout.NORTH);
    add(pnlBucketList, BorderLayout.CENTER);
    add(pnlButtons, BorderLayout.SOUTH);

    btnBack.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            Data.mainFrame.showPanel("license");
        }
    });

    btnRefresh.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            getAccessKeyData();
        }
    });
    btnAdd.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            Data.mainFrame.uiGenerateKey = new UIGenerateKey();
            Data.mainFrame.addPanel(Data.mainFrame.uiGenerateKey, "generateKey");
            Data.mainFrame.pack();
            Data.mainFrame.showPanel("generateKey");
        }
    });

    btnSelectElements.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {

            SwingWorker<Void, Void> mySwingWorker = new SwingWorker<Void, Void>() {
                @Override
                protected Void doInBackground() throws Exception {
                    int selected = listBucket.getSelectedRow();

                    if (selected != -1) {
                        Data.accessKey = (String) listBucket.getModel().getValueAt(selected, 0);
                        Data.mainFrame.qrGenerator = new JavaQR();
                        Data.mainFrame.pack();
                        Data.mainFrame.addPanel(Data.mainFrame.qrGenerator, "generateQR");
                        Data.mainFrame.showPanel("generateQR");
                    } else {
                        JOptionPane.showMessageDialog(Data.mainFrame, "Please Select Access Key", "Error",
                                JOptionPane.ERROR_MESSAGE);
                    }

                    return null;
                }
            };

            Window win = SwingUtilities.getWindowAncestor((AbstractButton) e.getSource());
            final JDialog dialog = new JDialog(win, "Loading", ModalityType.APPLICATION_MODAL);

            mySwingWorker.addPropertyChangeListener(new PropertyChangeListener() {

                @Override
                public void propertyChange(PropertyChangeEvent evt) {
                    if (evt.getPropertyName().equals("state")) {
                        if (evt.getNewValue() == SwingWorker.StateValue.DONE) {
                            dialog.dispose();
                        }
                    }
                }
            });
            mySwingWorker.execute();

            JProgressBar progressBar = new JProgressBar();
            progressBar.setIndeterminate(true);
            JPanel panel = new JPanel(new BorderLayout());
            panel.add(progressBar, BorderLayout.CENTER);
            panel.add(new JLabel("Generating QR Code......."), BorderLayout.PAGE_START);
            dialog.add(panel);
            dialog.pack();
            dialog.setBounds(50, 50, 300, 100);
            dialog.setLocationRelativeTo(Data.mainFrame);
            dialog.setVisible(true);
        }
    });
}

From source file:ui.panel.UIBucketSelect.java

public void runBucketSelect() {
    Panel p = new Panel();
    Button b = new Button();
    Label l = new Label();

    setLayout(new BorderLayout());

    JPanel pnlInstruction = p.createPanel(Layouts.flow);
    JLabel lblInstruction = l.createLabel("Bucket List");
    pnlInstruction.setBackground(CustomColor.LightBlue.returnColor());
    lblInstruction.setForeground(Color.white);
    lblInstruction.setFont(new Font("San Serif", Font.PLAIN, 18));
    pnlInstruction.add(lblInstruction);//w w w  .j av  a 2 s  .  c o m

    JPanel pnlBucketList = p.createPanel(Layouts.border);

    listBucket.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    JScrollPane scrollBucket = new JScrollPane(listBucket);
    scrollBucket.setPreferredSize(new Dimension(300, 150));
    pnlBucketList.add(scrollBucket, BorderLayout.CENTER);

    JPanel pnlButtons = p.createPanel(Layouts.flow);
    JButton btnBack = b.createButton("Back");
    JButton btnSelectElements = b.createButton("Next");
    JButton btnRefresh = b.createButton("Refresh Bucket List");

    pnlButtons.add(btnBack);
    pnlButtons.add(btnRefresh);
    pnlButtons.add(btnSelectElements);

    add(pnlInstruction, BorderLayout.NORTH);
    add(pnlBucketList, BorderLayout.CENTER);
    add(pnlButtons, BorderLayout.SOUTH);
    setVisible(true);

    btnRefresh.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            getBucketData();
        }
    });
    btnSelectElements.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            SwingWorker<Void, Void> mySwingWorker = new SwingWorker<Void, Void>() {
                @Override
                protected Void doInBackground() throws Exception {

                    int selected = listBucket.getSelectedRow();
                    if (selected == -1) {
                        JOptionPane.showMessageDialog(Data.mainFrame, "Please Select a Bucket", "Error",
                                JOptionPane.ERROR_MESSAGE);
                    } else {
                        Data.bucketID = (int) listBucket.getModel().getValueAt(selected, 0);
                        Data.mainFrame.addPanel(Data.mainFrame.uiLicenseDetail = new UILicenseDetail(),
                                "license");
                        Data.mainFrame.pack();
                        Data.mainFrame.showPanel("license");
                    }
                    return null;
                }
            };

            Window win = SwingUtilities.getWindowAncestor((AbstractButton) e.getSource());
            final JDialog dialog = new JDialog(win, "Loading", ModalityType.APPLICATION_MODAL);

            mySwingWorker.addPropertyChangeListener(new PropertyChangeListener() {

                @Override
                public void propertyChange(PropertyChangeEvent evt) {
                    if (evt.getPropertyName().equals("state")) {
                        if (evt.getNewValue() == SwingWorker.StateValue.DONE) {
                            dialog.dispose();
                        }
                    }
                }
            });
            mySwingWorker.execute();

            JProgressBar progressBar = new JProgressBar();
            progressBar.setIndeterminate(true);
            JPanel panel = new JPanel(new BorderLayout());
            panel.add(progressBar, BorderLayout.CENTER);
            panel.add(new JLabel("Retrieving Licenses......."), BorderLayout.PAGE_START);
            dialog.add(panel);
            dialog.pack();
            dialog.setBounds(50, 50, 300, 100);
            dialog.setLocationRelativeTo(Data.mainFrame);
            dialog.setVisible(true);
        }
    });
    btnBack.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            setVisible(false);
            Data.mainFrame.showPanel("inventory");
        }
    });
}

From source file:uk.nhs.cfh.dsp.srth.desktop.modules.querycreationtreepanel.renderer.ReportingQueryStatementTreeCellRenderer.java

/**
 * Sets the font color.//w w w  .j  a  v  a 2  s  .com
 * 
 * @param expression the expression
 * @param label the label
 */
private void setFontColor(QueryExpression expression, JLabel label) {
    if (expression.getRunTimeStatus() == QueryExpression.QueryRunTimeStatus.SKIP) {
        label.setForeground(Color.RED);
    } else {
        label.setForeground(Color.BLACK);
    }
}

From source file:us.paulevans.basicxslt.BasicXSLTFrame.java

/**
 * Builds the south panel//from   w  w  w  . j  a  v  a  2s  . com
 * @return
 */
private JPanel buildSouthPanel() {

    JPanel transformBtnPanel;
    JPanel footerPanel;
    JPanel southPanel;
    JPanel panel;
    JLabel label;
    Font footerPanelFont;
    Font footerPanelFontBold;

    transformBtnPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
    transformBtnPanel.add(
            transformBtn = new JButton(stringFactory.getString(LabelStringFactory.MAIN_FRAME_TRANSFORM_BTN)));
    transformBtnPanel
            .add(exitBtn = new JButton(stringFactory.getString(LabelStringFactory.MAIN_FRAME_EXIT_BTN)));

    footerPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    southPanel = new JPanel(new BorderLayout());
    southPanel.add(transformBtnPanel, BorderLayout.CENTER);
    southPanel.add(footerPanel, BorderLayout.SOUTH);
    footerPanelFont = new Font("arial", Font.PLAIN, 12);
    footerPanelFontBold = new Font("arial", Font.BOLD, 12);
    footerPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));

    panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    panel.add(label = new JLabel(stringFactory.getString(LabelStringFactory.MAIN_FRAME_CURRENT_CONFIGURATION)));
    label.setFont(footerPanelFontBold);
    label.setForeground(Color.BLUE);
    panel.add(currentConfigLabel = new JLabel(userPrefs.getConfiguration()));
    currentConfigLabel.setFont(footerPanelFont);
    footerPanel.add(panel);

    panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    panel.add(label = new JLabel(stringFactory.getString(LabelStringFactory.MAIN_FRAME_TOTAL_TRANSFORM_TIME)));
    label.setFont(footerPanelFontBold);
    label.setForeground(Color.BLUE);
    panel.add(transformTimeLabel = new JLabel(lastTotalTransformTime + " "
            + stringFactory.getString(LabelStringFactory.MAIN_FRAME_MILLISECONDS_ABBREVIATION)));
    transformTimeLabel.setFont(footerPanelFont);
    footerPanel.add(panel);

    transformTimeLabel.setFont(footerPanelFont);
    footerPanel.add(new JLabel(""));
    footerPanel.add(new JLabel(""));
    transformBtn.addActionListener(this);
    exitBtn.addActionListener(this);
    return southPanel;
}

From source file:us.paulevans.basicxslt.SaveAsConfigurationFrame.java

/**
 * Builds the main panel//from w  ww. ja  v a 2 s .  c o m
 * @return
 */
private JPanel buildMainPanel() {

    int row;
    GridBagLayout layout;
    GridBagConstraints constraints;
    JPanel main;
    JLabel label;

    layout = new GridBagLayout();
    constraints = new GridBagConstraints();
    main = new JPanel(layout);
    row = 0;
    GUIUtils.add(main,
            new JLabel(stringFactory.getString(LabelStringFactory.SAVEASCONFIG_FRAME_CURRENT_CONFIGURATION)),
            layout, constraints, row, 0, 1, 1, GridBagConstraints.EAST, GridBagConstraints.NONE,
            GUIUtils.MED_INSETS);
    GUIUtils.add(main, label = new JLabel(userPrefs.getConfiguration()), layout, constraints, row++, 1, 1, 1,
            GridBagConstraints.WEST, GridBagConstraints.NONE, GUIUtils.SMALL_INSETS);
    label.setForeground(Color.BLUE);
    GUIUtils.add(main, new JSeparator(), layout, constraints, row++, 0, 1, 2, 1, 1, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, GUIUtils.MED_INSETS);
    GUIUtils.add(main,
            new JLabel(stringFactory.getString(LabelStringFactory.SAVEASCONFIG_FRAME_CONFIGURATION_NAME)),
            layout, constraints, row, 0, 1, 1, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE,
            GUIUtils.SMALL_INSETS);
    GUIUtils.add(main, new JScrollPane(configurationName = new JTextField(20)), layout, constraints, row++, 1,
            1, 1, GridBagConstraints.WEST, GridBagConstraints.NONE, GUIUtils.SMALL_INSETS);
    GUIUtils.add(main, new JLabel(stringFactory.getString(LabelStringFactory.SAVEASCONFIG_FRAME_MAKE_DEFAULT)),
            layout, constraints, row, 0, 1, 1, GridBagConstraints.EAST, GridBagConstraints.NONE,
            GUIUtils.SMALL_INSETS);
    GUIUtils.add(main, makeDefault = new JCheckBox(), layout, constraints, row++, 1, 1, 1,
            GridBagConstraints.WEST, GridBagConstraints.NONE, GUIUtils.SMALL_INSETS);
    return main;
}

From source file:utybo.branchingstorytree.swing.editor.StoryNodesEditor.java

public StoryNodesEditor() {
    setLayout(new MigLayout("", "[:33%:300px][grow 150]", "[grow][]"));

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    add(scrollPane, "cell 0 0,grow");

    jlist = new JList<>();
    jlist.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    jlist.setCellRenderer(new SubstanceDefaultListCellRenderer() {

        @Override//  www  .ja  v  a2  s.c o m
        public Component getListCellRendererComponent(@SuppressWarnings("rawtypes") JList list, Object o,
                int index, boolean isSelected, boolean cellHasFocus) {
            JLabel label = (JLabel) super.getListCellRendererComponent(list, o, index, isSelected,
                    cellHasFocus);

            if (o instanceof StorySingleNodeEditor) {
                if (((StorySingleNodeEditor) o).getStatus() == Status.ERROR)
                    label.setForeground(Color.RED.darker());
                if (o instanceof StoryLogicalNodeEditor)
                    label.setIcon(new ImageIcon(Icons.getImage("LogicalNode", 16)));
                else if (o instanceof StoryTextNodeEditor)
                    label.setIcon(new ImageIcon(Icons.getImage("TextNode", 16)));
                else if (o instanceof StoryVirtualNodeEditor)
                    label.setIcon(new ImageIcon(Icons.getImage("VirtualNode", 16)));
            }

            return label;
        }

    });
    jlist.addListSelectionListener(e -> {
        if (jlist.getSelectedValue() instanceof JComponent) {
            container.removeAll();
            container.add(jlist.getSelectedValue());
            container.revalidate();
            container.repaint();
        }
    });

    JScrollablePanel pan = new JScrollablePanel(new BorderLayout(0, 0));
    jlist.addComponentListener(new ComponentAdapter() {

        @Override
        public void componentResized(ComponentEvent e) {
            scrollPane.revalidate();
            pan.revalidate();
            jlist.revalidate();

            revalidate();
            repaint();
        }

    });
    pan.setScrollableWidth(ScrollableSizeHint.FIT);
    pan.setScrollableHeight(ScrollableSizeHint.STRETCH);
    pan.add(jlist, BorderLayout.CENTER);
    scrollPane.setViewportView(pan);

    container = new JPanel();
    add(container, "cell 1 0,grow");
    container.setLayout(new BorderLayout(0, 0));

    container.add(new JPanel(), BorderLayout.CENTER); // TODO

    JPanel panel = new JPanel();
    add(panel, "cell 0 1 2 1,alignx leading,growy");

    JButton btnAddNode = new JButton(Lang.get("editor.panel.add"),
            new ImageIcon(Icons.getImage("Add Subnode", 16)));
    btnAddNode.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            createMenu().show(btnAddNode, e.getX(), e.getY());
        }
    });
    panel.add(btnAddNode);

    JButton btnRemoveNode = new JButton(Lang.get("editor.panel.remove"),
            new ImageIcon(Icons.getImage("Delete Subnode", 16)));
    btnRemoveNode.addActionListener(e -> removeNode());
    panel.add(btnRemoveNode);

}

From source file:utybo.branchingstorytree.swing.visuals.AboutDialog.java

@SuppressWarnings("unchecked")
public AboutDialog(OpenBSTGUI parent) {
    super(parent);
    setTitle(Lang.get("about.title"));
    setModalityType(ModalityType.APPLICATION_MODAL);

    JPanel banner = new JPanel(new FlowLayout(FlowLayout.CENTER));
    banner.setBackground(OpenBSTGUI.OPENBST_BLUE);
    JLabel lblOpenbst = new JLabel(new ImageIcon(Icons.getImage("FullLogoWhite", 48)));
    lblOpenbst.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    banner.add(lblOpenbst, "flowx,cell 0 0,alignx center");
    getContentPane().add(banner, BorderLayout.NORTH);

    JPanel pan = new JPanel();
    pan.setLayout(new MigLayout("insets 10, gap 10px", "[grow]", "[][][grow]"));
    getContentPane().add(pan, BorderLayout.CENTER);

    JLabel lblWebsite = new JLabel("https://utybo.github.io/BST/");
    Font f = lblWebsite.getFont();
    @SuppressWarnings("rawtypes")
    Map attrs = f.getAttributes();
    attrs.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
    lblWebsite.setFont(f.deriveFont(attrs));
    lblWebsite.setForeground(OpenBSTGUI.OPENBST_BLUE);
    lblWebsite.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    lblWebsite.addMouseListener(new MouseAdapter() {
        @Override/*from   w w w . j  a  v  a 2 s.  c  o  m*/
        public void mouseClicked(MouseEvent e) {
            if (Desktop.isDesktopSupported()) {
                try {
                    Desktop.getDesktop().browse(new URL("https://utybo.github.io/BST/").toURI());
                } catch (IOException | URISyntaxException e1) {
                    OpenBST.LOG.warn("Exception when trying to open website", e1);
                }
            }
        }
    });
    pan.add(lblWebsite, "cell 0 0,alignx center");

    JLabel lblVersion = new JLabel(Lang.get("about.version").replace("$v", OpenBST.VERSION));
    pan.add(lblVersion, "flowy,cell 0 1");

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setBorder(new LineBorder(pan.getBackground().darker(), 1, false));
    pan.add(scrollPane, "cell 0 2,grow");

    JTextArea textArea = new JTextArea();
    textArea.setMargin(new Insets(5, 5, 5, 5));
    textArea.setLineWrap(true);
    textArea.setWrapStyleWord(true);
    textArea.setFont(new Font(textArea.getFont().getFontName(), Font.PLAIN, (int) (Icons.getScale() * 11)));

    try (InputStream in = getClass().getResourceAsStream("/utybo/branchingstorytree/swing/about.txt");) {
        textArea.setText(IOUtils.toString(in, StandardCharsets.UTF_8));
    } catch (IOException ex) {
        OpenBST.LOG.warn("Loading about information failed", ex);
    }
    textArea.setEditable(false);
    textArea.setCaretPosition(0);
    scrollPane.setViewportView(textArea);

    JLabel lblTranslatedBy = new JLabel(Lang.get("author"));
    pan.add(lblTranslatedBy, "cell 0 1");

    setSize((int) (Icons.getScale() * 450), (int) (Icons.getScale() * 400));
    setLocationRelativeTo(parent);
}

From source file:views.online.Panel_RejoindrePartieMulti.java

/**
 * Constructeur//from w  w w .  j ava  2s .  c  o m
 * 
 * @param parent le fenetre parent
 */
public Panel_RejoindrePartieMulti(JFrame parent) {
    // initialisation
    super(new BorderLayout());
    this.parent = parent;
    parent.setTitle(Language.getTexte(Language.ID_TITRE_REJOINDRE_UNE_PARTIE_MULTI));
    setBorder(new EmptyBorder(new Insets(MARGES_PANEL, MARGES_PANEL, MARGES_PANEL, MARGES_PANEL)));
    setBackground(LookInterface.COULEUR_DE_FOND_PRI);

    // ---------
    // -- TOP --
    // ---------
    JPanel pTop = new JPanel(new BorderLayout());
    pTop.setBackground(LookInterface.COULEUR_DE_FOND_PRI);

    JLabel titre = new JLabel(Language.getTexte(Language.ID_TITRE_REJOINDRE_UNE_PARTIE_MULTI));
    titre.setFont(ManageFonts.POLICE_TITRE);
    titre.setForeground(LookInterface.COULEUR_TEXTE_PRI);
    pTop.add(titre, BorderLayout.NORTH);

    // filtre
    JPanel pADroite = new JPanel(new BorderLayout());
    pADroite.setBackground(LookInterface.COULEUR_DE_FOND_PRI);

    tfFiltre.setPreferredSize(new Dimension(100, 25));
    tfFiltre.addKeyListener(this);
    tfFiltre.addMouseListener(this);

    pADroite.add(tfFiltre, BorderLayout.WEST);
    pTop.add(pADroite, BorderLayout.CENTER);
    ManageFonts.setStyle(bRafraichir);
    pTop.add(bRafraichir, BorderLayout.EAST);
    bRafraichir.addActionListener(this);

    add(pTop, BorderLayout.NORTH);

    // ------------
    // -- CENTER --
    // ------------

    // cration de la table avec boquage des editions
    tbServeurs = new JTable(model) {
        public boolean isCellEditable(int rowIndex, int colIndex) {
            return false; // toujours dsactiv
        }
    };

    // Simple selection
    tbServeurs.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    // nom de colonnes
    model.addColumn(Language.getTexte(Language.ID_TXT_NOM));
    model.addColumn(Language.getTexte(Language.ID_TXT_IP));
    model.addColumn(Language.getTexte(Language.ID_TXT_PORT));
    model.addColumn(Language.getTexte(Language.ID_TXT_MODE));
    model.addColumn(Language.getTexte(Language.ID_TXT_TERRAIN));
    model.addColumn(Language.getTexte(Language.ID_TXT_PLACES_DISPO));

    // Cration du canal avec le serveur d'enregistrement
    try {
        canalServeurEnregistrement = new ChannelTCP(Configuration.getIpSE(), Configuration.getPortSE());

        mettreAJourListeDesServeurs();
    } catch (ConnectException e) {
        connexionSEImpossible();
    } catch (ChannelException e) {
        connexionSEImpossible();
    }

    // ajout dans le panel
    add(new JScrollPane(tbServeurs), BorderLayout.CENTER);

    // ------------
    // -- BOTTOM --
    // ------------
    JPanel pBottom = new JPanel(new BorderLayout());
    pBottom.setBackground(LookInterface.COULEUR_DE_FOND_PRI);

    bRetour.addActionListener(this);
    ManageFonts.setStyle(bRetour);
    bRetour.setPreferredSize(new Dimension(80, 50));
    pBottom.add(bRetour, BorderLayout.WEST);

    JPanel bottomCenter = new JPanel();
    bottomCenter.setBackground(LookInterface.COULEUR_DE_FOND_PRI);

    // connexion par IP 
    lblConnexionParIP.setFont(ManageFonts.POLICE_SOUS_TITRE);
    lblConnexionParIP.setForeground(LookInterface.COULEUR_TEXTE_PRI);
    bottomCenter.add(lblConnexionParIP);
    tfConnexionParIP.setPreferredSize(new Dimension(100, 25));
    bottomCenter.add(tfConnexionParIP);
    tfConnexionParIP.addMouseListener(this);

    // pseudo
    JPanel pPseudo = new JPanel();
    JPanel pTmp = new JPanel();

    lblPseudo.setFont(ManageFonts.POLICE_SOUS_TITRE);
    lblPseudo.setForeground(LookInterface.COULEUR_TEXTE_PRI);
    bottomCenter.add(lblPseudo);

    tfPseudo.setText(Configuration.getPseudoJoueur());
    bottomCenter.add(tfPseudo);

    pPseudo.add(pTmp, BorderLayout.EAST);
    pBottom.add(bottomCenter, BorderLayout.CENTER);

    // bouton rejoindre
    bRejoindre.setPreferredSize(new Dimension(100, 50));
    ManageFonts.setStyle(bRejoindre);
    pBottom.add(bRejoindre, BorderLayout.EAST);
    bRejoindre.addActionListener(this);

    pBottom.add(lblEtat, BorderLayout.SOUTH);

    add(pBottom, BorderLayout.SOUTH);
}

From source file:vues.reseau.Panel_RejoindrePartieMulti.java

/**
 * Constructeur//from  ww w  .  j  a v a  2  s .  c  om
 * 
 * @param parent le fenetre parent
 */
public Panel_RejoindrePartieMulti(JFrame parent) {
    // initialisation
    super(new BorderLayout());
    this.parent = parent;
    parent.setTitle(Langue.getTexte(Langue.ID_TITRE_REJOINDRE_UNE_PARTIE_MULTI));
    setBorder(new EmptyBorder(new Insets(MARGES_PANEL, MARGES_PANEL, MARGES_PANEL, MARGES_PANEL)));
    setBackground(LookInterface.COULEUR_DE_FOND_PRI);

    // ---------
    // -- TOP --
    // ---------
    JPanel pTop = new JPanel(new BorderLayout());
    pTop.setBackground(LookInterface.COULEUR_DE_FOND_PRI);

    JLabel titre = new JLabel(Langue.getTexte(Langue.ID_TITRE_REJOINDRE_UNE_PARTIE_MULTI));
    titre.setFont(GestionnaireDesPolices.POLICE_TITRE);
    titre.setForeground(LookInterface.COULEUR_TEXTE_PRI);
    pTop.add(titre, BorderLayout.NORTH);

    // filtre
    JPanel pADroite = new JPanel(new BorderLayout());
    pADroite.setBackground(LookInterface.COULEUR_DE_FOND_PRI);

    tfFiltre.setPreferredSize(new Dimension(100, 25));
    tfFiltre.addKeyListener(this);
    tfFiltre.addMouseListener(this);

    pADroite.add(tfFiltre, BorderLayout.WEST);
    pTop.add(pADroite, BorderLayout.CENTER);
    GestionnaireDesPolices.setStyle(bRafraichir);
    pTop.add(bRafraichir, BorderLayout.EAST);
    bRafraichir.addActionListener(this);

    add(pTop, BorderLayout.NORTH);

    // ------------
    // -- CENTER --
    // ------------

    // cration de la table avec boquage des editions
    tbServeurs = new JTable(model) {
        public boolean isCellEditable(int rowIndex, int colIndex) {
            return false; // toujours dsactiv
        }
    };

    // Simple selection
    tbServeurs.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    // nom de colonnes
    model.addColumn(Langue.getTexte(Langue.ID_TXT_NOM));
    model.addColumn(Langue.getTexte(Langue.ID_TXT_IP));
    model.addColumn(Langue.getTexte(Langue.ID_TXT_PORT));
    model.addColumn(Langue.getTexte(Langue.ID_TXT_MODE));
    model.addColumn(Langue.getTexte(Langue.ID_TXT_TERRAIN));
    model.addColumn(Langue.getTexte(Langue.ID_TXT_PLACES_DISPO));

    // Cration du canal avec le serveur d'enregistrement
    try {
        canalServeurEnregistrement = new CanalTCP(Configuration.getIpSE(), Configuration.getPortSE());

        mettreAJourListeDesServeurs();
    } catch (ConnectException e) {
        connexionSEImpossible();
    } catch (CanalException e) {
        connexionSEImpossible();
    }

    // ajout dans le panel
    add(new JScrollPane(tbServeurs), BorderLayout.CENTER);

    // ------------
    // -- BOTTOM --
    // ------------
    JPanel pBottom = new JPanel(new BorderLayout());
    pBottom.setBackground(LookInterface.COULEUR_DE_FOND_PRI);

    bRetour.addActionListener(this);
    GestionnaireDesPolices.setStyle(bRetour);
    bRetour.setPreferredSize(new Dimension(80, 50));
    pBottom.add(bRetour, BorderLayout.WEST);

    JPanel bottomCenter = new JPanel();
    bottomCenter.setBackground(LookInterface.COULEUR_DE_FOND_PRI);

    // connexion par IP 
    lblConnexionParIP.setFont(GestionnaireDesPolices.POLICE_SOUS_TITRE);
    lblConnexionParIP.setForeground(LookInterface.COULEUR_TEXTE_PRI);
    bottomCenter.add(lblConnexionParIP);
    tfConnexionParIP.setPreferredSize(new Dimension(100, 25));
    bottomCenter.add(tfConnexionParIP);
    tfConnexionParIP.addMouseListener(this);

    // pseudo
    JPanel pPseudo = new JPanel();
    JPanel pTmp = new JPanel();

    lblPseudo.setFont(GestionnaireDesPolices.POLICE_SOUS_TITRE);
    lblPseudo.setForeground(LookInterface.COULEUR_TEXTE_PRI);
    bottomCenter.add(lblPseudo);

    tfPseudo.setText(Configuration.getPseudoJoueur());
    bottomCenter.add(tfPseudo);

    pPseudo.add(pTmp, BorderLayout.EAST);
    pBottom.add(bottomCenter, BorderLayout.CENTER);

    // bouton rejoindre
    bRejoindre.setPreferredSize(new Dimension(100, 50));
    GestionnaireDesPolices.setStyle(bRejoindre);
    pBottom.add(bRejoindre, BorderLayout.EAST);
    bRejoindre.addActionListener(this);

    pBottom.add(lblEtat, BorderLayout.SOUTH);

    add(pBottom, BorderLayout.SOUTH);
}