Example usage for javax.swing JLabel setOpaque

List of usage examples for javax.swing JLabel setOpaque

Introduction

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

Prototype

@BeanProperty(expert = true, description = "The component's opacity")
public void setOpaque(boolean isOpaque) 

Source Link

Document

If true the component paints every pixel within its bounds.

Usage

From source file:es.emergya.ui.plugins.admin.aux1.SummaryAction.java

private JList buildJList(final Dimension dimension, final Object[] items, final JList list,
        final boolean sort) {
    if (items == null) {
        return null;
    }/*from w  w w  . jav a  2  s .  c o  m*/
    list.setModel(new DefaultListModel() {

        @Override
        public void addElement(Object obj) {
            boolean inserted = false;
            if (sort) {
                for (int i = 0; i < this.getSize() && !inserted; i++) {
                    try {
                        final String comparator = ((obj == null) ? "" : obj.toString());
                        if (this.get(i).toString().compareTo(comparator) > 0) {
                            this.add(i, obj);
                            inserted = true;
                        }
                    } catch (Throwable t) {
                        log.error("Error al ordenar a " + obj + " y no lo incluimos", t);
                        inserted = true;
                    }
                }
            }
            if (!inserted) {
                super.addElement(obj);
            }
        }
    });
    log.trace("Lista con " + items.length + " objetos");
    for (Object obj : items) {
        ((DefaultListModel) list.getModel()).addElement(obj);
    }
    list.setCellRenderer(new DefaultListCellRenderer() {

        private static final long serialVersionUID = -987995602141400182L;

        @Override
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
                boolean cellHasFocus) {
            JLabel c = new JLabel();
            c.setText(value.toString());

            if (isSelected) {
                c.setOpaque(true);
                c.setBackground(Color.YELLOW);
            }
            return c;
        }
    });
    list.setMinimumSize(dimension);
    list.setFixedCellHeight(22);
    return list;
}

From source file:org.cds06.speleograph.graph.GraphEditor.java

/**
 * Creates a modal dialog by specifying the attached {@link GraphPanel}.
 * <p>Please look at {@link javax.swing.JDialog#JDialog()} to see defaults params applied to this Dialog.</p>
 *//*  w  w  w  . j  av  a 2  s  .  c o m*/
public GraphEditor(GraphPanel panel) {
    super((Frame) SwingUtilities.windowForComponent(panel), true);
    Validate.notNull(panel);
    this.graphPanel = panel;

    KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
    mainPanel.registerKeyboardAction(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            setVisible(false);
        }
    }, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);

    setContentPane(mainPanel);
    mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    this.setTitle(I18nSupport.translate("menus.graph.graphEditor"));

    {
        // This section use FormLayout which is an external layout for Java, consult the doc before edit the
        // following lines !
        final FormLayout layout = new FormLayout(
                "right:max(40dlu;p), 4dlu, p:grow, 4dlu, p, 4dlu, p:grow, 4dlu, p", //NON-NLS
                "p,4dlu,p,4dlu,p,4dlu,p,4dlu,p" //NON-NLS
        );

        PanelBuilder builder = new PanelBuilder(layout);

        final JLabel colorLabel = new JLabel();
        final JTextField titleForGraph = new JTextField(
                graphPanel.getChart().getTitle() != null ? graphPanel.getChart().getTitle().getText() : "");
        final JLabel colorXYPlotLabel = new JLabel();
        final JLabel colorGridLabel = new JLabel();
        final JCheckBox showLegendCheckBox = new JCheckBox("Afficher la lgende",
                graphPanel.getChart().getLegend().isVisible());

        {
            builder.addLabel("Titre :", "1,1");
            builder.add(titleForGraph, "3,1,7,1");
        }

        {
            builder.addLabel(I18nSupport.translate("menus.graph.graphEditor.backgroundColor"), "1,3");
            colorLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
            colorLabel.setText(" ");
            colorLabel.setBackground((Color) graphPanel.getChart().getBackgroundPaint());
            colorLabel.setOpaque(true);
            colorLabel.setEnabled(false);
            final JButton edit = new JButton(I18nSupport.translate("menus.graph.graphEditor.edit"));
            edit.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    Color c = JColorChooser.showDialog(GraphEditor.this,
                            I18nSupport.translate("menus.graph.graphEditor.selectColor"),
                            colorLabel.getBackground());
                    if (c != null) {
                        colorLabel.setBackground(c);
                    }
                }
            });
            builder.add(colorLabel, "3,3,5,1");
            builder.add(edit, "9,3");
        }

        final XYPlot xyPlot = graphPanel.getChart().getXYPlot();
        {
            builder.addLabel(I18nSupport.translate("menus.graph.graphEditor.graphColor"), "1,5");
            colorXYPlotLabel.setText(" ");
            colorXYPlotLabel.setOpaque(true);
            colorXYPlotLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
            colorXYPlotLabel.setBackground((Color) xyPlot.getBackgroundPaint());
            colorXYPlotLabel.setEnabled(false);
            final JButton edit = new JButton(I18nSupport.translate("menus.graph.graphEditor.edit"));
            edit.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    Color c = JColorChooser.showDialog(GraphEditor.this,
                            I18nSupport.translate("menus.graph.graphEditor.selectColor"),
                            colorXYPlotLabel.getBackground());
                    if (c != null) {
                        colorXYPlotLabel.setBackground(c);
                    }
                }
            });
            builder.add(colorXYPlotLabel, "3,5,5,1");
            builder.add(edit, "9,5");
        }

        {
            builder.addLabel(I18nSupport.translate("menus.graph.graphEditor.gridColor"), "1,7");
            colorGridLabel.setOpaque(true);
            colorGridLabel.setText(" ");
            colorGridLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
            colorGridLabel.setBackground((Color) xyPlot.getRangeGridlinePaint());
            colorGridLabel.setEnabled(false);
            final JButton edit = new JButton(I18nSupport.translate("menus.graph.graphEditor.edit"));
            edit.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    Color c = JColorChooser.showDialog(GraphEditor.this,
                            I18nSupport.translate("menus.graph.graphEditor.selectColor"),
                            colorGridLabel.getBackground());
                    if (c != null) {
                        colorGridLabel.setBackground(c);
                    }
                }
            });
            builder.add(colorGridLabel, "3,7,5,1");
            builder.add(edit, "9,7");
        }

        {
            builder.add(showLegendCheckBox, "1,9,9,1");
        }

        mainPanel.add(builder.build(), BorderLayout.CENTER);

        ButtonBarBuilder buttonBarBuilder = new ButtonBarBuilder();

        buttonBarBuilder.addGlue();

        buttonBarBuilder.addButton(new AbstractAction() {
            {
                putValue(NAME, I18nSupport.translate("cancel"));
            }

            @Override
            public void actionPerformed(ActionEvent e) {
                GraphEditor.this.setVisible(false);
            }
        });

        buttonBarBuilder.addButton(new AbstractAction() {

            {
                putValue(NAME, I18nSupport.translate("ok"));
            }

            @Override
            public void actionPerformed(ActionEvent e) {
                if (titleForGraph.getText().isEmpty())
                    graphPanel.getChart().setTitle((String) null);
                else
                    graphPanel.getChart().setTitle(titleForGraph.getText());
                {
                    Color c = colorGridLabel.getBackground();
                    xyPlot.setRangeGridlinePaint(c);
                    xyPlot.setRangeMinorGridlinePaint(c);
                    xyPlot.setDomainGridlinePaint(c);
                    xyPlot.setDomainMinorGridlinePaint(c);
                }
                graphPanel.getChart().setBackgroundPaint(colorLabel.getBackground());
                xyPlot.setBackgroundPaint(colorXYPlotLabel.getBackground());
                graphPanel.getChart().getLegend().setVisible(showLegendCheckBox.isSelected());
                GraphEditor.this.setVisible(false);
            }
        });

        mainPanel.add(buttonBarBuilder.build(), BorderLayout.SOUTH);
    }

    pack();
    Dimension d = this.getPreferredSize();
    this.setSize(new Dimension(d.width + 20, d.height));
    setResizable(false);
}

From source file:org.pentaho.support.standalone.SDSupportUtility.java

/**
 * initializing UI//from  w ww.  j a va2  s  .co  m
 * 
 * @throws Exception
 */
public SDSupportUtility() throws Exception {

    prop = loadProperty();

    setResizable(false);
    setTitle(SDConstant.PENT_SUP_WIZARD);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(100, 100, 665, 516);

    contentPane = new JPanel();
    contentPane.setBackground(UIManager.getColor("Button.background"));
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    setContentPane(contentPane);
    contentPane.setLayout(null);

    JLabel lblLastAttached = new JLabel("Last Attached");
    lblLastAttached.setOpaque(false);
    lblLastAttached.setHorizontalAlignment(SwingConstants.LEFT);
    lblLastAttached.setBounds(322, 335, 127, 23);
    contentPane.add(lblLastAttached);

    JLabel lblPentahoCustomerSupport = new JLabel("Pentaho Customer Support Wizard");
    lblPentahoCustomerSupport.setForeground(new Color(51, 51, 51));
    lblPentahoCustomerSupport.setVerticalAlignment(SwingConstants.TOP);
    lblPentahoCustomerSupport.setHorizontalAlignment(SwingConstants.RIGHT);
    lblPentahoCustomerSupport.setFont(new Font("Tahoma", Font.BOLD, 23));
    lblPentahoCustomerSupport.setBounds(130, 109, 506, 37);
    contentPane.add(lblPentahoCustomerSupport);

    JLabel lbllogo = new JLabel();
    lbllogo.setIcon(new ImageIcon(
            SDSupportUtility.class.getResource("/org/pentaho/support/standalone/puc-login-logo.png")));
    lbllogo.setBounds(10, 11, 409, 93);
    contentPane.add(lbllogo);

    chckbxNewCheckBoxEnvironment = new JCheckBox("Environment");
    chckbxNewCheckBoxEnvironment.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {

            if (e.getStateChange() == ItemEvent.SELECTED) {
                ArgList.add(SDConstant.ENVIRONMENT);
            } else {
                ArgList.remove(SDConstant.ENVIRONMENT);
            }
        }
    });
    chckbxNewCheckBoxEnvironment.setBounds(109, 268, 243, 23);
    contentPane.add(chckbxNewCheckBoxEnvironment);
    chckbxNewCheckBoxEnvironment.setOpaque(false);

    chckbxNewCheckBoxStructure = new JCheckBox("Structure Details");
    chckbxNewCheckBoxStructure.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {

            if (e.getStateChange() == ItemEvent.SELECTED) {
                ArgList.add(SDConstant.STRUCT);
            } else {
                ArgList.remove(SDConstant.STRUCT);
            }
        }
    });
    chckbxNewCheckBoxStructure.setBounds(377, 190, 248, 23);
    contentPane.add(chckbxNewCheckBoxStructure);
    chckbxNewCheckBoxStructure.setOpaque(false);

    chckbxLogs = new JCheckBox("Logs");
    chckbxLogs.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {

            if (e.getStateChange() == ItemEvent.SELECTED) {
                ArgList.add(SDConstant.LOGS);
            } else {
                ArgList.remove(SDConstant.LOGS);
            }
        }
    });
    chckbxLogs.setBounds(377, 164, 248, 23);
    contentPane.add(chckbxLogs);
    chckbxLogs.setOpaque(false);

    chckbxGetSecureFiles = new JCheckBox("Secure Files");
    chckbxGetSecureFiles.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {

            if (e.getStateChange() == ItemEvent.SELECTED) {
                ArgList.add(SDConstant.SECURITY);
            } else {
                ArgList.remove(SDConstant.SECURITY);
            }
        }
    });
    chckbxGetSecureFiles.setBounds(109, 190, 243, 23);
    contentPane.add(chckbxGetSecureFiles);
    chckbxGetSecureFiles.setOpaque(false);

    chckbxMd5 = new JCheckBox("MD5 Hash Value");
    chckbxMd5.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {

            if (e.getStateChange() == ItemEvent.SELECTED) {
                ArgList.add(SDConstant.MD5);
            } else {
                ArgList.remove(SDConstant.MD5);
            }
        }
    });
    chckbxMd5.setBounds(109, 216, 243, 23);
    contentPane.add(chckbxMd5);
    chckbxMd5.setOpaque(false);

    chckbxDbdetails = new JCheckBox("Datasource Details");
    chckbxDbdetails.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {

            if (e.getStateChange() == ItemEvent.SELECTED) {
                ArgList.add(SDConstant.DATASOURCE);
            } else {
                ArgList.remove(SDConstant.DATASOURCE);
            }
        }
    });
    chckbxDbdetails.setBounds(109, 294, 243, 23);
    contentPane.add(chckbxDbdetails);
    chckbxDbdetails.setOpaque(false);

    chckbxLicense = new JCheckBox("License File");
    chckbxLicense.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                ArgList.add(SDConstant.LICENSE);
            } else {
                ArgList.remove(SDConstant.LICENSE);
            }
        }
    });
    chckbxLicense.setBounds(109, 164, 243, 23);
    contentPane.add(chckbxLicense);
    chckbxLicense.setOpaque(false);

    chckbxProcesslist = new JCheckBox("Running Process");
    chckbxProcesslist.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {

            if (e.getStateChange() == ItemEvent.SELECTED) {
                ArgList.add(SDConstant.RUNNING_TASK);
            } else {
                ArgList.remove(SDConstant.RUNNING_TASK);
            }
        }
    });
    chckbxProcesslist.setBounds(109, 242, 243, 23);
    contentPane.add(chckbxProcesslist);
    chckbxProcesslist.setOpaque(false);

    chckbxTomcatxml = new JCheckBox("XML files from Tomcat");
    chckbxTomcatxml.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {

            if (e.getStateChange() == ItemEvent.SELECTED) {
                ArgList.add(SDConstant.FILE);
                tomcatXml = true;
            } else {
                ArgList.remove(SDConstant.FILE);
                tomcatXml = false;
            }
        }
    });
    chckbxTomcatxml.setBounds(377, 242, 248, 23);
    contentPane.add(chckbxTomcatxml);
    chckbxTomcatxml.setOpaque(false);

    chckbxServerXml = new JCheckBox("XML files from Server");
    chckbxServerXml.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {

            if (e.getStateChange() == ItemEvent.SELECTED) {
                ArgList.add(SDConstant.FILE);
                serverXml = true;
            } else {
                ArgList.remove(SDConstant.FILE);
                serverXml = false;
            }
        }
    });
    chckbxServerXml.setBounds(377, 216, 248, 23);
    contentPane.add(chckbxServerXml);
    chckbxServerXml.setOpaque(false);

    chckbxGetBatfiles = new JCheckBox("Start up files from server");
    chckbxGetBatfiles.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {

            if (e.getStateChange() == ItemEvent.SELECTED) {
                ArgList.add(SDConstant.FILE);
                serverBatFile = true;
            } else {
                ArgList.remove(SDConstant.FILE);
                serverBatFile = false;
            }
        }
    });
    chckbxGetBatfiles.setBounds(377, 268, 248, 23);
    contentPane.add(chckbxGetBatfiles);
    chckbxGetBatfiles.setOpaque(false);

    chckbxServerproperties = new JCheckBox("Properites files from server");
    chckbxServerproperties.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {

            if (e.getStateChange() == ItemEvent.SELECTED) {
                ArgList.add(SDConstant.FILE);
                serverProrperties = true;
            } else {
                ArgList.remove(SDConstant.FILE);
                serverProrperties = false;
            }
        }
    });
    chckbxServerproperties.setBounds(377, 294, 248, 23);
    contentPane.add(chckbxServerproperties);
    chckbxServerproperties.setOpaque(false);

    btnNewButton = new JButton("Package");
    btnNewButton.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent arg0) {

            try {

                if (installType.equalsIgnoreCase("Manual")) {

                    if (prop.getProperty(SDConstant.BI_TOM_PATH) == null) {
                        JOptionPane.showMessageDialog(contentPane, SDConstant.ERROR_12, "Inane error",
                                JOptionPane.ERROR_MESSAGE);
                    } else {

                        WEB_XML = new StringBuilder();
                        WEB_XML.append(prop.getProperty(SDConstant.BI_TOM_PATH)).append(File.separator)
                                .append(SDConstant.WEB_APP).append(File.separator).append(SDConstant.PENTAHO)
                                .append(File.separator).append(SDConstant.WEB_INF).append(File.separator)
                                .append(SDConstant.WEB_XML);

                        PENTAHO_SOLU_PATH = getSolutionPath("biserver", WEB_XML.toString());
                        prop.put(SDConstant.PENTAHO_SOLU_PATH, PENTAHO_SOLU_PATH);
                        prop.put(SDConstant.BI_PATH, PENTAHO_SOLU_PATH);
                    }

                }

                if (prop.getProperty(SDConstant.BI_PATH) == null) {
                    JOptionPane.showMessageDialog(contentPane, SDConstant.ERROR_1, "Inane error",
                            JOptionPane.ERROR_MESSAGE);
                }
                if (prop.getProperty(SDConstant.BI_TOM_PATH) == null) {
                    JOptionPane.showMessageDialog(contentPane, SDConstant.ERROR_12, "Inane error",
                            JOptionPane.ERROR_MESSAGE);
                }
                disableAll();
                setBIServerPath(prop);
                final String data = textFieldBrowser.getText();
                if (!data.equalsIgnoreCase(null)) {
                    ArgList.add(SDConstant.BROWSER);
                }

                String[] array = new String[ArgList.size()];

                int count = 0;
                for (int i = 0; i < ArgList.size(); i++) {

                    String retName = ArgList.get(i);
                    if (retName.equals("file")) {
                        if (count == 0) {
                            array[i] = retName;
                            count++;
                        }
                    } else {
                        array[i] = retName;
                    }

                }

                ApplicationContext context = new ClassPathXmlApplicationContext(SDConstant.SPRNG_FILE_NAME);

                factory = (CofingRetrieverFactory) context.getBean("cofingRetrieverFactory");
                ConfigRetreiver[] config = factory.getConfigRetrevier(array);

                ExecutorService service = Executors.newFixedThreadPool(10);

                for (final ConfigRetreiver configobj : config) {
                    if (null != configobj) {
                        configobj.setBISeverPath(prop);
                        configobj.setServerName("biserver");

                        if (installType.equalsIgnoreCase("Installer")) {
                            configobj.setInstallType("Installer");
                        } else if (installType.equalsIgnoreCase("Archive")) {
                            configobj.setInstallType("Archive");
                        } else if (installType.equalsIgnoreCase("Manual")) {
                            configobj.setInstallType("Manual");
                        }

                        if (configobj instanceof FileRetriever) {
                            configobj.setBidiXml(serverXml);
                            configobj.setBidiBatFile(serverBatFile);
                            configobj.setBidiProrperties(serverProrperties);
                            configobj.setTomcatXml(tomcatXml);
                        }
                        if (configobj instanceof BrowserInfoRetriever) {
                            configobj.setBrowserInfo(data);
                        }

                        service.execute(new Runnable() {
                            public void run() {
                                if (null != configobj)
                                    configobj.readAndSaveConfiguration(prop);
                            }
                        });
                    }
                }
                btnNewButton.setVisible(false);
                progressBar.setVisible(true);
                ProgressThread thread = new ProgressThread();
                thread.setSupport(getSupport());
                thread.setProp(prop);
                new Thread(thread).start();

                service.shutdown();
            } catch (Exception e1) {
                e1.printStackTrace();
            }

        }

    });

    chckbxSelectAll = new JCheckBox("Select/ De-select");
    chckbxSelectAll.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                selectAll();
            } else {
                deSelectAll();
            }
        }
    });

    chckbxSelectAll.setBounds(46, 138, 201, 23);
    chckbxSelectAll.setOpaque(false);
    contentPane.add(chckbxSelectAll);
    btnNewButton.setForeground(SystemColor.infoText);
    btnNewButton.setBounds(10, 430, 639, 37);
    contentPane.add(btnNewButton);
    chckbxServerproperties.setOpaque(false);

    JLabel lblAttach = new JLabel("Attach Artifact");
    lblAttach.setHorizontalAlignment(SwingConstants.LEFT);
    lblAttach.setBounds(32, 335, 177, 23);
    contentPane.add(lblAttach);
    lblAttach.setOpaque(false);

    JButton btnNewButtonBrowse = new JButton("Browse");
    btnNewButtonBrowse.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent arg0) {
            saveSelectedFile(prop);

            JFrame parentFrame = new JFrame();
            JFileChooser fileChooser = new JFileChooser();
            fileChooser.setDialogTitle("Specify a file to save");
            fileChooser.setMultiSelectionEnabled(true);

            int userSelection = fileChooser.showSaveDialog(parentFrame);

            if (userSelection == JFileChooser.APPROVE_OPTION) {
                fileToSave = fileChooser.getSelectedFiles();
                for (int i = 0; i < fileToSave.length; i++) {
                    File file = fileToSave[i];
                    String artifactpath = file.getAbsolutePath();

                    File f = new File(artifactpath);
                    String absolutefilename = f.getName();
                    String filename = ArtifactsDirectory.concat(absolutefilename);
                    CopyFile artifactcopy = new CopyFile(artifactpath, filename);
                    try {
                        artifactcopy.copy();
                    } catch (Exception e1) {
                        e1.printStackTrace();
                    }

                }
                uploadedFiles();

                rowList = new JList(model);
                listScrollPane.setViewportView(rowList);
                panel.add(listScrollPane);

            }
            rowList.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseClicked(MouseEvent e) {
                    lblDelete.setVisible(true);
                }
            });

        }
    });
    btnNewButtonBrowse.setBounds(208, 335, 104, 23);
    contentPane.add(btnNewButtonBrowse);
    btnNewButtonBrowse.setOpaque(false);

    textFieldBrowser = new JTextField();
    textFieldBrowser.setBounds(208, 364, 441, 23);
    contentPane.add(textFieldBrowser);
    textFieldBrowser.setColumns(10);

    progressBar = new JProgressBar(0, 100);
    progressBar.setBounds(8, 437, 639, 24);
    progressBar.setVisible(false);
    progressBar.setStringPainted(true);
    contentPane.add(progressBar);

    JLabel lblBrowserInformation = new JLabel("Browser Information");
    lblBrowserInformation.setHorizontalAlignment(SwingConstants.LEFT);
    lblBrowserInformation.setLabelFor(textFieldBrowser);
    lblBrowserInformation.setBounds(32, 368, 174, 14);
    contentPane.add(lblBrowserInformation);

    panel = new JPanel();
    panel.setBounds(423, 325, 127, 33);
    contentPane.add(panel);
    panel.setLayout(null);

    listScrollPane = new JScrollPane();
    listScrollPane.setBounds(0, 0, 127, 33);
    panel.add(listScrollPane);

    lblDelete = new JLabel("");
    lblDelete.setBounds(552, 325, 22, 23);
    lblDelete.setVisible(false);
    lblDelete.setIcon(
            new ImageIcon(SDSupportUtility.class.getResource("/org/pentaho/support/standalone/remove.png")));
    contentPane.add(lblDelete);
    lblDelete.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            int option = JOptionPane.showConfirmDialog(null, "Are you sure you want to delete this file ?");
            if (option == JOptionPane.YES_OPTION) {
                String sel = rowList.getSelectedValue().toString();
                String selected = dir + "/" + sel;
                File fileExists = new File(selected);
                fileExists.delete();
                model.remove(sel.indexOf(sel));
                lblDelete.setVisible(false);

            }
        }
    });

    JLabel instalType = new JLabel("Installation Type : ");
    instalType.setBounds(32, 395, 177, 23);
    instalType.setVisible(true);
    contentPane.add(instalType);

    ButtonGroup btnGrp = new ButtonGroup();

    rdbtnInstaller = new JRadioButton("Installer");
    rdbtnInstaller.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            installType = "Installer";
        }
    });
    rdbtnInstaller.setBounds(208, 395, 104, 23);
    rdbtnInstaller.setSelected(true);
    contentPane.add(rdbtnInstaller);
    btnGrp.add(rdbtnInstaller);

    rdbtnArchive = new JRadioButton("Archive");
    rdbtnArchive.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            installType = "Archive";
        }
    });
    rdbtnArchive.setBounds(333, 395, 104, 23);
    contentPane.add(rdbtnArchive);
    btnGrp.add(rdbtnArchive);

    rdbtnManual = new JRadioButton("Manual");
    rdbtnManual.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            installType = "Manual";
        }
    });
    rdbtnManual.setBounds(460, 395, 127, 27);
    contentPane.add(rdbtnManual);
    btnGrp.add(rdbtnManual);

    JLabel lblBackground = new JLabel();
    lblBackground.setIcon(new ImageIcon(
            SDSupportUtility.class.getResource("/org/pentaho/support/standalone/login-crystal-bg.jpg")));
    lblBackground.setBackground(SystemColor.controlHighlight);
    lblBackground.setHorizontalAlignment(SwingConstants.CENTER);
    lblBackground.setBounds(0, 0, 659, 488);
    contentPane.add(lblBackground);
}

From source file:UI.SecurityDashboard.java

private void performMetric7(MainViewPanel mvp) {
    Metric7 metric7 = new Metric7();

    JPanel graphPanel7 = new JPanel();
    graphPanel7.setLayout(new BorderLayout());
    graphPanel7.add(metric7.run(), BorderLayout.NORTH);

    PortPanel.setLayout(new BorderLayout());
    JTextArea header = new JTextArea(
            "\nOpen ports that are not being used by a secure service on a system may result in a malicious "
                    + "attacker gaining access to the network. By listing all open ports on each device, this can aid in ensuring that ports "
                    + "currently open are know of.\n");
    header.setLineWrap(true);//from w  ww  .  j a  v  a 2  s  .c  o  m
    header.setWrapStyleWord(true);
    header.setEditable(false);
    PortPanel.add(header, BorderLayout.NORTH);
    PortPanel.add(graphPanel7, BorderLayout.CENTER);

    Metric7Panel.setBackground(Color.WHITE);
    Metric7Panel.setLayout(new BorderLayout());

    Font titleFont = new Font("Calibri", Font.BOLD, 27);
    JLabel portTitleLabel = new JLabel("              Open Ports");
    portTitleLabel.setFont(titleFont);

    Metric7Panel.add(portTitleLabel, BorderLayout.NORTH);
    JPanel p = new JPanel();
    p.setLayout(new BorderLayout());
    JLabel emptyLabel = new JLabel(" ");
    JLabel emptyLabel2 = new JLabel(" ");
    JLabel emptyLabel3 = new JLabel("   ");
    JLabel emptyLabel4 = new JLabel("   ");

    emptyLabel.setBackground(Color.white);
    emptyLabel2.setBackground(Color.white);
    emptyLabel3.setBackground(Color.white);
    emptyLabel4.setBackground(Color.white);

    emptyLabel.setOpaque(true);
    emptyLabel2.setOpaque(true);
    emptyLabel3.setOpaque(true);
    emptyLabel4.setOpaque(true);

    p.add(emptyLabel, BorderLayout.NORTH);
    p.add(emptyLabel3, BorderLayout.WEST);
    p.add(mvp.getPanel7(metric7), BorderLayout.CENTER);
    p.add(emptyLabel4, BorderLayout.EAST);
    p.add(emptyLabel2, BorderLayout.SOUTH);
    Metric7Panel.add(p, BorderLayout.CENTER);
    Metric7Panel.setBackground(Color.white);
}

From source file:edu.ku.brc.af.ui.forms.formatters.UIFormatterEditorDlg.java

@Override
public void createUI() {
    super.createUI();

    CellConstraints cc = new CellConstraints();

    orderUpBtn = createIconBtn("ReorderUp", "TCGD_MOVE_UP", new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            int inx = fieldsTbl.getSelectedRow();
            UIFieldFormatterField item = (UIFieldFormatterField) fields.get(inx);

            fields.remove(inx);//from   w  w w  .  j a v  a 2s .  co m
            fields.insertElementAt(item, inx - 1);
            fieldsTbl.getSelectionModel().setSelectionInterval(inx - 1, inx - 1);
            selectedFormat.resetLength();

            updateEnabledState();
            updateUIEnabled();
        }
    });
    orderDwnBtn = createIconBtn("ReorderDown", "TCGD_MOVE_DOWN", new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            int inx = fieldsTbl.getSelectedRow();
            UIFieldFormatterField item = (UIFieldFormatterField) fields.get(inx);

            fields.remove(inx);
            fields.insertElementAt(item, inx + 1);
            fieldsTbl.getSelectionModel().setSelectionInterval(inx + 1, inx + 1);
            selectedFormat.resetLength();

            updateEnabledState();
            updateUIEnabled();
        }
    });

    // get formatters for field
    List<UIFieldFormatterIFace> fmtrs = new Vector<UIFieldFormatterIFace>(uiFieldFormatterMgrCache
            .getFormatterList(fieldInfo.getTableInfo().getClassObj(), fieldInfo.getName()));
    Collections.sort(fmtrs, new Comparator<UIFieldFormatterIFace>() {
        public int compare(UIFieldFormatterIFace o1, UIFieldFormatterIFace o2) {
            return o1.toPattern().compareTo(o2.toPattern());
        }
    });

    // table and field titles
    PanelBuilder tblInfoPB = new PanelBuilder(
            new FormLayout("r:p,2px,f:p:g", "p,2px,p,2px,p,10px")/*, new FormDebugPanel()*/);

    String typeStr = fieldInfo.getType();
    typeStr = typeStr.indexOf('.') > -1 ? StringUtils.substringAfterLast(fieldInfo.getType(), ".") : typeStr;

    JLabel tableTitleLbl = createI18NFormLabel("FFE_TABLE");
    JLabel tableTitleValueLbl = createLabel(fieldInfo.getTableInfo().getTitle());
    tableTitleValueLbl.setBackground(Color.WHITE);
    tableTitleValueLbl.setOpaque(true);

    JLabel fieldTitleLbl = createI18NFormLabel("FFE_FIELD");
    JLabel fieldTitleValueLbl = createLabel(fieldInfo.getTitle());
    fieldTitleValueLbl.setBackground(Color.WHITE);
    fieldTitleValueLbl.setOpaque(true);

    JLabel fieldLengthLbl = createI18NFormLabel("FFE_LENGTH");
    JLabel fieldLengthValueLbl = createLabel(Integer.toString(fieldInfo.getLength()));
    fieldLengthValueLbl.setBackground(Color.WHITE);
    fieldLengthValueLbl.setOpaque(true);

    int y = 1;
    tblInfoPB.add(tableTitleLbl, cc.xy(1, y));
    tblInfoPB.add(tableTitleValueLbl, cc.xy(3, y));
    y += 2;
    tblInfoPB.add(fieldTitleLbl, cc.xy(1, y));
    tblInfoPB.add(fieldTitleValueLbl, cc.xy(3, y));
    y += 2;
    tblInfoPB.add(fieldLengthLbl, cc.xy(1, y));
    tblInfoPB.add(fieldLengthValueLbl, cc.xy(3, y));
    y += 2;

    // sample panel
    sampleLabel = createLabel("", SwingConstants.LEFT);
    JPanel samplePanel = new JPanel();
    samplePanel.setBorder(BorderFactory.createTitledBorder(getResourceString("FFE_SAMPLE"))); //$NON-NLS-1$ 
    samplePanel.add(sampleLabel);

    // name text field
    nameTF = createTextField(20);

    // title text field
    titleTF = createTextField(20);

    byYearCB = createCheckBox(getResourceString("FFE_BY_YEAR_CHECKBOX")); //$NON-NLS-1$ 
    hookByYearCheckBoxListener();

    fieldsPanel = new EditDeleteAddPanel(getSaveAL(), getDelAL(), getAddAL());
    fieldsTbl = new JTable(fieldsModel = new FieldsTableModel());
    fieldTypeCbx = new JComboBox(FieldType.values()); // I18N
    fieldTxt = createTextField(20);
    fieldsPanel.getAddBtn().setEnabled(true);
    fieldsPanel.getEditBtn().setIcon(IconManager.getIcon("Green Arrow Up", IconManager.IconSize.Std16));
    UIHelper.makeTableHeadersCentered(fieldsTbl, true);

    fieldTxt.setDocument(new FieldDocument());

    fieldsTbl.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    int width = fieldTypeCbx.getPreferredSize().width;

    y = 1;
    PanelBuilder subPB = new PanelBuilder(new FormLayout("r:p,2px,p", "p,4px, p,4px, p,4px, p,4px"));

    subPB.add(createI18NFormLabel("FFE_NAME"), cc.xy(1, y));
    subPB.add(nameTF, cc.xy(3, y));
    y += 2;

    subPB.add(createI18NFormLabel("FFE_TITLE"), cc.xy(1, y));
    subPB.add(titleTF, cc.xy(3, y));
    y += 2;

    subPB.add(byYearCB, cc.xy(3, y));
    y += 2;

    // CardLayout for Editor Panels

    SpinnerModel retModel = new SpinnerNumberModel(1, //initial value
            1, //min
            fieldInfo.getLength(), //max
            1); //step
    sizeSpinner = new JSpinner(retModel);
    isIncChk = new JCheckBox("Is Incrementer"); // I18N

    String colDefs = "f:p:g,p,2px," + width + "px,2px,p";

    closeBtn = createClose(0);
    PanelBuilder numPB = new PanelBuilder(new FormLayout(colDefs, "p,2px,p,2px,p"));
    numPB.add(createI18NFormLabel("FFE_LENGTH"), cc.xy(2, 1));
    numPB.add(sizeSpinner, cc.xy(4, 1));
    //numPB.add(closeBtn,    cc.xy(6, 1));
    numPB.add(isIncChk, cc.xy(4, 3));

    sepCbx = new JComboBox(new String[] { "-", ".", "/", "(space)", "_" });
    closeBtn = createClose(1);
    PanelBuilder sepPB = new PanelBuilder(new FormLayout(colDefs, "p,2px,p"));
    sepPB.add(createI18NFormLabel("FFE_SEP"), cc.xy(2, 1));
    sepPB.add(sepCbx, cc.xy(4, 1));
    //sepPB.add(closeBtn, cc.xy(6, 1));

    closeBtn = createClose(2);
    PanelBuilder txtPB = new PanelBuilder(new FormLayout(colDefs, "p,2px,p"));
    txtPB.add(createI18NFormLabel("FFE_TEXT"), cc.xy(2, 1));
    txtPB.add(fieldTxt, cc.xy(4, 1));

    cardPanel = new JPanel(cardLayout);
    cardPanel.add("size", numPB.getPanel());
    cardPanel.add("text", txtPB.getPanel());
    cardPanel.add("sep", sepPB.getPanel());
    cardPanel.add("none", new JLabel(" "));

    y = 1;
    PanelBuilder leftPB = new PanelBuilder(new FormLayout("f:p:g", "t:p,10px,p,f:p:g"));
    leftPB.add(tblInfoPB.getPanel(), cc.xy(1, y));
    y += 2;
    leftPB.add(subPB.getPanel(), cc.xy(1, y));
    y += 2;

    PanelBuilder upDownPanel = new PanelBuilder(new FormLayout("p", "f:p:g, p, 2px, p, f:p:g"));
    upDownPanel.add(orderUpBtn, cc.xy(1, 2));
    upDownPanel.add(orderDwnBtn, cc.xy(1, 4));

    totLenLbl = createLabel("XXXXX");

    y = 1;
    PanelBuilder rightPB = new PanelBuilder(new FormLayout("p:g,2px,p,2px,p", "200px,2px,p,2px,p,2px,p"));
    rightPB.add(createScrollPane(fieldsTbl), cc.xywh(1, y, 3, 1));
    rightPB.add(upDownPanel.getPanel(), cc.xywh(5, y, 1, 1));
    y += 2;
    rightPB.add(totLenLbl, cc.xy(1, y));
    rightPB.add(fieldsPanel, cc.xywh(3, y, 1, 1));
    y += 2;
    rightPB.add(fieldTypeLbl = createI18NFormLabel("FFE_TYPE"), cc.xy(1, y));
    rightPB.add(fieldTypeCbx, cc.xy(3, y));
    rightPB.add(closeBtn, cc.xy(5, y));
    y += 2;
    rightPB.add(cardPanel, cc.xyw(1, y, 3));
    y += 2;

    y = 1;
    PanelBuilder pb = new PanelBuilder(new FormLayout("p:g,10px,p,10px,p:g,10px,p", "f:p:g,10px,p"));
    Color bg = getBackground();
    pb.add(new VerticalSeparator(bg.darker(), bg.brighter()), cc.xywh(3, 1, 1, 1));

    pb.add(leftPB.getPanel(), cc.xy(1, y));
    pb.add(rightPB.getPanel(), cc.xy(5, y));
    //pb.add(keyPanel,             cc.xy(7, y));     
    y += 2;
    pb.add(samplePanel, cc.xyw(1, y, 7));
    y += 2;

    setByYearSelected(selectedFormat);

    nameTF.setEditable(isNew);
    nameTF.setText(selectedFormat.getName());
    titleTF.setText(selectedFormat.getTitle());
    updateSample();

    hookTextChangeListener(nameTF, "FFE_NO_NAME", 32);
    hookTextChangeListener(titleTF, "FFE_NO_TITLE", 32);

    pb.setDefaultDialogBorder();

    contentPanel = pb.getPanel();
    mainPanel.add(contentPanel, BorderLayout.CENTER);

    updateUIEnabled();

    pack();

    enabledEditorUI(false);

    hookFieldsTblSelectionListener();

    fieldTypeCbx.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            typeChanged();
        }
    });

    sepCbx.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            fieldHasChanged = true;
            updateEnabledState();
            hasChanged = true;
            updateUIEnabled();
        }
    });

    fieldTxt.getDocument().addDocumentListener(new DocumentAdaptor() {
        @Override
        protected void changed(DocumentEvent e) {
            fieldHasChanged = true;
            updateEnabledState();
            hasChanged = true;
            updateUIEnabled();
        }
    });

    sizeSpinner.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            fieldHasChanged = true;
            updateEnabledState();
            hasChanged = true;
            updateUIEnabled();

        }
    });

    isIncChk.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            fieldHasChanged = true;
            if (!isIncChk.isSelected()) {
                byYearCB.setSelected(false);
            }
            updateEntry();
            updateUIEnabled();
            updateEnabledState();
            fieldsTbl.repaint();
        }
    });

    fieldTypeCbx.setSelectedIndex(-1);
    fieldHasChanged = false;
    updateEnabledState();
}

From source file:de.quadrillenschule.azocamsyncd.gui.ExploreWifiSDPanel.java

/**
 * Creates new form ExploreWifiSDPanel/*from  w ww  .ja  v a  2 s.  co m*/
 */
public ExploreWifiSDPanel() {
    initComponents();
    rootNode = new DefaultMutableTreeNode("/");
    DefaultTreeModel dtm = new DefaultTreeModel(rootNode);
    remotejTree.setModel(dtm);
    remotejTree.addTreeSelectionListener(new TreeSelectionListener() {

        @Override
        public void valueChanged(TreeSelectionEvent e) {
            updateSingleView();
        }
    });
    remotejTree.setCellRenderer(new TreeCellRenderer() {

        @Override
        public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected,
                boolean expanded, boolean leaf, int row, boolean hasFocus) {
            JLabel retval = new JLabel(value.toString());
            AZoFTPFile myaffile = null;
            if (afs == null) {
                return retval;
            }
            for (AZoFTPFile af : afs) {
                if (new String(af.dir + af.ftpFile.getName()).equals(value.toString())) {
                    myaffile = af;
                    break;
                }
            }
            try {
                if (!myaffile.ftpFile.isDirectory()) {
                    if (!localStorage.getLocalFile(myaffile).exists()) {

                        if (!localStorage.isFileSynced(myaffile)) {
                            retval.setForeground(new Color(0, 20, 100));
                        }
                    } else {
                        retval.setForeground(new Color(20, 100, 0));
                    }
                }
            } catch (Exception ex) {
                //           Logger.getLogger(ExploreWifiSDPanel.class.getName()).log(Level.SEVERE, null, ex);
            }

            if (selected) {
                retval.setOpaque(true);
                retval.setBackground(Color.darkGray);
            }
            return retval;
        }
    });
}

From source file:com.diversityarrays.kdxplore.KDXploreFrame.java

private Component makeComponentForTab(KdxApp kdxApp, Component uiComponent) {
    Component appComponent = uiComponent;
    DevelopmentState devState = kdxApp.getDevelopmentState();
    if (devState.getShouldShowHeading()) {
        JLabel heading = new JLabel(devState.getHeadingText(), JLabel.CENTER);
        heading.setOpaque(true);
        heading.setForeground(devState.getHeadingFontColor());
        heading.setBackground(Color.LIGHT_GRAY);
        heading.setFont(heading.getFont().deriveFont(Font.BOLD));

        JPanel p = new JPanel(new BorderLayout());
        p.add(heading, BorderLayout.NORTH);
        //Color.DARK_GRAY, Font.BOLD, Color.LIGHT_GRAY, Color.GRAY
        //            p.add(GuiUtil.createLabelSeparator(devState.getHeadingText(), fontColor, Font.BOLD, Color.LIGHT_GRAY, Color.GRAY),
        //                    BorderLayout.NORTH);
        p.add(uiComponent, BorderLayout.CENTER);
        appComponent = p;//  w  w  w .  j ava 2  s.c  om
    }
    return appComponent;
}

From source file:org.biojava.bio.view.MotifAnalyzer.java

/**
 * /*from   w w w  .j a  v a  2s .c  o m*/
 * @param f1 sequence file
 * @param motifs list of motifs to display
 */
public void showMotifs(SequenceIterator seqItr, List<Motif> motifs) {
    seqViewerTab.removeAll();
    seqViewerTab.setLayout(new BorderLayout());

    try {
        Vector<Sequence> seqs = new Vector<Sequence>();
        Set<MotifFinder> finders = new HashSet<MotifFinder>();

        while (seqItr.hasNext())
            seqs.add(seqItr.nextSequence());

        // labels panel

        JPanel labelPanel = new JPanel();
        seqViewerTab.add(labelPanel, BorderLayout.NORTH);

        // Sequence panels array
        JPanel seqViewer = new JPanel(new GridLayout(seqs.size(), 1));
        seqViewerTab.add(seqViewer, BorderLayout.CENTER);

        SequencePanel[] seqPanel = new SequencePanel[seqs.size()];
        GridLayout seqPanelLayout = new GridLayout(2, 1);
        seqPanelLayout.setColumns(1);
        seqPanelLayout.setHgap(5);
        seqPanelLayout.setVgap(5);
        seqPanelLayout.setRows(2);
        int i = 0;

        for (Iterator<Sequence> itr = seqs.iterator(); itr.hasNext(); i++) {
            Sequence sourceSeq = itr.next();
            String name = sourceSeq.getName().substring(sourceSeq.getName().indexOf("_") + 1);
            seqPanel[i] = new SequencePanel();
            seqPanel[i].setLayout(seqPanelLayout);
            int num = 0;
            String[] f = new String[motifs.size()];
            for (Iterator<Motif> m = motifs.iterator(); m.hasNext();) {
                Motif motif = m.next();
                if (motif.getSites().get(name) == null)
                    continue;
                for (Iterator<Site> itr2 = motif.getSites().get(name).iterator(); itr2.hasNext();) {
                    Site seq = itr2.next();
                    finders.add(motif.getFinder());
                    seq.location = new RangeLocation(sourceSeq.length() + seq.location.getMin(),
                            sourceSeq.length() + seq.location.getMax());
                    seq.type = motif.getFinder().name() + "_" + num;
                    sourceSeq.createFeature(seq);
                }
                f[num] = motif.getFinder().name() + "_" + num;
                num++;
            }

            seqPanel[i].setSequence(sourceSeq);
            seqPanel[i].setRange(new RangeLocation(1, sourceSeq.length()));
            // Magic number from EmblViewer
            seqPanel[i].setScale(Math.exp(-INITIAL_SCALE / 7.0) * 20.0);
            seqPanel[i].setDirection(SequencePanel.HORIZONTAL);

            OptimizableFilter[] optFilter = new OptimizableFilter[num];//MotifFinder.values().length];
            FeatureBlockSequenceRenderer[] renderer = new FeatureBlockSequenceRenderer[num];//MotifFinder.values().length];

            for (int k = 0; k < num; k++)//MotifFinder.values().length; k++)
            {
                optFilter[k] = new FeatureFilter.ByType(f[k]);//MotifFinder.values()[k].name());
                renderer[k] = new FeatureBlockSequenceRenderer(new RectangularBeadRenderer(10.0f, 5.0f,
                        Color.black, MotifFinder.valueOf(f[k].substring(0, f[k].indexOf('_'))).color,
                        new BasicStroke()));
            }

            MultiLineRenderer multi = new MultiLineRenderer();

            for (int k = 0; k < renderer.length; k++)
                multi.addRenderer(new FilteringRenderer(renderer[k], optFilter[k], false));

            multi.addRenderer(new SymbolSequenceRenderer());
            multi.addRenderer(new RulerRenderer());

            seqPanel[i].setRenderer(multi);
            seqPanel[i].setEnabled(false);

            JScrollPane seqScroll = new JScrollPane(seqPanel[i]);

            JPanel temp = new JPanel(new BorderLayout());

            temp.add(getControlBox(seqPanel[i], sourceSeq.getName()), BorderLayout.NORTH);
            temp.add(seqScroll, BorderLayout.CENTER);

            seqViewer.add(temp);
        }

        for (Iterator<MotifFinder> itr = finders.iterator(); itr.hasNext();) {
            MotifFinder finder = itr.next();
            // Add label of this MotifFinder
            labelPanel.add(new JLabel(finder.name()));
            JLabel l = new JLabel("      ");
            l.setOpaque(true);
            l.setBackground(finder.color);
            l.setBorder(BorderFactory.createLineBorder(Color.black));
            labelPanel.add(l);
        }
        mainFrame.setVisible(true);

    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:beproject.MainGUI.java

void createTagCloud() throws SQLException {
    TreeMap tmp = getFrequentWords();
    Cloud cld = new Cloud();
    JPanel tmpPanel = new JPanel();
    FlowLayout t1 = new FlowLayout();
    tmpPanel.setPreferredSize(new Dimension(512, 512));
    tmpPanel.setLayout(t1);/*from   ww w . j  a v a 2 s . com*/
    tmpPanel.setBounds(0, 0, 512, 512);
    //FlowLayout lm=(FlowLayout) tmpPanel.getLayout();
    for (int i = 0; i < 40 && !tmp.isEmpty(); i++) {
        Map.Entry mp = tmp.pollFirstEntry();
        Tag t = new Tag((String) mp.getKey(), (int) (mp.getValue()));
        cld.addTag(t);
    }
    Random rand = new Random();
    for (Tag tag : cld.tags()) {
        final JLabel label = new JLabel(tag.getName());
        label.setOpaque(false);
        label.setFont(label.getFont().deriveFont(rand.nextFloat() * 39));
        label.setForeground(new Color(rand.nextInt()));
        tmpPanel.add(label);
    }
    if (tagCloudPanel == null) {
        tagCloudPanel = new JScrollPane(tmpPanel, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
                JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    } else {
        jPanel3.remove(tagCloudPanel);
        jPanel3.validate();
        tagCloudPanel = new JScrollPane(tmpPanel, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
                JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    }
    //tagCloudPanel.setLayout(new ScrollPaneLayout());
    //tagCloudPanel.setAutoscrolls(true);
    tmpPanel.validate();
    tagCloudPanel.validate();
    jPanel3.add(tagCloudPanel, BorderLayout.CENTER);
    jPanel3.validate();

}

From source file:de.tor.tribes.ui.renderer.ColoredCoutdownCellRenderer.java

@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
        int row, int column) {
    Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
    try {// w  ww . j  a v  a2  s  .co m
        JLabel renderComponent = ((JLabel) c);
        Long d = (Long) value;

        // renderComponent.setText(DurationFormatUtils.formatDuration(d, "HHH:mm:ss.SSS", true));

        long diff = d;
        long five_minutes = 5 * MINUTE;
        long ten_minutes = 10 * MINUTE;
        Color color = null;
        if (row % 2 == 0) {
            color = Constants.DS_ROW_A;
        } else {
            color = Constants.DS_ROW_B;
        }

        if (diff <= 0) {
            //value is expired, stroke result
            //renderComponent.setText(specialFormat.format(d));
            //renderComponent.setForeground(Color.RED);
        } else if (diff <= ten_minutes && diff > five_minutes) {
            float ratio = (float) (diff - five_minutes) / (float) five_minutes;
            Color c1 = Color.YELLOW;
            Color c2 = Color.GREEN;
            int red = (int) (c2.getRed() * ratio + c1.getRed() * (1 - ratio));
            int green = (int) (c2.getGreen() * ratio + c1.getGreen() * (1 - ratio));
            int blue = (int) (c2.getBlue() * ratio + c1.getBlue() * (1 - ratio));
            color = new Color(red, green, blue);
        } else if (diff <= five_minutes) {
            float ratio = (float) diff / (float) five_minutes;
            Color c1 = Color.RED;
            Color c2 = Color.YELLOW;
            int red = (int) (c2.getRed() * ratio + c1.getRed() * (1 - ratio));
            int green = (int) (c2.getGreen() * ratio + c1.getGreen() * (1 - ratio));
            int blue = (int) (c2.getBlue() * ratio + c1.getBlue() * (1 - ratio));
            color = new Color(red, green, blue);
        }
        renderComponent.setText(DurationFormatUtils.formatDuration(d, "HHH:mm:ss.SSS", true));
        if (isSelected) {
            color = c.getBackground();
        }
        renderComponent.setOpaque(true);
        renderComponent.setBackground(color);
        return renderComponent;
    } catch (Exception e) {
        return c;
    }
}