Example usage for javax.swing JLabel setBackground

List of usage examples for javax.swing JLabel setBackground

Introduction

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

Prototype

@BeanProperty(preferred = true, visualUpdate = true, description = "The background color of the component.")
public void setBackground(Color bg) 

Source Link

Document

Sets the background color of this component.

Usage

From source file:edu.ku.brc.specify.dbsupport.cleanuptools.GeoChooserDlg.java

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override//from  w w w. j a  v  a2 s .c  o m
public void createUI() {
    boolean doStatesOrCounties = doAllCountries[1] || doAllCountries[2] || doInvCountry[1] || doInvCountry[2];
    //this.whichBtns = doStatesOrCounties && !doInvCountry[1] && rankId > 200 ? CustomDialog.OKCANCELAPPLYHELP : CustomDialog.OKCANCELHELP;

    boolean isStCnty = true;//rankId > 200; 

    dataListModel = new DefaultListModel<GeoSearchResultsItem>();
    mainList = new JList<GeoSearchResultsItem>(dataListModel);
    JScrollPane sb = createScrollPane(mainList, true);

    String listDim;
    if (UIHelper.isWindows()) {
        listDim = "250px";
        Dimension sz = new Dimension(250, 250);
        mainList.setPreferredSize(sz);
        sb.setPreferredSize(sz);
    } else {
        listDim = "f:p:g";
    }

    CellConstraints cc = new CellConstraints();
    PanelBuilder pb = new PanelBuilder(new FormLayout("f:p:g",
            "p,2px,p,12px,p,2px," + listDim + ",8px,p,4px,p,10px,p" + (isStCnty ? ",8px,p" : "")));

    this.contentPanel = pb.getPanel();

    super.createUI();

    okBtn.setEnabled(false);

    calcProgress();

    try {
        if (coInfoList != null && coInfoList.size() > 0) {
            fillFromLuceneResults();
        } else {
            fillFromQuery();
        }

        mainList.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                if (e.getClickCount() == 2) {
                    getOkBtn().doClick();

                } else if (e.getClickCount() == 1 && !noMatchesFound && !mainList.isSelectionEmpty()) {
                    getOkBtn().setEnabled(true);
                }
            }
        });
        mainList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
            @Override
            public void valueChanged(ListSelectionEvent e) {
                if (!e.getValueIsAdjusting()) {
                    listItemSelected();
                }
            }
        });

        updateNameCB = createCheckBox("Update the Name in the Geography tree."); // I18N
        //mergeCB      = createCheckBox("Merge all the geographies with the same name.");
        addISOCodeCB = createCheckBox("Add the ISO Code to the record");
        isoCodeTF = createTextField(8);
        isoCodeTF.setVisible(rankId < 400);

        updateNameCB.setSelected(isUpdateNamesChecked);
        //mergeCB.setSelected(true);
        addISOCodeCB.setSelected(true);

        updateNameCB.addChangeListener(new ChangeListener() {
            @Override
            public void stateChanged(final ChangeEvent e) {
                isUpdateNamesChecked = updateNameCB.isSelected();
            }
        });

        DocumentListener dl = new DocumentAdaptor() {
            @Override
            protected void changed(DocumentEvent e) {
                okBtn.setEnabled(!isoCodeTF.getText().isEmpty());
            }
        };
        isoCodeTF.getDocument().addDocumentListener(dl);
        //labels.add(nameStr);// + "  (Unknown)");

        PanelBuilder lookPB = null;
        JButton lookupBtn = null;
        if (isStCnty) {
            lookPB = new PanelBuilder(new FormLayout("f:p:g,p", "p"));
            lookupBtn = createI18NButton("CLNUP_GEO_LOOK_UP_ISO");
            lookPB.add(lookupBtn, cc.xy(2, 1));
            lookupBtn.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    globalRankSearch();
                }
            });
        }

        int i = 0;
        ArrayList<String> labels = new ArrayList<String>();
        while (i < parentNames.length && parentRanks[i] > -1) {
            labels.add(i18NLabelsMap.get(parentRanks[i++]));
        }

        PanelBuilder pbTop = new PanelBuilder(
                new FormLayout("p,2px,f:p:g", UIHelper.createDuplicateJGoodiesDef("p", "2px", labels.size())));
        int y = 1;
        for (i = 0; i < labels.size(); i++) {
            JLabel lbl = createLabel(parentNames[i]);
            pbTop.add(createFormLabel(labels.get(i)), cc.xy(1, y));
            pbTop.add(lbl, cc.xy(3, y));
            lbl.setBackground(Color.WHITE);
            lbl.setOpaque(true);
            y += 2;
        }

        pb.add(pbTop.getPanel(), cc.xy(1, 3));
        pb.addSeparator("Possible standard Geography choices", cc.xy(1, 5)); // I18N
        pb.add(sb, cc.xy(1, 7));
        pb.add(updateNameCB, cc.xy(1, 9));

        PanelBuilder pbc = new PanelBuilder(new FormLayout("p,10px,p,f:p:g", "p"));
        pbc.add(addISOCodeCB, cc.xy(1, 1));
        pbc.add(isoCodeTF, cc.xy(3, 1));

        pb.add(pbc.getPanel(), cc.xy(1, 11));

        i = 13;
        if (isStCnty) {
            pb.add(lookPB.getPanel(), cc.xy(1, i));
            i += 2;
        }

        //if (doAllCountries[0])
        if (false) // hidding it for now
        {
            progressBar = new JProgressBar(0, 100);
            progressBar.setStringPainted(true);
            PanelBuilder prgPB = new PanelBuilder(new FormLayout("p,2px,f:p:g", "p"));
            prgPB.add(createFormLabel("Progress"), cc.xy(1, 1));
            prgPB.add(progressBar, cc.xy(3, 1));
            pb.add(prgPB.getPanel(), cc.xy(1, i));
            i += 2;
        }

        mainList.setSelectedIndex(selectedIndex);
        mainList.ensureIndexIsVisible(selectedIndex);

        noMatchesFound = dataListModel.size() == 0;

        // Optional Depending on States / Countries
        if (doStatesOrCounties) {
            if (dataListModel.getSize() == 0) {
                dataListModel.addElement(new GeoSearchResultsItem("No matches found."));// I18N
            }
        }

        pb.setDefaultDialogBorder();

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

    if (UIHelper.isWindows()) {
        setResizable(false);
    }
    setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); // Must be called at the end 'createUI'
}

From source file:coolmap.application.widget.impl.WidgetUserGroup.java

private void init() {

    table.getTableHeader().setReorderingAllowed(false);
    table.setAutoCreateRowSorter(true);/*  w ww . ja  va2s .c  om*/
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

    table.setDefaultRenderer(Object.class, new DefaultTableCellRenderer() {

        @Override
        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
                boolean hasFocus, int row, int column) {
            JLabel label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row,
                    column);
            if (isSelected) {
                return label;
            }

            if (column == 1) {
                try {
                    label.setBackground(
                            nodeColor.get(table.getModel().getValueAt(table.convertRowIndexToModel(row), 0)));
                } catch (Exception e) {

                }
            } else {
                label.setBackground(UI.colorWhite);
            }

            return label;
        }

    });
    //Need a search box as well.

    //
    getContentPane().setLayout(new BorderLayout());

    //
    getContentPane().add(new JScrollPane(table), BorderLayout.CENTER);
    JToolBar t = new JToolBar();
    getContentPane().add(t, BorderLayout.NORTH);
    t.setFloatable(false);

    try {
        //also add an action to add group nodes
        JMenuItem item = new JMenuItem("selected row nodes");
        item.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {

                CoolMapObject o = CoolMapMaster.getActiveCoolMapObject();
                if (o == null) {
                    return;
                }

                ArrayList<Range<Integer>> selected = o.getCoolMapView().getSelectedRows();
                ArrayList<VNode> selectedNodes = new ArrayList<>();

                for (Range<Integer> r : selected) {
                    for (int i = r.lowerEndpoint(); i < r.upperEndpoint(); i++) {
                        selectedNodes.add(o.getViewNodeRow(i));
                    }
                }

                createNewGroup(selectedNodes);

                //create a group
            }
        });
        WidgetMaster.getViewport().addPopupMenuItem("Create group", item, false);

        item = new JMenuItem("selected column nodes");
        item.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {

                CoolMapObject o = CoolMapMaster.getActiveCoolMapObject();
                if (o == null) {
                    return;
                }

                ArrayList<Range<Integer>> selected = o.getCoolMapView().getSelectedColumns();
                ArrayList<VNode> selectedNodes = new ArrayList<>();

                for (Range<Integer> r : selected) {
                    for (int i = r.lowerEndpoint(); i < r.upperEndpoint(); i++) {
                        selectedNodes.add(o.getViewNodeColumn(i));
                    }
                }

                createNewGroup(selectedNodes);

            }
        });
        WidgetMaster.getViewport().addPopupMenuItem("Create group", item, false);
    } catch (Exception e) {
        //
        //Error handling.
    }

}

From source file:com.diversityarrays.kdxplore.design.EntryFileImportDialog.java

public EntryFileImportDialog(Window owner, String title, File inputFile, Predicate<Role> entryHeadingFilter) {
    super(owner, title, ModalityType.APPLICATION_MODAL);

    this.entryHeadingFilter = entryHeadingFilter;
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);

    setGlassPane(backgroundRunner.getBlockingPane());

    useScrollBarOption.addActionListener(new ActionListener() {
        @Override/*from   w w  w  . j av a  2  s  . co m*/
        public void actionPerformed(ActionEvent e) {
            updateDataPreviewScrolling();
        }
    });

    headingRoleTableModel = createHeadingRoleTableModel();
    headingRoleTable = new HeadingRoleTable<>(headingRoleTableModel);
    headingTableScrollPane = new JScrollPane(headingRoleTable);
    GuiUtil.setVisibleRowCount(headingRoleTable, 10);

    JPanel roleAssignmentPanel = new JPanel(new BorderLayout());
    roleAssignmentPanel.add(headingTableScrollPane, BorderLayout.CENTER);

    headingRoleTable.setTransferHandler(flth);
    headingRoleTableModel.addChangeListener(headingRoleChangeListener);

    GuiUtil.setVisibleRowCount(dataPreviewTable, 10);
    dataPreviewTable.setTransferHandler(flth);
    dataPreviewScrollPane.setTransferHandler(flth);
    updateDataPreviewScrolling();

    dataPreviewScrollPane.addComponentListener(new ComponentAdapter() {
        @Override
        public void componentResized(ComponentEvent e) {
            //                boolean useScrollBar = useScrollBarOption.isSelected();
            GuiUtil.initialiseTableColumnWidths(dataPreviewTable, true);
        }
    });

    Box top = Box.createHorizontalBox();
    top.add(new JLabel("# rows to preview: "));
    top.add(new JSpinner(previewRowCountSpinnerModel));
    top.add(Box.createHorizontalGlue());
    top.add(useScrollBarOption);

    JPanel dataPreviewPanel = new JPanel(new BorderLayout());
    dataPreviewPanel.add(GuiUtil.createLabelSeparator("Data Preview", top), BorderLayout.NORTH);
    dataPreviewPanel.add(dataPreviewScrollPane, BorderLayout.CENTER);

    headingWarning.setForeground(Color.RED);
    JLabel instructions = new JLabel("<HTML>Please assign a <i>Role</i> for each of the headings in your data"
            + "<br>You must specify one as the <i>Entry Name</i>."
            + "<br>Click on one of the <i>Role</i> cells and select from the dropdown"
            + "<br>To assign multiple headings, select the rows for which you wish"
            + "<br>to set the <i>Role</i> then right-click and choose from the dropdown.");
    instructions.setHorizontalAlignment(JLabel.CENTER);
    instructions.setBackground(Toast.PALE_YELLOW);

    JScrollPane instScroll = new JScrollPane(instructions);
    instScroll.setBackground(Toast.PALE_YELLOW);

    normalEntryNameField.getDocument()
            .addDocumentListener(new DocumentChangeListener((e) -> updateAcceptButton()));
    normalEntryNameField.setText(TrialDesignPreferences.getInstance().getNormalEntryTypeName());

    JPanel rolesPanel = new JPanel();
    GBH gbh = new GBH(rolesPanel, 2, 2, 0, 0);
    int y = 0;
    gbh.add(0, y, 1, 1, GBH.NONE, 0, 1, GBH.EAST, "Entry Type Name for non-Checks:");
    gbh.add(1, y, 1, 1, GBH.NONE, 1, 1, GBH.WEST, normalEntryNameField);
    gbh.add(2, y, 1, 1, GBH.NONE, 1, 1, GBH.WEST, saveForFuture);
    ++y;

    gbh.add(0, y, 3, 1, GBH.BOTH, 2, 1, GBH.CENTER, roleAssignmentPanel);
    ++y;

    JSplitPane headingsAndInstructions = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, rolesPanel, instScroll);

    JPanel headingPanel = new JPanel(new BorderLayout());
    headingPanel.add(GuiUtil.createLabelSeparator("Assign Roles for Headings"), BorderLayout.NORTH);
    headingPanel.add(headingsAndInstructions, BorderLayout.CENTER);
    headingPanel.add(headingWarning, BorderLayout.SOUTH);

    errorMessage.setEditable(false);

    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, dataPreviewPanel, headingPanel);
    splitPane.setResizeWeight(0.5);

    cardPanel.add(new JScrollPane(errorMessage), CARD_ERROR);
    cardPanel.add(splitPane, CARD_DATA);

    Box bot = Box.createHorizontalBox();
    bot.add(Box.createHorizontalGlue());
    bot.add(new JButton(cancelAction));
    bot.add(new JButton(acceptAction));
    acceptAction.setEnabled(false);

    Container cp = getContentPane();
    cp.add(cardPanel, BorderLayout.CENTER);
    cp.add(bot, BorderLayout.SOUTH);
    pack();

    sheetNamesComboBox.addActionListener(sheetNamesActionListener);

    Timer timer = new Timer(true);

    previewRowCountSpinnerModel.addChangeListener(new ChangeListener() {
        int nPreview;
        TimerTask timerTask = null;

        @Override
        public void stateChanged(ChangeEvent e) {
            nPreview = previewRowCountSpinnerModel.getNumber().intValue();

            if (timerTask == null) {
                timerTask = new TimerTask() {
                    int lastPreviewCount = nPreview;

                    @Override
                    public void run() {
                        if (lastPreviewCount == nPreview) {
                            System.err.println("Stable at " + lastPreviewCount);
                            // No change, do it now
                            cancel();
                            try {
                                updateDataPreview(lastPreviewCount);
                            } finally {
                                timerTask = null;
                            }
                        } else {
                            System.err.println("Changing from " + lastPreviewCount + " to " + nPreview);
                            lastPreviewCount = nPreview;
                        }
                    }
                };
                timer.scheduleAtFixedRate(timerTask, 500, 100);
            }
        }
    });

    sheetNamesComboBox.setVisible(false);

    addWindowListener(new WindowAdapter() {
        @Override
        public void windowOpened(WindowEvent e) {
            removeWindowListener(this);
            setFile(inputFile);
        }
    });
}

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>
 *///ww w  . j a  v  a 2s.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: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 .ja va 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: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 va 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:org.forester.archaeopteryx.ControlPanel.java

static JLabel customizeLabel(final JLabel label, final Configuration configuration) {
    label.setFont(ControlPanel.jcb_bold_font);
    if (!configuration.isUseNativeUI()) {
        label.setForeground(ControlPanel.jcb_text_color);
        label.setBackground(ControlPanel.background_color);
    }/* w w  w.j  a v a  2 s  .  c  o  m*/
    return label;
}

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);/* w  w w  . j a v  a 2s. c  o  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:org.pentaho.support.standalone.SDSupportUtility.java

/**
 * initializing UI/*from  w ww .  j  a  v  a 2s.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:de.quadrillenschule.azocamsyncd.gui.ExploreWifiSDPanel.java

/**
 * Creates new form ExploreWifiSDPanel/*from  www. jav a2s.  com*/
 */
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;
        }
    });
}