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:ComplexCellRenderer.java

public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
        boolean cellHasFocus) {
    Font theFont = null;/* w w  w  . j av a2  s .  c o m*/
    Color theForeground = null;
    Icon theIcon = null;
    String theText = null;

    JLabel renderer = (JLabel) defaultRenderer.getListCellRendererComponent(list, value, index, isSelected,
            cellHasFocus);

    if (value instanceof Object[]) {
        Object values[] = (Object[]) value;
        theFont = (Font) values[0];
        theForeground = (Color) values[1];
        theIcon = (Icon) values[2];
        theText = (String) values[3];
    } else {
        theFont = list.getFont();
        theForeground = list.getForeground();
        theText = "";
    }
    if (!isSelected) {
        renderer.setForeground(theForeground);
    }
    if (theIcon != null) {
        renderer.setIcon(theIcon);
    }
    renderer.setText(theText);
    renderer.setFont(theFont);
    return renderer;
}

From source file:burp.BurpExtender.java

private void createTitle(String text, Container cont) {
    JLabel title = new JLabel(text);
    title.setForeground(new Color(229, 137, 0));
    Font f = title.getFont();//from   w  ww .  jav a2  s.co m
    title.setFont(new Font(f.getName(), Font.BOLD, f.getSize() + 2));
    callbacks.customizeUiComponent(title);
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridwidth = 0;
    gbc.gridx = 0;
    gbc.insets = new Insets(8, 10, 0, 0);
    gbc.anchor = GridBagConstraints.WEST;
    cont.add(title, gbc);
}

From source file:com.sshtools.appframework.api.ui.SshToolsApplicationPanel.java

/**
 * Display something other that the normal blank screen so our component
 * looks pretty.//  w  ww  .j a  va2s .  co m
 */
protected void showWelcomeScreen() {
    synchronized (getTreeLock()) {
        removeAll();
        setLayout(new BorderLayout());
        //         GradientPanel p = new GradientPanel(new BorderLayout());
        //         p.setBackground(Color.white);
        //         p.setBackground2(new Color(164, 228, 244));
        //         p.setForeground(Color.black);
        JPanel p = new JPanel(new BorderLayout());
        JLabel welcomeLabel = new JLabel("", JLabel.CENTER);
        welcomeLabel.setForeground(Color.white);
        welcomeLabel.setFont(welcomeLabel.getFont().deriveFont(72f).deriveFont(Font.BOLD + Font.ITALIC));
        welcomeLabel.setHorizontalAlignment(JLabel.RIGHT);
        p.add(welcomeLabel, BorderLayout.SOUTH);
        add(p, BorderLayout.CENTER);
        validate();
    }
}

From source file:org.obiba.onyx.jade.instrument.gehealthcare.CardiosoftInstrumentRunner.java

/**
 * Create an information dialog that tells the user to wait while the data is being processed.
 *//*from  w w w . j a  v  a  2  s .c  om*/
private void showProcessingDialog() {

    JPanel messagePanel = new JPanel();
    messagePanel.setAlignmentX(Component.CENTER_ALIGNMENT);
    messagePanel.setLayout(new BoxLayout(messagePanel, BoxLayout.Y_AXIS));

    JLabel message = new JLabel(ecgResourceBundle.getString("Message.ProcessingEcgMeasurement"));
    message.setFont(new Font(Font.DIALOG, Font.PLAIN, 20));
    messagePanel.add(message);

    JLabel subMessage = new JLabel(ecgResourceBundle.getString("Message.ProcessingEcgMeasurementInstructions"));
    subMessage.setFont(new Font(Font.DIALOG, Font.PLAIN, 14));
    subMessage.setForeground(Color.RED);
    messagePanel.add(subMessage);

    JFrame window = new JFrame();
    window.add(messagePanel);
    window.pack();

    // Make sure dialog stays on top of all other application windows.
    window.setAlwaysOnTop(true);
    window.setLocationByPlatform(true);

    // Center dialog horizontally at the bottom of the screen.
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    window.setLocation((screenSize.width - window.getWidth()) / 2, screenSize.height - window.getHeight() - 70);

    window.setEnabled(false);
    window.setVisible(true);

}

From source file:org.lmn.fc.frameworks.starbase.plugins.observatory.ui.tabs.charts.ChartUIHelper.java

/***********************************************************************************************
 * Create the default Toolbar for a Chart.
 *
 * @param obsinstrument//w  w w  .  j av  a 2 s.  c o  m
 * @param chart
 * @param title
 * @param fontdata
 * @param colourforeground
 * @param colourbackground
 * @param debug
 *
 * @return JToolBar
 */

public static JToolBar createDefaultToolbar(final ObservatoryInstrumentInterface obsinstrument,
        final ChartUIComponentPlugin chart, final String title, final FontInterface fontdata,
        final ColourInterface colourforeground, final ColourInterface colourbackground, final boolean debug) {
    final JToolBar toolbar;

    if ((obsinstrument != null) && (chart != null)) {
        final List<Component> listComponentsToAdd;
        final JLabel labelName;

        listComponentsToAdd = new ArrayList<Component>(10);

        //-------------------------------------------------------------------------------------
        // Initialise the Label

        labelName = new JLabel(title, RegistryModelUtilities.getAtomIcon(obsinstrument.getHostAtom(),
                ObservatoryInterface.FILENAME_ICON_CHART_VIEWER), SwingConstants.LEFT) {
            static final long serialVersionUID = 7580736117336162922L;

            // Enable Antialiasing in Java 1.5
            protected void paintComponent(final Graphics graphics) {
                final Graphics2D graphics2D = (Graphics2D) graphics;

                // For antialiasing text
                graphics2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
                        RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
                super.paintComponent(graphics2D);
            }
        };

        labelName.setFont(
                fontdata.getFont().deriveFont(ReportTableHelper.SIZE_HEADER_FONT).deriveFont(Font.BOLD));
        labelName.setForeground(colourforeground.getColor());
        labelName.setIconTextGap(UIComponentPlugin.TOOLBAR_ICON_TEXT_GAP);

        listComponentsToAdd.add(new JToolBar.Separator(UIComponentPlugin.DIM_TOOLBAR_SEPARATOR_BUTTON));
        listComponentsToAdd.add(labelName);
        listComponentsToAdd.add(new JToolBar.Separator(UIComponentPlugin.DIM_TOOLBAR_SEPARATOR));

        listComponentsToAdd.add(Box.createHorizontalGlue());

        UIComponentHelper.addToolbarPrintButtons(listComponentsToAdd, chart, chart.getChartPanel(), title,
                fontdata, colourforeground, colourbackground, debug);

        // Build the Toolbar using the Components, if any
        toolbar = UIComponentHelper.buildToolbar(listComponentsToAdd);
    } else {
        toolbar = new JToolBar();
    }

    toolbar.setFloatable(false);
    toolbar.setMinimumSize(UIComponentPlugin.DIM_TOOLBAR_SIZE);
    toolbar.setPreferredSize(UIComponentPlugin.DIM_TOOLBAR_SIZE);
    toolbar.setMaximumSize(UIComponentPlugin.DIM_TOOLBAR_SIZE);
    toolbar.setBackground(colourbackground.getColor());
    NavigationUtilities.updateComponentTreeUI(toolbar);

    return (toolbar);
}

From source file:utybo.easypastebin.windows.MainWindow.java

/**
 * Creates the window/*from www.  j  a v  a2 s.c om*/
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
public MainWindow() {
    EasyPastebin.LOGGER.log("Initializing the window", SinkJLevel.INFO);
    setTitle("EasyPastebin");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(100, 100, 664, 431);
    contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    contentPane.setLayout(new BorderLayout(0, 0));
    setContentPane(contentPane);

    JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
    contentPane.add(tabbedPane, BorderLayout.CENTER);

    JPanel main = new JPanel();
    tabbedPane.addTab("EasyPastebin", null, main, null);
    main.setLayout(null);

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setBounds(62, 39, 312, 132);
    main.add(scrollPane);

    pasteContent = new JTextArea();
    pasteContent.setFont(new Font("Monospaced", Font.PLAIN, 11));
    pasteContent.setWrapStyleWord(true);
    pasteContent.setLineWrap(true);
    pasteContent.setToolTipText("Put your paste here!");
    scrollPane.setViewportView(pasteContent);

    JLabel titleLabel = new JLabel("Title :");
    titleLabel.setFont(new Font("Tahoma", Font.PLAIN, 12));
    titleLabel.setBounds(10, 11, 42, 21);
    main.add(titleLabel);

    pasteTitle = new JTextField();
    pasteTitle.setBounds(62, 12, 312, 20);
    main.add(pasteTitle);
    pasteTitle.setColumns(10);

    JLabel lblPaste = new JLabel("Paste :");
    lblPaste.setForeground(Color.RED);
    lblPaste.setFont(new Font("Tahoma", Font.PLAIN, 12));
    lblPaste.setBounds(10, 85, 53, 21);
    main.add(lblPaste);

    pasteExpireDate = new JComboBox();
    pasteExpireDate.setFont(new Font("Tahoma", Font.PLAIN, 12));
    pasteExpireDate.setModel(new DefaultComboBoxModel(EnumExpireDate.values()));
    pasteExpireDate.setBounds(468, 12, 155, 21);
    main.add(pasteExpireDate);

    JLabel lblExpireDate = new JLabel("Expire Date :");
    lblExpireDate.setFont(new Font("Tahoma", Font.PLAIN, 12));
    lblExpireDate.setBounds(384, 14, 81, 14);
    main.add(lblExpireDate);

    JLabel lblfieldsInRed = new JLabel("(Fields in red are required)");
    lblfieldsInRed.setBounds(72, 182, 302, 14);
    main.add(lblfieldsInRed);

    btnSubmit = new JButton("Submit!");
    btnSubmit.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            EasyPastebin.LOGGER.log("Starting Submit script", SinkJLevel.INFO);
            btnSubmit.setEnabled(false);
            btnSubmit.setText("Please wait...");

            boolean success = true;
            String paste = pasteContent.getText();
            String title = pasteTitle.getText();
            EnumExpireDate expireDate = (EnumExpireDate) pasteExpireDate.getSelectedItem();

            if (paste.equals("") || paste.equals(" ") || paste.equals(null)) {
                pastebinUrl.setText("ERROR");
                JOptionPane.showMessageDialog(null, "You cannot send empty pastes!",
                        "Error while processing paste", JOptionPane.ERROR_MESSAGE);
            } else {
                try {
                    EasyPastebin.LOGGER.log("Setting options", SinkJLevel.INFO);
                    Map map = new HashMap<String, String>();
                    map.put("api_dev_key", HttpHelper.API_KEY);
                    map.put("api_option", "paste");
                    map.put("api_paste_code", paste);
                    if (!(expireDate.equals(null) || expireDate.equals(EnumExpireDate.NEVER)))
                        map.put("api_paste_expire_date", expireDate.getRawName());
                    if (!(title.equals("") || title.equals(" ") || title.equals(null)))
                        map.put("api_paste_name", title);

                    EasyPastebin.LOGGER.log("Sending paste", SinkJLevel.INFO);
                    String actionResult = HttpHelper.sendPost("http://pastebin.com/api/api_post.php", map)
                            .asString();
                    EasyPastebin.LOGGER.log("Paste sent, checking output", SinkJLevel.INFO);
                    // Exception handlers
                    if (actionResult.equals("Bad API request, invalid api_option")) {
                        success = false;
                        EasyPastebin.LOGGER.log(
                                "The output is an error message : " + actionResult + ". Submit script failed!",
                                SinkJLevel.ERROR);
                        JOptionPane.showMessageDialog(null,
                                "Error while processing paste. Incorrect Pastebin option!", "Error",
                                JOptionPane.ERROR_MESSAGE);
                    }
                    if (actionResult.equals("Bad API request, invalid api_dev_key")) {
                        success = false;
                        EasyPastebin.LOGGER.log(
                                "The output is an error message : " + actionResult + ". Submit script failed!",
                                SinkJLevel.ERROR);
                        JOptionPane.showMessageDialog(null,
                                "Error while processing paste. Incorrect dev key! Try again with a more recent version!",
                                "Error", JOptionPane.ERROR_MESSAGE);
                    }
                    if (actionResult.equals("Bad API request, IP blocked")) {
                        success = false;
                        EasyPastebin.LOGGER.log(
                                "The output is an error message : " + actionResult + ". Submit script failed!",
                                SinkJLevel.ERROR);
                        JOptionPane.showMessageDialog(null, "Error while processing paste. Your IP is blocked!",
                                "Error", JOptionPane.ERROR_MESSAGE);
                    }
                    if (actionResult.equals(
                            "Bad API request, maximum number of 25 unlisted pastes for your free account")) {
                        success = false;
                        EasyPastebin.LOGGER.log(
                                "The output is an error message : " + actionResult + ". Submit script failed!",
                                SinkJLevel.ERROR);
                    }
                    if (actionResult.equals(
                            "Bad API request, maximum number of 10 private pastes for your free account")) {
                        success = false;
                        EasyPastebin.LOGGER.log(
                                "The output is an error message : " + actionResult + ". Submit script failed!",
                                SinkJLevel.ERROR);
                    }
                    if (actionResult.equals("Bad API request, api_paste_code was empty")) {
                        success = false;
                        EasyPastebin.LOGGER.log(
                                "The output is an error message : " + actionResult + ". Submit script failed!",
                                SinkJLevel.ERROR);
                    }
                    if (actionResult.equals("Bad API request, maximum paste file size exceeded")) {
                        success = false;
                        EasyPastebin.LOGGER.log(
                                "The output is an error message : " + actionResult + ". Submit script failed!",
                                SinkJLevel.ERROR);
                        JOptionPane.showMessageDialog(null,
                                "Error while processing paste. Your paste is too big!", "Error",
                                JOptionPane.ERROR_MESSAGE);
                    }
                    if (actionResult.equals("Bad API request, invalid api_expire_date")) {
                        success = false;
                        EasyPastebin.LOGGER.log(
                                "The output is an error message : " + actionResult + ". Submit script failed!",
                                SinkJLevel.ERROR);
                        JOptionPane.showMessageDialog(null,
                                "Error while processing paste. Invalid expire date!", "Error",
                                JOptionPane.ERROR_MESSAGE);
                    }
                    if (actionResult.equals("Bad API request, invalid api_paste_private")) {
                        success = false;
                        EasyPastebin.LOGGER.log(
                                "The output is an error message : " + actionResult + ". Submit script failed!",
                                SinkJLevel.ERROR);
                        JOptionPane.showMessageDialog(null,
                                "Error while processing paste. Invalid privacy value!", "Error",
                                JOptionPane.ERROR_MESSAGE);
                    }
                    if (actionResult.equals("Bad API request, invalid api_paste_format")) {
                        success = false;
                        EasyPastebin.LOGGER.log(
                                "The output is an error message : " + actionResult + ". Submit script failed!",
                                SinkJLevel.ERROR);
                        JOptionPane.showMessageDialog(null, "Error while processing paste. Invalid format!",
                                "Error", JOptionPane.ERROR_MESSAGE);
                    }
                    // END

                    // Starting display stuff
                    if (success == false) {
                        EasyPastebin.LOGGER.log("Submit script failed : success == false", SinkJLevel.ERROR);
                        pastebinUrl.setText("ERROR");
                    }
                    if (success == true) {
                        EasyPastebin.LOGGER.log("Paste sent! Starting display script!", SinkJLevel.INFO);
                        pastebinUrl.setText(actionResult);
                        JOptionPane.showMessageDialog(null, "Paste successfully sent!", "Done!",
                                JOptionPane.INFORMATION_MESSAGE);
                        EasyPastebin.LOGGER.log("Display script finished! Paste URL is : " + actionResult,
                                SinkJLevel.INFO);
                    }

                } catch (ClientProtocolException e) {
                    EasyPastebin.LOGGER.log("Unexpected error! " + e, SinkJLevel.ERROR);
                    JOptionPane.showMessageDialog(null, "Error while processing paste : " + e, "Error",
                            JOptionPane.ERROR_MESSAGE);
                    e.printStackTrace();
                } catch (IOException e) {
                    EasyPastebin.LOGGER.log("Unexpected error! " + e, SinkJLevel.ERROR);
                    JOptionPane.showMessageDialog(null, "Error while processing paste : " + e, "Error",
                            JOptionPane.ERROR_MESSAGE);
                    e.printStackTrace();
                } catch (MissingParamException e) {
                    EasyPastebin.LOGGER.log("Unexpected error! " + e, SinkJLevel.ERROR);
                    JOptionPane.showMessageDialog(null, "Error while processing paste : " + e
                            + "! This is a severe programming error! Try again with a more recent version!",
                            "Error", JOptionPane.ERROR_MESSAGE);
                    e.printStackTrace();
                }
            }

            EasyPastebin.LOGGER.log("Re-enabling the Submit button ", SinkJLevel.INFO);
            btnSubmit.setEnabled(true);
            btnSubmit.setText("Submit another paste!");
            EasyPastebin.LOGGER.log("Finished submit script! Success : " + success, SinkJLevel.INFO);
        }
    });
    btnSubmit.setBounds(386, 45, 237, 44);
    main.add(btnSubmit);

    pastebinUrl = new JTextField();
    pastebinUrl.setText("The paste's URL will be shown here!");
    pastebinUrl.setEditable(false);
    pastebinUrl.setBounds(384, 198, 239, 32);
    main.add(pastebinUrl);
    pastebinUrl.setColumns(10);

    JPanel about = new JPanel();
    tabbedPane.addTab("About", null, about, null);

    JLabel label = new JLabel("EasyPastebin");
    label.setBounds(12, 12, 623, 39);
    label.setHorizontalAlignment(SwingConstants.CENTER);
    label.setFont(new Font("Dialog", Font.PLAIN, 25));

    JLabel lblTheEasiestWay = new JLabel("The easiest way to use Pastebin.com");
    lblTheEasiestWay.setBounds(12, 63, 623, 32);
    lblTheEasiestWay.setFont(new Font("Dialog", Font.PLAIN, 16));
    lblTheEasiestWay.setHorizontalAlignment(SwingConstants.CENTER);
    about.setLayout(null);
    about.add(label);
    about.add(lblTheEasiestWay);

    JButton btnForkM = new JButton("Fork me on Github!");
    btnForkM.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            goToUrl("https://github.com/utybo/EasyPastebin");
        }
    });
    btnForkM.setBounds(12, 117, 623, 25);
    about.add(btnForkM);

    JButton btnCheckOutUtybos = new JButton("Check out utybo's projects!");
    btnCheckOutUtybos.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            goToUrl("http://utybo.github.io/");
        }
    });
    btnCheckOutUtybos.setBounds(12, 154, 623, 25);
    about.add(btnCheckOutUtybos);

    JButton btnGoToPastebincom = new JButton("Go to Pastebin.com!");
    btnGoToPastebincom.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            goToUrl("http://www.pastebin.com");
        }
    });
    btnGoToPastebincom.setBounds(12, 191, 623, 25);
    about.add(btnGoToPastebincom);

    JLabel lblcUtybo = new JLabel(
            "This soft was made by utybo. It uses Apache's libraries for the interaction with Pastebin's API");
    lblcUtybo.setFont(new Font("Dialog", Font.PLAIN, 10));
    lblcUtybo.setHorizontalAlignment(SwingConstants.CENTER);
    lblcUtybo.setBounds(12, 324, 623, 15);
    about.add(lblcUtybo);

    JLabel lblClickMeTo = new JLabel("Click me to go to Apache's licence official website");
    lblClickMeTo.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            goToUrl("http://www.apache.org/licenses/LICENSE-2.0");
        }
    });
    lblClickMeTo.setHorizontalAlignment(SwingConstants.CENTER);
    lblClickMeTo.setFont(new Font("Dialog", Font.PLAIN, 10));
    lblClickMeTo.setBounds(12, 342, 623, 15);
    about.add(lblClickMeTo);

    setVisible(true);

    EasyPastebin.LOGGER.log("Done!", SinkJLevel.INFO);
}

From source file:com.hexidec.ekit.component.UnicodeDialog.java

public void init(int startIndex) {
    String customFont = Translatrix.getTranslationString("UnicodeDialogButtonFont");
    if (customFont != null && customFont.length() > 0) {
        buttonFont = new Font(Translatrix.getTranslationString("UnicodeDialogButtonFont"), Font.PLAIN, 12);
    } else {// w ww  .  ja  v  a 2  s . co  m
        buttonFont = new Font("Monospaced", Font.PLAIN, 12);
    }

    Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());
    setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);

    JPanel centerPanel = new JPanel();
    centerPanel.setLayout(new GridLayout(0, 17, 0, 0));
    buttonGroup = new ButtonGroup();

    int prefButtonWidth = 32;
    int prefButtonHeight = 32;

    centerPanel.add(new JLabel(""));
    for (int labelLoop = 0; labelLoop < 16; labelLoop++) {
        JLabel jlblMarker = new JLabel(
                "x" + (labelLoop > 9 ? "" + (char) (65 + (labelLoop - 10)) : "" + labelLoop));
        jlblMarker.setHorizontalAlignment(SwingConstants.CENTER);
        jlblMarker.setVerticalAlignment(SwingConstants.CENTER);
        jlblMarker.setForeground(new Color(0.5f, 0.5f, 0.75f));
        centerPanel.add(jlblMarker);
    }

    int labelcount = 0;
    for (int counter = 0; counter < UNICODEBLOCKSIZE; counter++) {
        if ((counter % 16) == 0) {
            JLabel jlblMarker = new JLabel(
                    (labelcount > 9 ? "" + (char) (65 + (labelcount - 10)) : "" + labelcount) + "x");
            jlblMarker.setHorizontalAlignment(SwingConstants.CENTER);
            jlblMarker.setVerticalAlignment(SwingConstants.CENTER);
            jlblMarker.setForeground(new Color(0.5f, 0.5f, 0.75f));
            centerPanel.add(jlblMarker);
            labelcount++;
        }
        buttonArray[counter] = new JToggleButton(" ");
        buttonArray[counter].getModel().setActionCommand("");
        buttonArray[counter].setFont(buttonFont);
        buttonArray[counter].setBorder(
                javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.LOWERED));
        buttonArray[counter].addActionListener(this);
        if (counter == 0) {
            FontRenderContext frcLocal = ((java.awt.Graphics2D) (parentEkit.getGraphics()))
                    .getFontRenderContext();
            Rectangle2D fontBounds = buttonFont.getMaxCharBounds(frcLocal);
            int maxCharWidth = (int) (Math.abs(fontBounds.getX())) + (int) (Math.abs(fontBounds.getWidth()));
            int maxCharHeight = (int) (Math.abs(fontBounds.getY())) + (int) (Math.abs(fontBounds.getHeight()));
            Insets buttonInsets = buttonArray[counter].getBorder().getBorderInsets(buttonArray[counter]);
            prefButtonWidth = maxCharWidth + buttonInsets.left + buttonInsets.right;
            prefButtonHeight = maxCharHeight + buttonInsets.top + buttonInsets.bottom;
        }
        buttonArray[counter].setPreferredSize(new Dimension(prefButtonWidth, prefButtonHeight));
        centerPanel.add(buttonArray[counter]);
        buttonGroup.add(buttonArray[counter]);
    }

    JPanel selectorPanel = new JPanel();

    jcmbBlockSelector = new JComboBox(unicodeBlocks);
    jcmbBlockSelector.setSelectedIndex(startIndex);
    jcmbBlockSelector.setActionCommand(CMDCHANGEBLOCK);
    jcmbBlockSelector.addActionListener(this);

    String[] sPages = { "1" };
    jcmbPageSelector = new JComboBox(sPages);
    jcmbPageSelector.setSelectedIndex(0);
    jcmbPageSelector.setActionCommand(CMDCHANGEBLOCK);
    jcmbPageSelector.addActionListener(this);

    selectorPanel.add(new JLabel(Translatrix.getTranslationString("SelectorToolUnicodeBlock")));
    selectorPanel.add(jcmbBlockSelector);
    selectorPanel.add(new JLabel(Translatrix.getTranslationString("SelectorToolUnicodePage")));
    selectorPanel.add(jcmbPageSelector);

    JPanel buttonPanel = new JPanel();

    JButton closeButton = new JButton(Translatrix.getTranslationString("DialogClose"));
    closeButton.setActionCommand("close");
    closeButton.addActionListener(this);
    buttonPanel.add(closeButton);

    contentPane.add(centerPanel, BorderLayout.CENTER);
    contentPane.add(selectorPanel, BorderLayout.NORTH);
    contentPane.add(buttonPanel, BorderLayout.SOUTH);

    this.pack();

    populateButtons(startIndex, 0);

    this.setVisible(true);
}

From source file:com.diversityarrays.kdxplore.field.FieldViewPanel.java

public FieldViewPanel(PlotVisitList plotVisitList, Map<Integer, Trait> traitMap,
        SeparatorVisibilityOption visible, SimplePlotCellRenderer plotRenderer, Component... extras) {
    super(new BorderLayout());

    this.plotVisitList = plotVisitList;
    this.traitMap = traitMap;

    trial = plotVisitList.getTrial();/*from   w w w.ja v a  2  s . co m*/

    fieldLayoutTableModel.setTrial(trial);

    int rowHeight = fieldLayoutTable.getRowHeight();
    fieldLayoutTable.setRowHeight(4 * rowHeight);

    fieldLayoutTable.setCellSelectionEnabled(true);

    fieldLayoutTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);

    // IMPORTANT: DO NOT SORT THE FIELD LAYOUT TABLE
    fieldLayoutTable.setAutoCreateRowSorter(false);

    Map<Integer, Plot> plotById = new HashMap<>();
    FieldLayout<Integer> plotIdLayout = FieldLayoutUtil.createPlotIdLayout(trial.getTrialLayout(),
            trial.getPlotIdentSummary(), plotVisitList.getPlots(), plotById);

    KdxploreFieldLayout<Plot> kdxFieldLayout = new KdxploreFieldLayout<Plot>(Plot.class, plotIdLayout.imageId,
            plotIdLayout.xsize, plotIdLayout.ysize);
    kdxFieldLayout.warning = plotIdLayout.warning;

    String displayName = null;
    for (VisitOrder2D vo : VisitOrder2D.values()) {
        if (vo.imageId == plotIdLayout.imageId) {
            displayName = vo.displayName;
            break;
        }
    }
    //      VisitOrder2D vo = plotVisitList.getVisitOrder();
    KDClientUtils.initAction(plotIdLayout.imageId, changeCollectionOrder, displayName);

    hasUserPlotId = lookForUserPlotIdPresent(plotById, plotIdLayout, kdxFieldLayout);

    this.plotCellRenderer = plotRenderer;
    plotCellRenderer.setShowUserPlotId(hasUserPlotId);

    plotCellRenderer.setPlotXYprovider(getXYprovider());

    plotCellRenderer.setPlotVisitList(plotVisitList);

    fieldLayoutTable.setDefaultRenderer(Plot.class, plotCellRenderer);
    fieldLayoutTable.setCellSelectionEnabled(true);

    fieldLayoutTableModel.setFieldLayout(kdxFieldLayout);

    if (kdxFieldLayout.warning != null && !kdxFieldLayout.warning.isEmpty()) {
        warningMessage.setText(kdxFieldLayout.warning);
    } else {
        warningMessage.setText("");
    }

    fieldLayoutTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    fieldLayoutTable.getTableHeader().setReorderingAllowed(false);
    fieldLayoutTable.setCellSelectionEnabled(true);

    StringBuilder naming = new StringBuilder();
    String nameForRow = plotVisitList.getTrial().getNameForRow();
    if (!Check.isEmpty(nameForRow)) {
        naming.append(nameForRow);
    }
    String nameForCol = plotVisitList.getTrial().getNameForColumn();
    if (!Check.isEmpty(nameForCol)) {
        if (naming.length() > 0) {
            naming.append('/');
        }
        naming.append(nameForCol);
    }
    fieldTableScrollPane = new JScrollPane(fieldLayoutTable);
    if (naming.length() > 0) {
        JLabel cornerLabel = new JLabel(naming.toString());
        fieldTableScrollPane.setCorner(JScrollPane.UPPER_LEFT_CORNER, cornerLabel);
    }
    fieldTableScrollPane.setRowHeaderView(rowHeaderTable);

    //      fieldLayoutTable.setRowHeaderTable(rowHeaderTable);

    //      Box extra = Box.createHorizontalBox();
    //      extra.add(new JButton(changeCollectionOrder));
    //      if (extras != null && extras.length > 0) {
    //         extra.add(Box.createHorizontalStrut(8));
    //         for (Component c : extras) {
    //            extra.add(c);
    //         }
    //      }
    //      extra.add(Box.createHorizontalGlue());

    switch (visible) {
    case NOTVISIBLE:
        break;

    case VISIBLE:
    default:
        Box top = Box.createHorizontalBox();
        top.setOpaque(true);
        top.setBackground(Color.LIGHT_GRAY);
        top.setBorder(new MatteBorder(0, 0, 1, 0, Color.GRAY));
        JLabel label = new JLabel("Field");
        label.setForeground(Color.DARK_GRAY);
        label.setFont(label.getFont().deriveFont(Font.BOLD));
        top.add(label);
        top.add(new JButton(changeCollectionOrder));

        if (extras != null && extras.length > 0) {
            top.add(Box.createHorizontalStrut(8));
            for (Component c : extras) {
                top.add(c);
            }
        }
        add(top, BorderLayout.NORTH);
        break;
    }

    add(fieldTableScrollPane, BorderLayout.CENTER);
    add(warningMessage, BorderLayout.SOUTH);
}

From source file:com.commander4j.util.JUtility.java

public static void setResultRecordCountColour(JLabel label, boolean limitSet, Integer limitRecords,
        Integer ActualRecords) {/*w  w  w.  j  a v a 2  s  .c o  m*/
    String warning = "";

    if (ActualRecords > 0) {
        if (limitSet) {
            if (ActualRecords >= limitRecords) {
                label.setForeground(Color.RED);
                warning = " Number of records returned constrained by user defined limit.";
            } else {
                label.setForeground(Color.BLACK);
            }
        } else {
            label.setForeground(Color.BLACK);
        }

        label.setText(String.valueOf(ActualRecords) + " record(s) retrieved." + warning);
    } else {
        label.setForeground(Color.BLACK);
        label.setText("0 records shown.");
    }
}

From source file:multiplayer.pong.client.LobbyFrame.java

/**
 * This method is called from within the constructor to initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is always
 * regenerated by the Form Editor./*from  w  w  w  . ja  v  a 2s .co m*/
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    jScrollPane2 = new javax.swing.JScrollPane();
    jScrollPane2.setBackground(Color.WHITE);
    usernamesT = new javax.swing.JTable();
    usernamesT.setBackground(Color.WHITE);

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    setBackground(new java.awt.Color(0, 0, 0));

    usernamesT.setModel(new javax.swing.table.DefaultTableModel(
            new Object[][] { { null }, { null }, { null }, { null } }, new String[] { "Username" }) {
        boolean[] canEdit = new boolean[] { false };

        public boolean isCellEditable(int rowIndex, int columnIndex) {
            return canEdit[columnIndex];
        }
    });
    usernamesT.setGridColor(new java.awt.Color(0, 0, 0));
    usernamesT.setInheritsPopupMenu(true);
    jScrollPane2.setViewportView(usernamesT);
    if (usernamesT.getColumnModel().getColumnCount() > 0) {
        usernamesT.getColumnModel().getColumn(0).setResizable(false);
    }

    JLabel lblUtilisateursEnligne = new JLabel("Utilisateurs en-ligne");
    lblUtilisateursEnligne.setForeground(new Color(255, 255, 255));
    lblUtilisateursEnligne.setFont(new Font("Trebuchet MS", Font.PLAIN, 14));

    commandBtn = new JButton("Envoyer");
    commandBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            commandBtnActionPerformed(e);
        }
    });

    JLabel lblLobbyPrincipal = new JLabel("Lobby Principal");
    lblLobbyPrincipal.setFont(new Font("Georgia", Font.PLAIN, 70));
    lblLobbyPrincipal.setForeground(new Color(255, 255, 255));
    lblLobbyPrincipal.setBackground(new Color(0, 0, 0));

    scrollPane = new JScrollPane();
    scrollPane.setBackground(Color.WHITE);

    cmdPrompt = new JTextField();
    cmdPrompt.setColumns(10);
    cmdPrompt.grabFocus();

    scrollPane_1 = new JScrollPane();

    lblWelcome = new JLabel("Bienvenue, " + SocketHandler.username);
    lblWelcome.setHorizontalAlignment(SwingConstants.RIGHT);
    lblWelcome.setFont(new Font("Georgia", Font.PLAIN, 18));
    lblWelcome.setForeground(Color.WHITE);

    JLabel label = new JLabel("Amis connect\u00E9s");
    label.setForeground(Color.WHITE);
    label.setFont(new Font("Trebuchet MS", Font.PLAIN, 14));

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    layout.setHorizontalGroup(layout.createParallelGroup(Alignment.LEADING).addGroup(layout
            .createSequentialGroup().addContainerGap()
            .addGroup(layout.createParallelGroup(Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                            .addGroup(layout.createParallelGroup(Alignment.LEADING)
                                    .addComponent(scrollPane_1, GroupLayout.PREFERRED_SIZE, 605,
                                            GroupLayout.PREFERRED_SIZE)
                                    .addComponent(cmdPrompt, 605, 605, 605))
                            .addPreferredGap(ComponentPlacement.RELATED))
                    .addGroup(layout.createSequentialGroup()
                            .addComponent(lblLobbyPrincipal, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE,
                                    Short.MAX_VALUE)
                            .addGap(120)))
            .addGroup(layout.createParallelGroup(Alignment.TRAILING)
                    .addComponent(lblUtilisateursEnligne, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 169,
                            Short.MAX_VALUE)
                    .addGroup(Alignment.LEADING,
                            layout.createSequentialGroup().addPreferredGap(ComponentPlacement.RELATED)
                                    .addComponent(lblWelcome, GroupLayout.PREFERRED_SIZE, 160,
                                            GroupLayout.PREFERRED_SIZE))
                    .addComponent(commandBtn, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 169, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup().addPreferredGap(ComponentPlacement.RELATED)
                            .addComponent(label, GroupLayout.PREFERRED_SIZE, 169, GroupLayout.PREFERRED_SIZE))
                    .addGroup(Alignment.LEADING,
                            layout.createSequentialGroup().addPreferredGap(ComponentPlacement.RELATED)
                                    .addComponent(jScrollPane2, GroupLayout.DEFAULT_SIZE, 169, Short.MAX_VALUE))
                    .addGroup(Alignment.LEADING,
                            layout.createSequentialGroup().addPreferredGap(ComponentPlacement.UNRELATED)
                                    .addComponent(scrollPane, GroupLayout.DEFAULT_SIZE, 169, Short.MAX_VALUE)))
            .addContainerGap()));
    layout.setVerticalGroup(layout.createParallelGroup(Alignment.LEADING).addGroup(layout
            .createSequentialGroup().addContainerGap()
            .addGroup(layout.createParallelGroup(Alignment.TRAILING).addGroup(layout.createSequentialGroup()
                    .addGroup(layout.createParallelGroup(Alignment.LEADING)
                            .addComponent(lblLobbyPrincipal, GroupLayout.PREFERRED_SIZE, 85,
                                    GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblWelcome, GroupLayout.PREFERRED_SIZE, 31,
                                    GroupLayout.PREFERRED_SIZE))
                    .addGap(18)
                    .addGroup(layout.createParallelGroup(Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                    .addComponent(scrollPane, GroupLayout.PREFERRED_SIZE, 164,
                                            GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(ComponentPlacement.RELATED)
                                    .addComponent(lblUtilisateursEnligne, GroupLayout.PREFERRED_SIZE, 24,
                                            GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(ComponentPlacement.RELATED)
                                    .addComponent(jScrollPane2, GroupLayout.DEFAULT_SIZE, 232, Short.MAX_VALUE))
                            .addComponent(scrollPane_1, GroupLayout.DEFAULT_SIZE, 432, Short.MAX_VALUE))
                    .addGap(9)
                    .addGroup(
                            layout.createParallelGroup(Alignment.BASELINE)
                                    .addComponent(cmdPrompt, GroupLayout.PREFERRED_SIZE, 22,
                                            GroupLayout.PREFERRED_SIZE)
                                    .addComponent(commandBtn))
                    .addGap(22))
                    .addGroup(layout.createSequentialGroup()
                            .addComponent(label, GroupLayout.PREFERRED_SIZE, 24, GroupLayout.PREFERRED_SIZE)
                            .addGap(492)))));

    ta = new JTextPane();
    ta.setEditable(false);
    ta.setFont(new Font("SansSerif", Font.PLAIN, 14));
    scrollPane_1.setViewportView(ta);

    friendsT = new JTable();
    friendsT.setModel(new DefaultTableModel(new Object[][] {}, new String[] { "Username" }));
    scrollPane.setViewportView(friendsT);
    getContentPane().setLayout(layout);

    pack();
}