Example usage for javax.swing JPanel setOpaque

List of usage examples for javax.swing JPanel setOpaque

Introduction

In this page you can find the example usage for javax.swing JPanel 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:edu.ku.brc.af.ui.db.DatabaseLoginPanel.java

/**
 * Creates the UI for the login and hooks up any listeners.
 * @param isDlg  whether the parent is a dialog (false mean JFrame)
 * @param iconName the icon that will be shown in the panel
 * @param engageUPPrefs whether it should load and save the username password into the prefs
 * @param helpContext the help context to use.
 *///from   ww w.  jav  a 2 s.c om
protected void createUI(final boolean isDlg, final String iconName, final String helpContext) {
    final boolean isNotEmbedded = !DBConnection.getInstance().isEmbedded() && !UIRegistry.isMobile();
    final AppPreferences localPrefs = AppPreferences.getLocalPrefs();

    //Font cachedFont = UIManager.getFont("JLabel.font");
    SkinItem skinItem = SkinsMgr.getSkinItem("LoginPanel");
    if (skinItem != null) {
        skinItem.pushFG("Label.foreground");
    }

    if (isNotEmbedded) {
        SpinnerModel portModel = new SpinnerNumberModel(3306, //initial value
                0, //min
                Integer.MAX_VALUE, //max
                1); //step
        portSpinner = new JSpinner(portModel);
        JSpinner.NumberEditor editor = new JSpinner.NumberEditor(portSpinner, "#");
        portSpinner.setEditor(editor);

        portSpinner.addChangeListener(new ChangeListener() {
            @Override
            public void stateChanged(ChangeEvent e) {
                DatabaseDriverInfo drvInfo = dbDrivers.get(dbDriverCBX.getSelectedIndex());
                if (drvInfo != null && isNotEmbedded && portSpinner != null) {
                    drvInfo.setPort((Integer) portSpinner.getValue());
                }
            }
        });
        setControlSize(portSpinner);
    }

    // First create the controls and hook up listeners
    dbPickList = new PropertiesPickListAdapter("login.databases"); //$NON-NLS-1$
    svPickList = new PropertiesPickListAdapter("login.servers"); //$NON-NLS-1$

    username = createTextField(15);
    password = createPasswordField(15);

    FocusAdapter focusAdp = new FocusAdapter() {
        @Override
        public void focusGained(FocusEvent e) {
            super.focusGained(e);

            JTextField tf = (JTextField) e.getSource();
            tf.selectAll();
        }
    };
    username.addFocusListener(focusAdp);
    password.addFocusListener(focusAdp);

    databases = new ValComboBox(dbPickList);
    if (databases.getComboBox() instanceof Java2sAutoComboBox) {
        ((Java2sAutoComboBox) databases.getComboBox()).setCaseSensitive(true);
    }
    servers = new ValComboBox(svPickList);

    dbPickList.setComboBox(databases);
    svPickList.setComboBox(servers);

    setControlSize(password);
    setControlSize(databases);
    setControlSize(servers);

    if (masterUsrPwdProvider != null) {
        editKeyInfoBtn = UIHelper.createI18NButton("CONFIG_MSTR_KEY");
        editKeyInfoBtn.setIcon(IconManager.getIcon("Key", IconManager.IconSize.Std20));
        editKeyInfoBtn.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                if (masterUsrPwdProvider != null && databases != null) {
                    String itemName = null;
                    if (databases.getComboBox().getSelectedItem() instanceof String) {
                        itemName = (String) databases.getComboBox().getSelectedItem();
                    } else {
                        PickListItemIFace pli = (PickListItemIFace) databases.getComboBox().getSelectedItem();
                        if (pli != null && pli.getValue() != null) {
                            itemName = pli.getValue();
                        }
                    }

                    if (itemName != null) {
                        masterUsrPwdProvider.editMasterInfo(username.getText(), itemName, false);
                    }
                }
            }
        });
    }

    rememberUsernameCBX = createCheckBox(getResourceString("rememberuser")); //$NON-NLS-1$
    rememberUsernameCBX.setEnabled(engageUPPrefs);

    statusBar = new JStatusBar();
    statusBar.setErrorIcon(IconManager.getIcon("Error", IconManager.IconSize.Std16)); //$NON-NLS-1$

    cancelBtn = createButton(getResourceString("CANCEL")); //$NON-NLS-1$
    loginBtn = createButton(getResourceString("Login")); //$NON-NLS-1$
    helpBtn = createButton(getResourceString("HELP")); //$NON-NLS-1$

    forwardImgIcon = IconManager.getIcon("Forward"); //$NON-NLS-1$
    downImgIcon = IconManager.getIcon("Down"); //$NON-NLS-1$
    moreBtn = new JCheckBox(getResourceString("LOGIN_DLG_MORE"), forwardImgIcon); // XXX I18N //$NON-NLS-1$
    setControlSize(moreBtn);

    // Extra
    dbDrivers = DatabaseDriverInfo.getDriversList();
    dbDriverCBX = createComboBox(dbDrivers);

    dbDriverCBX.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            updateUIControls();

            DatabaseDriverInfo drvInfo = dbDrivers.get(dbDriverCBX.getSelectedIndex());
            if (drvInfo != null && isNotEmbedded && portSpinner != null) {
                Integer defPort = drvInfo.getPortAsInt();
                int portFromPref = localPrefs.getInt(LOGIN_PORT, defPort);

                portSpinner.setValue(portFromPref);
                drvInfo.setPort(portFromPref);
            }
        }
    });

    if (dbDrivers.size() > 0) {
        if (dbDrivers.size() == 1) {
            dbDriverCBX.setSelectedIndex(0);
            dbDriverCBX.setEnabled(false);

        } else {
            String selectedStr = localPrefs.get("login.dbdriver_selected", "MySQL"); //$NON-NLS-1$ //$NON-NLS-2$
            int inx = Collections.binarySearch(dbDrivers,
                    new DatabaseDriverInfo(selectedStr, null, null, false, null));
            dbDriverCBX.setSelectedIndex(inx > -1 ? inx : -1);
        }

    } else {
        JOptionPane.showConfirmDialog(null, getResourceString("NO_DBDRIVERS"), //$NON-NLS-1$
                getResourceString("NO_DBDRIVERS_TITLE"), JOptionPane.CLOSED_OPTION); //$NON-NLS-1$
        System.exit(1);
    }

    addFocusListenerForTextComp(username);
    addFocusListenerForTextComp(password);

    addKeyListenerFor(username, !isDlg);
    addKeyListenerFor(password, !isDlg);

    addKeyListenerFor(databases.getTextField(), !isDlg);
    addKeyListenerFor(servers.getTextField(), !isDlg);

    if (!isDlg) {
        addKeyListenerFor(loginBtn, true);
    }

    rememberUsernameCBX.setSelected(engageUPPrefs ? localPrefs.getBoolean("login.rememberuser", false) : false); //$NON-NLS-1$

    cancelBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (dbListener != null) {
                dbListener.cancelled();
            }
        }
    });

    loginBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            doLogin();
        }
    });

    HelpMgr.registerComponent(helpBtn, helpContext); //$NON-NLS-1$

    moreBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (extraPanel.isVisible()) {
                if (dbDriverCBX.getSelectedIndex() != -1) {
                    extraPanel.setVisible(false);
                    moreBtn.setIcon(forwardImgIcon);
                }

            } else {
                extraPanel.setVisible(true);
                moreBtn.setIcon(downImgIcon);
            }
            if (window != null) {
                window.pack();
            }
        }
    });

    // Ask the PropertiesPickListAdapter to set the index from the prefs
    dbPickList.setSelectedIndex();
    svPickList.setSelectedIndex();

    servers.getTextField().addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
            updateUIControls();
        }
    });

    databases.getTextField().addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
            updateUIControls();
        }
    });

    databases.getTextField().addFocusListener(new FocusAdapter() {
        String server = null;

        private String getServerStr() {
            String serverStr = null;
            Object serverObj = servers.getValue();
            if (serverObj != null) {
                serverStr = serverObj.toString();
            }
            return serverStr;
        }

        @Override
        public void focusGained(FocusEvent e) {
            server = getServerStr();
        }

        @Override
        public void focusLost(FocusEvent e) {
            if (server != null) {
                String newVal = getServerStr();
                if (newVal != null && !newVal.equals(server)) {
                    setUsrPwdControlsFromPrefs();
                }
            }
        }
    });

    setUsrPwdControlsFromPrefs();

    // Layout the form

    PanelBuilder formBuilder = new PanelBuilder(new FormLayout("p,3dlu,p:g", "p,2dlu,p,2dlu,p,2dlu,p,2dlu,p")); //$NON-NLS-1$ //$NON-NLS-2$
    CellConstraints cc = new CellConstraints();
    formBuilder.addSeparator(getResourceString("LOGINLABEL"), cc.xywh(1, 1, 3, 1)); //$NON-NLS-1$

    addLine("username", username, formBuilder, cc, 3); //$NON-NLS-1$
    addLine("password", password, formBuilder, cc, 5); //$NON-NLS-1$
    formBuilder.add(moreBtn, cc.xy(3, 7));

    PanelBuilder extraPanelBlder = new PanelBuilder(new FormLayout("p,3dlu,p:g", //$NON-NLS-1$ 
            UIHelper.createDuplicateJGoodiesDef("p", "2dlu", isNotEmbedded ? 9 : 11))); //$NON-NLS-1$ //$NON-NLS-2$

    extraPanel = extraPanelBlder.getPanel();
    extraPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 4, 2));

    //extraPanelBlder.addSeparator("", cc.xywh(1, 1, 3, 1)); //$NON-NLS-1$
    int y = 1;
    y = addLine(null, rememberUsernameCBX, extraPanelBlder, cc, y);
    y = addLine("databases", databases, extraPanelBlder, cc, y); //$NON-NLS-1$
    y = addLine("servers", servers, extraPanelBlder, cc, y); //$NON-NLS-1$

    y = addLine("driver", dbDriverCBX, extraPanelBlder, cc, y); //$NON-NLS-1$
    if (isNotEmbedded) {
        y = addLine("port", portSpinner, extraPanelBlder, cc, y); //$NON-NLS-1$
    }
    if (editKeyInfoBtn != null) {
        PanelBuilder pb = new PanelBuilder(new FormLayout("p,f:p:g", "p"));
        pb.add(editKeyInfoBtn, cc.xy(1, 1));
        y = addLine(null, pb.getPanel(), extraPanelBlder, cc, y);
        pb.getPanel().setOpaque(false);
    }
    extraPanel.setVisible(false);

    formBuilder.add(extraPanelBlder.getPanel(), cc.xywh(3, 9, 1, 1));

    PanelBuilder outerPanel = new PanelBuilder(new FormLayout("p,3dlu,p:g", "t:p,2dlu,p,2dlu,p"), this); //$NON-NLS-1$ //$NON-NLS-2$
    JLabel icon = StringUtils.isNotEmpty(iconName) ? new JLabel(IconManager.getIcon(iconName)) : null;

    if (icon != null) {
        icon.setBorder(BorderFactory.createEmptyBorder(10, 10, 2, 2));
    }

    formBuilder.getPanel().setBorder(BorderFactory.createEmptyBorder(10, 5, 0, 5));

    if (icon != null) {
        outerPanel.add(icon, cc.xy(1, 1));
    }
    JPanel btnPanel = ButtonBarFactory.buildOKCancelHelpBar(loginBtn, cancelBtn, helpBtn);
    outerPanel.add(formBuilder.getPanel(), cc.xy(3, 1));
    outerPanel.add(btnPanel, cc.xywh(1, 3, 3, 1));
    outerPanel.add(statusBar, cc.xywh(1, 5, 3, 1));

    formBuilder.getPanel().setOpaque(false);
    outerPanel.getPanel().setOpaque(false);
    btnPanel.setOpaque(false);

    updateUIControls();

    if (skinItem != null) {
        skinItem.popFG("Label.foreground");
    }

    if (AppPreferences.getLocalPrefs().getBoolean(expandExtraPanelName, false)) {
        extraPanel.setVisible(true);
        moreBtn.setIcon(downImgIcon);
    }
}

From source file:lol.search.RankedStatsPage.java

private JPanel headerPanel() {
    //init spacers for header
    for (int i = 0; i < 10; i++) {
        JLabel label = new JLabel("--");
        label.setForeground(new Color(0, 0, 0, 0));
        spacers.add(label);// w w  w.  j  av a  2 s  .co  m
    }
    //header -- to set this semi-transparent i had to remove setOpaque and replace with setBackground(...)
    JPanel headerPanel = new JPanel();
    headerPanel.setLayout(new BorderLayout());
    //headerPanel.setBorder(BorderFactory.createLineBorder(Color.WHITE));
    headerPanel.setBackground(backgroundColor);
    headerPanel.setPreferredSize(headerDimension);
    //back button
    JPanel buttonHolder = new JPanel();
    ImageIcon buttonImage = new ImageIcon("assets\\other\\button.png");
    ImageIcon buttonPressedImage = new ImageIcon("assets\\other\\buttonPressed.png");
    Image tempImage = buttonImage.getImage();
    Image newTempImg = tempImage.getScaledInstance(75, 35, Image.SCALE_SMOOTH);
    buttonImage = new ImageIcon(newTempImg);
    JButton backButton = new JButton("BACK");
    backButton.setFont(new Font("Sen-Regular", Font.CENTER_BASELINE, 10)); //custom font
    backButton.setForeground(Color.WHITE); //text color
    backButton.setBackground(new Color(0, 0, 0, 0));
    backButton.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    backButton.setHorizontalTextPosition(AbstractButton.CENTER);
    backButton.setPreferredSize(new Dimension(75, 35));
    //pressed button
    Image tempImage2 = buttonPressedImage.getImage();
    Image newTempImg2 = tempImage2.getScaledInstance(75, 35, Image.SCALE_SMOOTH);
    buttonPressedImage = new ImageIcon(newTempImg2);
    backButton.setIcon(buttonImage);
    backButton.setRolloverIcon(buttonPressedImage);
    backButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) { //button pressed
            System.out.println("Going back...\n");
            masterFrame.getContentPane().removeAll();
            masterFrame.revalidate();
            masterFrame.repaint();
            MainPage MAIN_PAGE = new MainPage(masterFrame, summonerName);
        }
    });
    buttonHolder.add(backButton);
    buttonHolder.setOpaque(false);
    headerPanel.add(buttonHolder, BorderLayout.LINE_START);
    //centerpanel
    JPanel centerPanel = new JPanel();
    centerPanel.setLayout(new GridLayout(1, 2));
    centerPanel.setOpaque(false);
    //centerPanel.setBorder(BorderFactory.createLineBorder(Color.WHITE));
    //rightcenter
    JPanel rightCenter = new JPanel();
    rightCenter.setOpaque(false);
    rightCenter.setLayout(new GridLayout(2, 1));
    //top center panel
    JPanel topCenter = new JPanel();
    topCenter.setOpaque(false);
    topCenter.setLayout(new BoxLayout(topCenter, BoxLayout.X_AXIS));
    //profile icon
    JPanel proIconPanel = new JPanel();
    proIconPanel.setOpaque(false);
    proIconPanel.setLayout(new BoxLayout(proIconPanel, BoxLayout.Y_AXIS));
    JLabel profileIconLabel = new JLabel(this.profileIcon);
    //profileIconLabel.setBorder(BorderFactory.createLineBorder(Color.WHITE));
    profileIconLabel.setAlignmentX(Component.RIGHT_ALIGNMENT);
    proIconPanel.add(profileIconLabel);
    centerPanel.add(proIconPanel);
    //empty spacer
    topCenter.add(spacers.get(0));
    //summoner name
    JLabel summonerNameLabel = new JLabel(this.summonerName);
    summonerNameLabel.setFont(new Font("Sen-Regular", Font.CENTER_BASELINE, 15)); //custom font
    summonerNameLabel.setForeground(Color.WHITE); //text color
    summonerNameLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
    topCenter.add(summonerNameLabel);
    //empty spacer
    topCenter.add(spacers.get(1));
    //tier
    JLabel tierLabel = new JLabel(this.tier);
    tierLabel.setFont(new Font("Sen-Regular", Font.CENTER_BASELINE, 13)); //custom font
    tierLabel.setForeground(new Color(219, 219, 219)); //text color
    tierLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
    topCenter.add(tierLabel);
    //empty spacer
    topCenter.add(spacers.get(2));
    //division
    JLabel divisionLabel = new JLabel(this.division);
    divisionLabel.setFont(new Font("Sen-Regular", Font.CENTER_BASELINE, 13)); //custom font
    divisionLabel.setForeground(new Color(219, 219, 219)); //text color
    divisionLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
    topCenter.add(divisionLabel);
    //bottom center panel
    JPanel bottomCenter = new JPanel();
    bottomCenter.setOpaque(false);
    bottomCenter.setLayout(new BoxLayout(bottomCenter, BoxLayout.X_AXIS));
    //empty spacer
    bottomCenter.add(spacers.get(3));
    //season
    JLabel winsLabel = new JLabel(this.season);
    winsLabel.setFont(new Font("Sen-Regular", Font.CENTER_BASELINE, 14)); //custom font
    winsLabel.setForeground(new Color(219, 219, 219)); //text color
    winsLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
    bottomCenter.add(winsLabel);

    rightCenter.add(topCenter);
    rightCenter.add(bottomCenter);
    centerPanel.add(rightCenter);
    headerPanel.add(centerPanel, BorderLayout.CENTER);
    //empty panel to balance right side
    JPanel ee = new JPanel();
    ee.setOpaque(false);
    ee.setPreferredSize(new Dimension(260, 50));
    headerPanel.add(ee, BorderLayout.LINE_END);
    return headerPanel;
}

From source file:com.google.code.facebook.graph.sna.applet.PluggableRendererDemo.java

/**
 * @param jp    panel to which controls will be added
 *///  w w w .j  a  va  2 s.  c  om
@SuppressWarnings("serial")
protected void addBottomControls(final JPanel jp) {
    final JPanel control_panel = new JPanel();
    jp.add(control_panel, BorderLayout.EAST);
    control_panel.setLayout(new BorderLayout());
    final Box vertex_panel = Box.createVerticalBox();
    vertex_panel.setBorder(BorderFactory.createTitledBorder("Vertices"));
    final Box edge_panel = Box.createVerticalBox();
    edge_panel.setBorder(BorderFactory.createTitledBorder("Edges"));
    final Box both_panel = Box.createVerticalBox();

    control_panel.add(vertex_panel, BorderLayout.NORTH);
    control_panel.add(edge_panel, BorderLayout.SOUTH);
    control_panel.add(both_panel, BorderLayout.CENTER);

    // set up vertex controls
    v_color = new JCheckBox("seed highlight");
    v_color.addActionListener(this);
    v_stroke = new JCheckBox("stroke highlight on selection");
    v_stroke.addActionListener(this);
    v_labels = new JCheckBox("show voltage values");
    v_labels.addActionListener(this);
    v_shape = new JCheckBox("shape by degree");
    v_shape.addActionListener(this);
    v_size = new JCheckBox("size by voltage");
    v_size.addActionListener(this);
    v_size.setSelected(true);
    v_aspect = new JCheckBox("stretch by degree ratio");
    v_aspect.addActionListener(this);
    v_small = new JCheckBox("filter when degree < " + VertexDisplayPredicate.MIN_DEGREE);
    v_small.addActionListener(this);

    vertex_panel.add(v_color);
    vertex_panel.add(v_stroke);
    vertex_panel.add(v_labels);
    vertex_panel.add(v_shape);
    vertex_panel.add(v_size);
    vertex_panel.add(v_aspect);
    vertex_panel.add(v_small);

    // set up edge controls
    JPanel gradient_panel = new JPanel(new GridLayout(1, 0));
    gradient_panel.setBorder(BorderFactory.createTitledBorder("Edge paint"));
    no_gradient = new JRadioButton("Solid color");
    no_gradient.addActionListener(this);
    no_gradient.setSelected(true);
    //      gradient_absolute = new JRadioButton("Absolute gradient");
    //      gradient_absolute.addActionListener(this);
    gradient_relative = new JRadioButton("Gradient");
    gradient_relative.addActionListener(this);
    ButtonGroup bg_grad = new ButtonGroup();
    bg_grad.add(no_gradient);
    bg_grad.add(gradient_relative);
    //bg_grad.add(gradient_absolute);
    gradient_panel.add(no_gradient);
    //gradientGrid.add(gradient_absolute);
    gradient_panel.add(gradient_relative);

    JPanel shape_panel = new JPanel(new GridLayout(3, 2));
    shape_panel.setBorder(BorderFactory.createTitledBorder("Edge shape"));
    e_line = new JRadioButton("line");
    e_line.addActionListener(this);
    e_line.setSelected(true);
    //        e_bent = new JRadioButton("bent line");
    //        e_bent.addActionListener(this);
    e_wedge = new JRadioButton("wedge");
    e_wedge.addActionListener(this);
    e_quad = new JRadioButton("quad curve");
    e_quad.addActionListener(this);
    e_cubic = new JRadioButton("cubic curve");
    e_cubic.addActionListener(this);
    e_ortho = new JRadioButton("orthogonal");
    e_ortho.addActionListener(this);
    ButtonGroup bg_shape = new ButtonGroup();
    bg_shape.add(e_line);
    //        bg.add(e_bent);
    bg_shape.add(e_wedge);
    bg_shape.add(e_quad);
    bg_shape.add(e_ortho);
    bg_shape.add(e_cubic);
    shape_panel.add(e_line);
    //        shape_panel.add(e_bent);
    shape_panel.add(e_wedge);
    shape_panel.add(e_quad);
    shape_panel.add(e_cubic);
    shape_panel.add(e_ortho);
    fill_edges = new JCheckBox("fill edge shapes");
    fill_edges.setSelected(false);
    fill_edges.addActionListener(this);
    shape_panel.add(fill_edges);
    shape_panel.setOpaque(true);
    e_color = new JCheckBox("highlight edge weights");
    e_color.addActionListener(this);
    e_labels = new JCheckBox("show edge weight values");
    e_labels.addActionListener(this);
    e_uarrow_pred = new JCheckBox("undirected");
    e_uarrow_pred.addActionListener(this);
    e_darrow_pred = new JCheckBox("directed");
    e_darrow_pred.addActionListener(this);
    e_darrow_pred.setSelected(true);
    e_arrow_centered = new JCheckBox("centered");
    e_arrow_centered.addActionListener(this);
    JPanel arrow_panel = new JPanel(new GridLayout(1, 0));
    arrow_panel.setBorder(BorderFactory.createTitledBorder("Show arrows"));
    arrow_panel.add(e_uarrow_pred);
    arrow_panel.add(e_darrow_pred);
    arrow_panel.add(e_arrow_centered);

    e_show_d = new JCheckBox("directed");
    e_show_d.addActionListener(this);
    e_show_d.setSelected(true);
    e_show_u = new JCheckBox("undirected");
    e_show_u.addActionListener(this);
    e_show_u.setSelected(true);
    JPanel show_edge_panel = new JPanel(new GridLayout(1, 0));
    show_edge_panel.setBorder(BorderFactory.createTitledBorder("Show edges"));
    show_edge_panel.add(e_show_u);
    show_edge_panel.add(e_show_d);

    shape_panel.setAlignmentX(Component.LEFT_ALIGNMENT);
    edge_panel.add(shape_panel);
    gradient_panel.setAlignmentX(Component.LEFT_ALIGNMENT);
    edge_panel.add(gradient_panel);
    show_edge_panel.setAlignmentX(Component.LEFT_ALIGNMENT);
    edge_panel.add(show_edge_panel);
    arrow_panel.setAlignmentX(Component.LEFT_ALIGNMENT);
    edge_panel.add(arrow_panel);

    e_color.setAlignmentX(Component.LEFT_ALIGNMENT);
    edge_panel.add(e_color);
    e_labels.setAlignmentX(Component.LEFT_ALIGNMENT);
    edge_panel.add(e_labels);

    // set up zoom controls
    zoom_at_mouse = new JCheckBox("<html><center>zoom at mouse<p>(wheel only)</center></html>");
    zoom_at_mouse.addActionListener(this);
    zoom_at_mouse.setSelected(true);

    final ScalingControl scaler = new CrossoverScalingControl();

    JButton plus = new JButton("+");
    plus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1.1f, vv.getCenter());
        }
    });
    JButton minus = new JButton("-");
    minus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1 / 1.1f, vv.getCenter());
        }
    });

    JPanel zoomPanel = new JPanel();
    zoomPanel.setBorder(BorderFactory.createTitledBorder("Zoom"));
    plus.setAlignmentX(Component.CENTER_ALIGNMENT);
    zoomPanel.add(plus);
    minus.setAlignmentX(Component.CENTER_ALIGNMENT);
    zoomPanel.add(minus);
    zoom_at_mouse.setAlignmentX(Component.CENTER_ALIGNMENT);
    zoomPanel.add(zoom_at_mouse);

    JPanel fontPanel = new JPanel();
    // add font and zoom controls to center panel
    font = new JCheckBox("bold text");
    font.addActionListener(this);
    font.setAlignmentX(Component.CENTER_ALIGNMENT);
    fontPanel.add(font);

    both_panel.add(zoomPanel);
    both_panel.add(fontPanel);

    JComboBox modeBox = gm.getModeComboBox();
    modeBox.setAlignmentX(Component.CENTER_ALIGNMENT);
    JPanel modePanel = new JPanel(new BorderLayout()) {
        public Dimension getMaximumSize() {
            return getPreferredSize();
        }
    };
    modePanel.setBorder(BorderFactory.createTitledBorder("Mouse Mode"));
    modePanel.add(modeBox);
    JPanel comboGrid = new JPanel(new GridLayout(0, 1));
    comboGrid.add(modePanel);
    fontPanel.add(comboGrid);

    JComboBox cb = new JComboBox();
    cb.addItem(Renderer.VertexLabel.Position.N);
    cb.addItem(Renderer.VertexLabel.Position.NE);
    cb.addItem(Renderer.VertexLabel.Position.E);
    cb.addItem(Renderer.VertexLabel.Position.SE);
    cb.addItem(Renderer.VertexLabel.Position.S);
    cb.addItem(Renderer.VertexLabel.Position.SW);
    cb.addItem(Renderer.VertexLabel.Position.W);
    cb.addItem(Renderer.VertexLabel.Position.NW);
    cb.addItem(Renderer.VertexLabel.Position.N);
    cb.addItem(Renderer.VertexLabel.Position.CNTR);
    cb.addItem(Renderer.VertexLabel.Position.AUTO);
    cb.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            Renderer.VertexLabel.Position position = (Renderer.VertexLabel.Position) e.getItem();
            vv.getRenderer().getVertexLabelRenderer().setPosition(position);
            vv.repaint();
        }
    });
    cb.setSelectedItem(Renderer.VertexLabel.Position.SE);
    JPanel positionPanel = new JPanel();
    positionPanel.setBorder(BorderFactory.createTitledBorder("Label Position"));
    positionPanel.add(cb);

    comboGrid.add(positionPanel);

}

From source file:edu.uci.ics.jung.samples.PluggableRendererDemo.java

/**
 * @param jp    panel to which controls will be added
 *///from w w  w.j a  va 2 s . c om
@SuppressWarnings({ "rawtypes", "unchecked" })
protected void addBottomControls(final JPanel jp) {
    final JPanel control_panel = new JPanel();
    jp.add(control_panel, BorderLayout.EAST);
    control_panel.setLayout(new BorderLayout());
    final Box vertex_panel = Box.createVerticalBox();
    vertex_panel.setBorder(BorderFactory.createTitledBorder("Vertices"));
    final Box edge_panel = Box.createVerticalBox();
    edge_panel.setBorder(BorderFactory.createTitledBorder("Edges"));
    final Box both_panel = Box.createVerticalBox();

    control_panel.add(vertex_panel, BorderLayout.NORTH);
    control_panel.add(edge_panel, BorderLayout.SOUTH);
    control_panel.add(both_panel, BorderLayout.CENTER);

    // set up vertex controls
    v_color = new JCheckBox("seed highlight");
    v_color.addActionListener(this);
    v_stroke = new JCheckBox("stroke highlight on selection");
    v_stroke.addActionListener(this);
    v_labels = new JCheckBox("show voltage values");
    v_labels.addActionListener(this);
    v_shape = new JCheckBox("shape by degree");
    v_shape.addActionListener(this);
    v_size = new JCheckBox("size by voltage");
    v_size.addActionListener(this);
    v_size.setSelected(true);
    v_aspect = new JCheckBox("stretch by degree ratio");
    v_aspect.addActionListener(this);
    v_small = new JCheckBox("filter when degree < " + VertexDisplayPredicate.MIN_DEGREE);
    v_small.addActionListener(this);

    vertex_panel.add(v_color);
    vertex_panel.add(v_stroke);
    vertex_panel.add(v_labels);
    vertex_panel.add(v_shape);
    vertex_panel.add(v_size);
    vertex_panel.add(v_aspect);
    vertex_panel.add(v_small);

    // set up edge controls
    JPanel gradient_panel = new JPanel(new GridLayout(1, 0));
    gradient_panel.setBorder(BorderFactory.createTitledBorder("Edge paint"));
    no_gradient = new JRadioButton("Solid color");
    no_gradient.addActionListener(this);
    no_gradient.setSelected(true);
    //      gradient_absolute = new JRadioButton("Absolute gradient");
    //      gradient_absolute.addActionListener(this);
    gradient_relative = new JRadioButton("Gradient");
    gradient_relative.addActionListener(this);
    ButtonGroup bg_grad = new ButtonGroup();
    bg_grad.add(no_gradient);
    bg_grad.add(gradient_relative);
    //bg_grad.add(gradient_absolute);
    gradient_panel.add(no_gradient);
    //gradientGrid.add(gradient_absolute);
    gradient_panel.add(gradient_relative);

    JPanel shape_panel = new JPanel(new GridLayout(3, 2));
    shape_panel.setBorder(BorderFactory.createTitledBorder("Edge shape"));
    e_line = new JRadioButton("line");
    e_line.addActionListener(this);
    e_line.setSelected(true);
    //        e_bent = new JRadioButton("bent line");
    //        e_bent.addActionListener(this);
    e_wedge = new JRadioButton("wedge");
    e_wedge.addActionListener(this);
    e_quad = new JRadioButton("quad curve");
    e_quad.addActionListener(this);
    e_cubic = new JRadioButton("cubic curve");
    e_cubic.addActionListener(this);
    e_ortho = new JRadioButton("orthogonal");
    e_ortho.addActionListener(this);
    ButtonGroup bg_shape = new ButtonGroup();
    bg_shape.add(e_line);
    //        bg.add(e_bent);
    bg_shape.add(e_wedge);
    bg_shape.add(e_quad);
    bg_shape.add(e_ortho);
    bg_shape.add(e_cubic);
    shape_panel.add(e_line);
    //        shape_panel.add(e_bent);
    shape_panel.add(e_wedge);
    shape_panel.add(e_quad);
    shape_panel.add(e_cubic);
    shape_panel.add(e_ortho);
    fill_edges = new JCheckBox("fill edge shapes");
    fill_edges.setSelected(false);
    fill_edges.addActionListener(this);
    shape_panel.add(fill_edges);
    shape_panel.setOpaque(true);
    e_color = new JCheckBox("highlight edge weights");
    e_color.addActionListener(this);
    e_labels = new JCheckBox("show edge weight values");
    e_labels.addActionListener(this);
    e_uarrow_pred = new JCheckBox("undirected");
    e_uarrow_pred.addActionListener(this);
    e_darrow_pred = new JCheckBox("directed");
    e_darrow_pred.addActionListener(this);
    e_darrow_pred.setSelected(true);
    e_arrow_centered = new JCheckBox("centered");
    e_arrow_centered.addActionListener(this);
    JPanel arrow_panel = new JPanel(new GridLayout(1, 0));
    arrow_panel.setBorder(BorderFactory.createTitledBorder("Show arrows"));
    arrow_panel.add(e_uarrow_pred);
    arrow_panel.add(e_darrow_pred);
    arrow_panel.add(e_arrow_centered);

    e_show_d = new JCheckBox("directed");
    e_show_d.addActionListener(this);
    e_show_d.setSelected(true);
    e_show_u = new JCheckBox("undirected");
    e_show_u.addActionListener(this);
    e_show_u.setSelected(true);
    JPanel show_edge_panel = new JPanel(new GridLayout(1, 0));
    show_edge_panel.setBorder(BorderFactory.createTitledBorder("Show edges"));
    show_edge_panel.add(e_show_u);
    show_edge_panel.add(e_show_d);

    shape_panel.setAlignmentX(Component.LEFT_ALIGNMENT);
    edge_panel.add(shape_panel);
    gradient_panel.setAlignmentX(Component.LEFT_ALIGNMENT);
    edge_panel.add(gradient_panel);
    show_edge_panel.setAlignmentX(Component.LEFT_ALIGNMENT);
    edge_panel.add(show_edge_panel);
    arrow_panel.setAlignmentX(Component.LEFT_ALIGNMENT);
    edge_panel.add(arrow_panel);

    e_color.setAlignmentX(Component.LEFT_ALIGNMENT);
    edge_panel.add(e_color);
    e_labels.setAlignmentX(Component.LEFT_ALIGNMENT);
    edge_panel.add(e_labels);

    // set up zoom controls
    zoom_at_mouse = new JCheckBox("<html><center>zoom at mouse<p>(wheel only)</center></html>");
    zoom_at_mouse.addActionListener(this);
    zoom_at_mouse.setSelected(true);

    final ScalingControl scaler = new CrossoverScalingControl();

    JButton plus = new JButton("+");
    plus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1.1f, vv.getCenter());
        }
    });
    JButton minus = new JButton("-");
    minus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1 / 1.1f, vv.getCenter());
        }
    });

    JPanel zoomPanel = new JPanel();
    zoomPanel.setBorder(BorderFactory.createTitledBorder("Zoom"));
    plus.setAlignmentX(Component.CENTER_ALIGNMENT);
    zoomPanel.add(plus);
    minus.setAlignmentX(Component.CENTER_ALIGNMENT);
    zoomPanel.add(minus);
    zoom_at_mouse.setAlignmentX(Component.CENTER_ALIGNMENT);
    zoomPanel.add(zoom_at_mouse);

    JPanel fontPanel = new JPanel();
    // add font and zoom controls to center panel
    font = new JCheckBox("bold text");
    font.addActionListener(this);
    font.setAlignmentX(Component.CENTER_ALIGNMENT);
    fontPanel.add(font);

    both_panel.add(zoomPanel);
    both_panel.add(fontPanel);

    JComboBox modeBox = gm.getModeComboBox();
    modeBox.setAlignmentX(Component.CENTER_ALIGNMENT);
    JPanel modePanel = new JPanel(new BorderLayout()) {
        public Dimension getMaximumSize() {
            return getPreferredSize();
        }
    };
    modePanel.setBorder(BorderFactory.createTitledBorder("Mouse Mode"));
    modePanel.add(modeBox);
    JPanel comboGrid = new JPanel(new GridLayout(0, 1));
    comboGrid.add(modePanel);
    fontPanel.add(comboGrid);

    JComboBox cb = new JComboBox();
    cb.addItem(Renderer.VertexLabel.Position.N);
    cb.addItem(Renderer.VertexLabel.Position.NE);
    cb.addItem(Renderer.VertexLabel.Position.E);
    cb.addItem(Renderer.VertexLabel.Position.SE);
    cb.addItem(Renderer.VertexLabel.Position.S);
    cb.addItem(Renderer.VertexLabel.Position.SW);
    cb.addItem(Renderer.VertexLabel.Position.W);
    cb.addItem(Renderer.VertexLabel.Position.NW);
    cb.addItem(Renderer.VertexLabel.Position.N);
    cb.addItem(Renderer.VertexLabel.Position.CNTR);
    cb.addItem(Renderer.VertexLabel.Position.AUTO);
    cb.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            Renderer.VertexLabel.Position position = (Renderer.VertexLabel.Position) e.getItem();
            vv.getRenderer().getVertexLabelRenderer().setPosition(position);
            vv.repaint();
        }
    });
    cb.setSelectedItem(Renderer.VertexLabel.Position.SE);
    JPanel positionPanel = new JPanel();
    positionPanel.setBorder(BorderFactory.createTitledBorder("Label Position"));
    positionPanel.add(cb);

    comboGrid.add(positionPanel);

}

From source file:de.unikassel.jung.PluggableRendererDemo.java

/**
 * @param jp//from   ww  w .  j  a va 2 s  .  com
 *            panel to which controls will be added
 */
@SuppressWarnings("serial")
protected void addBottomControls(final JPanel jp) {
    final JPanel control_panel = new JPanel();
    jp.add(control_panel, BorderLayout.EAST);
    control_panel.setLayout(new BorderLayout());
    final Box vertex_panel = Box.createVerticalBox();
    vertex_panel.setBorder(BorderFactory.createTitledBorder("Vertices"));
    final Box edge_panel = Box.createVerticalBox();
    edge_panel.setBorder(BorderFactory.createTitledBorder("Edges"));
    final Box both_panel = Box.createVerticalBox();

    control_panel.add(vertex_panel, BorderLayout.NORTH);
    control_panel.add(edge_panel, BorderLayout.SOUTH);
    control_panel.add(both_panel, BorderLayout.CENTER);

    // set up vertex controls
    v_color = new JCheckBox("seed highlight");
    v_color.addActionListener(this);
    v_stroke = new JCheckBox("stroke highlight on selection");
    v_stroke.addActionListener(this);
    v_labels = new JCheckBox("show voltage values");
    v_labels.addActionListener(this);
    v_shape = new JCheckBox("shape by degree");
    v_shape.addActionListener(this);
    v_size = new JCheckBox("size by voltage");
    v_size.addActionListener(this);
    v_size.setSelected(true);
    v_aspect = new JCheckBox("stretch by degree ratio");
    v_aspect.addActionListener(this);
    v_small = new JCheckBox("filter when degree < " + VertexDisplayPredicate.MIN_DEGREE);
    v_small.addActionListener(this);

    vertex_panel.add(v_color);
    vertex_panel.add(v_stroke);
    vertex_panel.add(v_labels);
    vertex_panel.add(v_shape);
    vertex_panel.add(v_size);
    vertex_panel.add(v_aspect);
    vertex_panel.add(v_small);

    // set up edge controls
    JPanel gradient_panel = new JPanel(new GridLayout(1, 0));
    gradient_panel.setBorder(BorderFactory.createTitledBorder("Edge paint"));
    no_gradient = new JRadioButton("Solid color");
    no_gradient.addActionListener(this);
    no_gradient.setSelected(true);
    // gradient_absolute = new JRadioButton("Absolute gradient");
    // gradient_absolute.addActionListener(this);
    gradient_relative = new JRadioButton("Gradient");
    gradient_relative.addActionListener(this);
    ButtonGroup bg_grad = new ButtonGroup();
    bg_grad.add(no_gradient);
    bg_grad.add(gradient_relative);
    // bg_grad.add(gradient_absolute);
    gradient_panel.add(no_gradient);
    // gradientGrid.add(gradient_absolute);
    gradient_panel.add(gradient_relative);

    JPanel shape_panel = new JPanel(new GridLayout(3, 2));
    shape_panel.setBorder(BorderFactory.createTitledBorder("Edge shape"));
    e_line = new JRadioButton("line");
    e_line.addActionListener(this);
    e_line.setSelected(true);
    // e_bent = new JRadioButton("bent line");
    // e_bent.addActionListener(this);
    e_wedge = new JRadioButton("wedge");
    e_wedge.addActionListener(this);
    e_quad = new JRadioButton("quad curve");
    e_quad.addActionListener(this);
    e_cubic = new JRadioButton("cubic curve");
    e_cubic.addActionListener(this);
    e_ortho = new JRadioButton("orthogonal");
    e_ortho.addActionListener(this);
    ButtonGroup bg_shape = new ButtonGroup();
    bg_shape.add(e_line);
    // bg.add(e_bent);
    bg_shape.add(e_wedge);
    bg_shape.add(e_quad);
    bg_shape.add(e_ortho);
    bg_shape.add(e_cubic);
    shape_panel.add(e_line);
    // shape_panel.add(e_bent);
    shape_panel.add(e_wedge);
    shape_panel.add(e_quad);
    shape_panel.add(e_cubic);
    shape_panel.add(e_ortho);
    fill_edges = new JCheckBox("fill edge shapes");
    fill_edges.setSelected(false);
    fill_edges.addActionListener(this);
    shape_panel.add(fill_edges);
    shape_panel.setOpaque(true);
    e_color = new JCheckBox("highlight edge weights");
    e_color.addActionListener(this);
    e_labels = new JCheckBox("show edge weight values");
    e_labels.addActionListener(this);
    e_uarrow_pred = new JCheckBox("undirected");
    e_uarrow_pred.addActionListener(this);
    e_darrow_pred = new JCheckBox("directed");
    e_darrow_pred.addActionListener(this);
    e_darrow_pred.setSelected(true);
    e_arrow_centered = new JCheckBox("centered");
    e_arrow_centered.addActionListener(this);
    JPanel arrow_panel = new JPanel(new GridLayout(1, 0));
    arrow_panel.setBorder(BorderFactory.createTitledBorder("Show arrows"));
    arrow_panel.add(e_uarrow_pred);
    arrow_panel.add(e_darrow_pred);
    arrow_panel.add(e_arrow_centered);

    e_show_d = new JCheckBox("directed");
    e_show_d.addActionListener(this);
    e_show_d.setSelected(true);
    e_show_u = new JCheckBox("undirected");
    e_show_u.addActionListener(this);
    e_show_u.setSelected(true);
    JPanel show_edge_panel = new JPanel(new GridLayout(1, 0));
    show_edge_panel.setBorder(BorderFactory.createTitledBorder("Show edges"));
    show_edge_panel.add(e_show_u);
    show_edge_panel.add(e_show_d);

    shape_panel.setAlignmentX(Component.LEFT_ALIGNMENT);
    edge_panel.add(shape_panel);
    gradient_panel.setAlignmentX(Component.LEFT_ALIGNMENT);
    edge_panel.add(gradient_panel);
    show_edge_panel.setAlignmentX(Component.LEFT_ALIGNMENT);
    edge_panel.add(show_edge_panel);
    arrow_panel.setAlignmentX(Component.LEFT_ALIGNMENT);
    edge_panel.add(arrow_panel);

    e_color.setAlignmentX(Component.LEFT_ALIGNMENT);
    edge_panel.add(e_color);
    e_labels.setAlignmentX(Component.LEFT_ALIGNMENT);
    edge_panel.add(e_labels);

    // set up zoom controls
    zoom_at_mouse = new JCheckBox("<html><center>zoom at mouse<p>(wheel only)</center></html>");
    zoom_at_mouse.addActionListener(this);
    zoom_at_mouse.setSelected(true);

    final ScalingControl scaler = new CrossoverScalingControl();

    JButton plus = new JButton("+");
    plus.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent e) {
            scaler.scale(vv, 1.1f, vv.getCenter());
        }
    });
    JButton minus = new JButton("-");
    minus.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent e) {
            scaler.scale(vv, 1 / 1.1f, vv.getCenter());
        }
    });

    JPanel zoomPanel = new JPanel();
    zoomPanel.setBorder(BorderFactory.createTitledBorder("Zoom"));
    plus.setAlignmentX(Component.CENTER_ALIGNMENT);
    zoomPanel.add(plus);
    minus.setAlignmentX(Component.CENTER_ALIGNMENT);
    zoomPanel.add(minus);
    zoom_at_mouse.setAlignmentX(Component.CENTER_ALIGNMENT);
    zoomPanel.add(zoom_at_mouse);

    JPanel fontPanel = new JPanel();
    // add font and zoom controls to center panel
    font = new JCheckBox("bold text");
    font.addActionListener(this);
    font.setAlignmentX(Component.CENTER_ALIGNMENT);
    fontPanel.add(font);

    both_panel.add(zoomPanel);
    both_panel.add(fontPanel);

    JComboBox modeBox = gm.getModeComboBox();
    modeBox.setAlignmentX(Component.CENTER_ALIGNMENT);
    JPanel modePanel = new JPanel(new BorderLayout()) {
        @Override
        public Dimension getMaximumSize() {
            return getPreferredSize();
        }
    };
    modePanel.setBorder(BorderFactory.createTitledBorder("Mouse Mode"));
    modePanel.add(modeBox);
    JPanel comboGrid = new JPanel(new GridLayout(0, 1));
    comboGrid.add(modePanel);
    fontPanel.add(comboGrid);

    JComboBox cb = new JComboBox();
    cb.addItem(Renderer.VertexLabel.Position.N);
    cb.addItem(Renderer.VertexLabel.Position.NE);
    cb.addItem(Renderer.VertexLabel.Position.E);
    cb.addItem(Renderer.VertexLabel.Position.SE);
    cb.addItem(Renderer.VertexLabel.Position.S);
    cb.addItem(Renderer.VertexLabel.Position.SW);
    cb.addItem(Renderer.VertexLabel.Position.W);
    cb.addItem(Renderer.VertexLabel.Position.NW);
    cb.addItem(Renderer.VertexLabel.Position.N);
    cb.addItem(Renderer.VertexLabel.Position.CNTR);
    cb.addItem(Renderer.VertexLabel.Position.AUTO);
    cb.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(final ItemEvent e) {
            Renderer.VertexLabel.Position position = (Renderer.VertexLabel.Position) e.getItem();
            vv.getRenderer().getVertexLabelRenderer().setPosition(position);
            vv.repaint();
        }
    });
    cb.setSelectedItem(Renderer.VertexLabel.Position.SE);
    JPanel positionPanel = new JPanel();
    positionPanel.setBorder(BorderFactory.createTitledBorder("Label Position"));
    positionPanel.add(cb);

    comboGrid.add(positionPanel);

}

From source file:com.xilinx.virtex7.MainScreen.java

private Container createContentPane() {
    JPanel contentPane = new JPanel();
    contentPane.setLayout(new BorderLayout());
    contentPane.setOpaque(true);

    mainPanel = new JPanel(new BorderLayout());

    mainPanel.setBounds(0, 0, minWidth, minHeight);
    testPanel = new JPanel(new BorderLayout());
    ttabs = new JTabbedPane();
    ttabs.add("DATAPATH 0&1", testAndStats());

    if (mode == LandingPage.PERFORMANCE_MODE_RAW || mode == LandingPage.PERFORMANCE_MODE_RAW_DV
            || mode == LandingPage.APPLICATION_MODE || mode == LandingPage.APPLICATION_MODE_P2P) // condition for placing dynamic tabs. a kcah
        ttabs.add("DATAPATH 2&3", testAndStatsSecondTab());
    else//from   w  w  w  .  ja  v  a 2 s .  co  m
        testAndStatsSecondTab();

    testPanel.add(ttabs, BorderLayout.CENTER);
    testPanel.add(messageBox(), BorderLayout.PAGE_END);

    mainPanel.add(testPanel, BorderLayout.LINE_START);

    //Make the center component big, since that's the
    //typical usage of BorderLayout.
    tabs = new JTabbedPane();

    mainPanel.add(tabs, BorderLayout.CENTER);

    tabs.add("System Monitor", pciInfo());
    tabs.add("Performance Plots", plotPanel());

    mainPanel.setOpaque(true);

    try {
        imagePanel = new ImageBackgroundPanel(blockDiagram, false);
    } catch (Exception e) {
    }
    /*imagePanel.setBorder(BorderFactory.createCompoundBorder(
                BorderFactory.createTitledBorder("Design Block Diagram"),
                BorderFactory.createEmptyBorder(5,5,5,5)));*/
    imagePanel.setBackground(Color.WHITE);
    imagePanel.setSize(minWidth, minHeight);

    imagePanel.setLocation(0, 0);
    imagePanel.setOpaque(true);

    final JLayeredPane layeredPane = new JLayeredPane();
    layeredPane.setPreferredSize(new Dimension(minWidth, minHeight));
    layeredPane.add(mainPanel, JLayeredPane.DEFAULT_LAYER, 0);
    layeredPane.add(imagePanel, JLayeredPane.DEFAULT_LAYER, 0);
    layeredPane.addComponentListener(new ComponentListener() {

        @Override
        public void componentResized(ComponentEvent ce) {
            mainPanel.setBounds(0, 0, Math.max(minWidth, layeredPane.getWidth()),
                    Math.max(minHeight, layeredPane.getHeight()));
            if (layeredPane.getWidth() > 1024) {
                tplotPanel.setPreferredSize(new Dimension(300, 100));
            } else {
                tplotPanel.setPreferredSize(new Dimension(200, 100));
            }
            imagePanel.setSize(mainPanel.getWidth(), mainPanel.getHeight());
            imagePanel.setLocation(0, 0);
            mainPanel.repaint();
        }

        @Override
        public void componentMoved(ComponentEvent ce) {
            //throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public void componentShown(ComponentEvent ce) {
            //throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public void componentHidden(ComponentEvent ce) {
            //throw new UnsupportedOperationException("Not supported yet.");
        }
    });
    // on top, but invisible initially
    imagePanel.setVisible(false);

    JPanel bpanel = new JPanel(new BorderLayout());

    final JButton button = new JButton(
            "<html><b>B<br>L<br>O<br>C<br>K<br> <br>D<br>I<br>A<br>G<br>R<br>A<br>M<br></b></html>");
    button.setToolTipText("Click here to see the block diagram");
    button.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            adjustSelectionPanel();
        }
    });

    bpanel.add(button, BorderLayout.CENTER);

    contentPane.add(layeredPane, BorderLayout.CENTER);
    contentPane.add(button, BorderLayout.EAST);
    JPanel panel = new JPanel(new BorderLayout());

    JLabel mLabel = new JLabel(modeText, JLabel.CENTER);
    mLabel.setFont(new Font(modeText, Font.BOLD, 15));
    panel.add(mLabel, BorderLayout.PAGE_START);

    JPanel ledPanel = new JPanel(new BorderLayout());

    JPanel iledPanel = new JPanel();
    iledPanel.setLayout(new BoxLayout(iledPanel, BoxLayout.X_AXIS));

    led_ddr3_1 = new JLabel("DDR3 0", new ImageIcon(led1), JLabel.CENTER);
    led_ddr3_2 = new JLabel("DDR3 1", new ImageIcon(led1), JLabel.CENTER);
    led_phy0 = new JLabel("PHY 0", new ImageIcon(led1), JLabel.CENTER);
    led_phy1 = new JLabel("PHY 1", new ImageIcon(led1), JLabel.CENTER);
    led_phy2 = new JLabel("PHY 2", new ImageIcon(led1), JLabel.CENTER);
    led_phy3 = new JLabel("PHY 3", new ImageIcon(led1), JLabel.CENTER);

    JPanel le1 = new JPanel(new BorderLayout());
    le1.add(led_ddr3_1, BorderLayout.CENTER);

    JPanel le2 = new JPanel(new BorderLayout());
    le2.add(led_ddr3_2, BorderLayout.CENTER);

    JPanel le3 = new JPanel(new BorderLayout());
    le3.add(led_phy0, BorderLayout.CENTER);

    JPanel le4 = new JPanel(new BorderLayout());
    le4.add(led_phy1, BorderLayout.CENTER);

    JPanel le5 = new JPanel(new BorderLayout());
    le5.add(led_phy2, BorderLayout.CENTER);

    JPanel le6 = new JPanel(new BorderLayout());
    le6.add(led_phy3, BorderLayout.CENTER);

    iledPanel.add(le1);
    iledPanel.add(le2);
    iledPanel.add(le3);
    iledPanel.add(le4);
    iledPanel.add(le5);
    iledPanel.add(le6);

    if (mode == LandingPage.PERFORMANCE_MODE_RAW || mode == LandingPage.PERFORMANCE_MODE_RAW_DV) {
        startAll_tooltip = "This will start tests on all data paths";
        startAlltests = new JButton("Start All");
        startAlltests.setToolTipText(startAll_tooltip);
        startAlltests.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent ae) {
                if (startAlltests.getText().equals("Start All")) {
                    startAll_tooltip = "This will stop tests on all data paths";
                    startAlltests.setToolTipText(startAll_tooltip);
                    // check whether any tests are already started
                    String message = "";
                    if (testStarted || testStarted1)
                        message = "Test(s) on Path 0&1 are running. Cannot do Start All";
                    if (testStarted2 || testStarted3) {
                        if (message.length() > 0) // test 1 and 0 are also running
                            message = "Test(s) on Path 0&1 and 2&3 are running. Cannot do Start All";
                        else
                            message = "Test(s) on Path 2&3 are running. Cannot do Start All";
                    }
                    if (message.length() > 0) {
                        JOptionPane.showMessageDialog(null, message, "Error", JOptionPane.ERROR_MESSAGE);
                    } else {
                        String ledsMsg = checkLedsState();
                        // condition to check the ddr and py leds are enable or not
                        if (ledsMsg.length() == 0) {
                            startAlltests.setEnabled(false);
                            startAlltests.setText("Stop All");

                            startTest.doClick();
                            stest.doClick();
                            s3test.doClick();
                            s4test.doClick();

                            // disable all buttons
                            startTest.setEnabled(false);
                            stest.setEnabled(false);
                            s3test.setEnabled(false);
                            s4test.setEnabled(false);

                            startAlltests.setEnabled(true);
                        } else {// shows alert when leds are disabled                                
                            JOptionPane.showMessageDialog(null, ledsMsg, "Error", JOptionPane.ERROR_MESSAGE);
                        }

                    }
                } else {
                    startAlltests.setEnabled(false);
                    startAll_tooltip = "This will start tests on all data paths";
                    startAlltests.setToolTipText(startAll_tooltip);
                    /*
                    startTest.setEnabled(true);
                    stest.setEnabled(true);
                    s3test.setEnabled(true);
                    s4test.setEnabled(true);
                            
                    s3test.doClick();
                    s4test.doClick();
                    startTest.doClick();
                    stest.doClick();
                    */
                    SwingWorker worker = new SwingWorker<Void, Void>() {
                        @Override
                        protected Void doInBackground() throws Exception {
                            try {
                                stopTest4();
                                s4test.setEnabled(false);
                                stopTest3();
                                s3test.setEnabled(false);
                                stopTest2();
                                stest.setEnabled(false);
                                stopTest1();
                                startTest.setEnabled(false);

                                startAlltests.setText("Start All");
                                startAlltests.setEnabled(true);
                                startTest.setEnabled(true);
                                stest.setEnabled(true);
                                s3test.setEnabled(true);
                                s4test.setEnabled(true);
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                            return null;
                        }

                    };
                    worker.execute();
                }
            }
        });
        iledPanel.add(startAlltests);
    }
    ledPanel.add(iledPanel, BorderLayout.CENTER);

    //tstats.add(ledPanel);
    panel.add(ledPanel, BorderLayout.CENTER);
    contentPane.add(panel, BorderLayout.PAGE_START);
    return contentPane;
}

From source file:com.openbravo.pos.util.JRViewer411.java

protected void createHyperlinks(List<JRPrintElement> elements, int offsetX, int offsetY) {
    if (elements != null && elements.size() > 0) {
        for (Iterator<JRPrintElement> it = elements.iterator(); it.hasNext();) {
            JRPrintElement element = it.next();

            JRImageMapRenderer imageMap = null;
            if (element instanceof JRPrintImage) {
                JRRenderable renderer = ((JRPrintImage) element).getRenderer();
                if (renderer instanceof JRImageMapRenderer) {
                    imageMap = (JRImageMapRenderer) renderer;
                    if (!imageMap.hasImageAreaHyperlinks()) {
                        imageMap = null;
                    }//from   w w w.j a  va2  s. c o  m
                }
            }
            boolean hasImageMap = imageMap != null;

            JRPrintHyperlink hyperlink = null;
            if (element instanceof JRPrintHyperlink) {
                hyperlink = (JRPrintHyperlink) element;
            }
            boolean hasHyperlink = !hasImageMap && hyperlink != null
                    && hyperlink.getHyperlinkTypeValue() != HyperlinkTypeEnum.NONE;
            boolean hasTooltip = hyperlink != null && hyperlink.getHyperlinkTooltip() != null;

            if (hasHyperlink || hasImageMap || hasTooltip) {
                JPanel link;
                if (hasImageMap) {
                    Rectangle renderingArea = new Rectangle(0, 0, element.getWidth(), element.getHeight());
                    link = new ImageMapPanel(renderingArea, imageMap);
                } else //hasImageMap
                {
                    link = new JPanel();
                    if (hasHyperlink) {
                        link.addMouseListener(mouseListener);
                    }
                }

                if (hasHyperlink) {
                    link.setCursor(new Cursor(Cursor.HAND_CURSOR));
                }

                link.setLocation((int) ((element.getX() + offsetX) * realZoom),
                        (int) ((element.getY() + offsetY) * realZoom));
                link.setSize((int) (element.getWidth() * realZoom), (int) (element.getHeight() * realZoom));
                link.setOpaque(false);

                String toolTip = getHyperlinkTooltip(hyperlink);
                if (toolTip == null && hasImageMap) {
                    toolTip = "";//not null to register the panel as having a tool tip
                }
                link.setToolTipText(toolTip);

                pnlLinks.add(link);
                linksMap.put(link, hyperlink);
            }

            if (element instanceof JRPrintFrame) {
                JRPrintFrame frame = (JRPrintFrame) element;
                int frameOffsetX = offsetX + frame.getX() + frame.getLineBox().getLeftPadding().intValue();
                int frameOffsetY = offsetY + frame.getY() + frame.getLineBox().getTopPadding().intValue();
                createHyperlinks(frame.getElements(), frameOffsetX, frameOffsetY);
            }
        }
    }
}

From source file:neg.JRViewer.java

protected void createHyperlinks(List elements, int offsetX, int offsetY) {
    if (elements != null && elements.size() > 0) {
        for (Iterator it = elements.iterator(); it.hasNext();) {
            JRPrintElement element = (JRPrintElement) it.next();

            JRImageMapRenderer imageMap = null;
            if (element instanceof JRPrintImage) {
                JRRenderable renderer = ((JRPrintImage) element).getRenderer();
                if (renderer instanceof JRImageMapRenderer) {
                    imageMap = (JRImageMapRenderer) renderer;
                    if (!imageMap.hasImageAreaHyperlinks()) {
                        imageMap = null;
                    }//from  www  .  j  a v a2s  .c  o m
                }
            }
            boolean hasImageMap = imageMap != null;

            JRPrintHyperlink hyperlink = null;
            if (element instanceof JRPrintHyperlink) {
                hyperlink = (JRPrintHyperlink) element;
            }
            boolean hasHyperlink = !hasImageMap && hyperlink != null
                    && hyperlink.getHyperlinkType() != JRHyperlink.HYPERLINK_TYPE_NONE;
            boolean hasTooltip = hyperlink != null && hyperlink.getHyperlinkTooltip() != null;

            if (hasHyperlink || hasImageMap || hasTooltip) {
                JPanel link;
                if (hasImageMap) {
                    Rectangle renderingArea = new Rectangle(0, 0, element.getWidth(), element.getHeight());
                    link = new ImageMapPanel(renderingArea, imageMap);
                } else //hasImageMap
                {
                    link = new JPanel();
                    if (hasHyperlink) {
                        link.addMouseListener(mouseListener);
                    }
                }

                if (hasHyperlink) {
                    link.setCursor(new Cursor(Cursor.HAND_CURSOR));
                }

                link.setLocation((int) ((element.getX() + offsetX) * realZoom),
                        (int) ((element.getY() + offsetY) * realZoom));
                link.setSize((int) (element.getWidth() * realZoom), (int) (element.getHeight() * realZoom));
                link.setOpaque(false);

                String toolTip = getHyperlinkTooltip(hyperlink);
                if (toolTip == null && hasImageMap) {
                    toolTip = "";//not null to register the panel as having a tool tip
                }
                link.setToolTipText(toolTip);

                pnlLinks.add(link);
                linksMap.put(link, element);
            }

            if (element instanceof JRPrintFrame) {
                JRPrintFrame frame = (JRPrintFrame) element;
                int frameOffsetX = offsetX + frame.getX() + frame.getLineBox().getLeftPadding().intValue();
                int frameOffsetY = offsetY + frame.getY() + frame.getLineBox().getTopPadding().intValue();
                createHyperlinks(frame.getElements(), frameOffsetX, frameOffsetY);
            }
        }
    }
}

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

private JPanel buildBotones(final Dimension dimension2, final JList left, final JList right) {

    JPanel botones = new JPanel(new GridBagLayout());
    botones.setPreferredSize(dimension2);
    JButton derecha = new JButton(LogicConstants.getIcon("button_right"));
    derecha.setBorderPainted(false);//from  w  w w  . jav  a  2 s  .c  o  m
    derecha.setOpaque(false);
    derecha.setContentAreaFilled(false);
    derecha.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            cambios = true;
            for (Object o : left.getSelectedValues()) {
                ((DefaultListModel) right.getModel()).addElement(o);
                rightItems.add(o);
            }
            for (Object o : left.getSelectedValues()) {
                ((DefaultListModel) left.getModel()).removeElement(o);
                leftItems.remove(o);
            }
        }
    });
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridy = 0;
    botones.add(derecha, gbc);
    izquierda.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            cambios = true;
            for (Object o : right.getSelectedValues()) {
                ((DefaultListModel) left.getModel()).addElement(o);
                leftItems.add(o);
            }
            for (Object o : right.getSelectedValues()) {
                ((DefaultListModel) right.getModel()).removeElement(o);
                rightItems.remove(o);
            }
        }
    });
    gbc.gridy++;
    izquierda.setBorderPainted(false);
    izquierda.setOpaque(false);
    izquierda.setContentAreaFilled(false);
    botones.add(izquierda, gbc);
    botones.setOpaque(false);
    return botones;
}

From source file:cn.pholance.datamanager.common.components.JRViewer.java

protected void createHyperlinks(List<JRPrintElement> elements, int offsetX, int offsetY) {
    if (elements != null && elements.size() > 0) {
        for (Iterator<JRPrintElement> it = elements.iterator(); it.hasNext();) {
            JRPrintElement element = it.next();

            ImageMapRenderable imageMap = null;
            if (element instanceof JRPrintImage) {
                Renderable renderer = ((JRPrintImage) element).getRenderable();
                if (renderer instanceof ImageMapRenderable) {
                    imageMap = (ImageMapRenderable) renderer;
                    if (!imageMap.hasImageAreaHyperlinks()) {
                        imageMap = null;
                    }/*from   w w  w  .  java  2  s  . com*/
                }
            }
            boolean hasImageMap = imageMap != null;

            JRPrintHyperlink hyperlink = null;
            if (element instanceof JRPrintHyperlink) {
                hyperlink = (JRPrintHyperlink) element;
            }
            boolean hasHyperlink = !hasImageMap && hyperlink != null
                    && hyperlink.getHyperlinkTypeValue() != HyperlinkTypeEnum.NONE;
            boolean hasTooltip = hyperlink != null && hyperlink.getHyperlinkTooltip() != null;

            if (hasHyperlink || hasImageMap || hasTooltip) {
                JPanel link;
                if (hasImageMap) {
                    Rectangle renderingArea = new Rectangle(0, 0, element.getWidth(), element.getHeight());
                    link = new ImageMapPanel(renderingArea, imageMap);
                } else //hasImageMap
                {
                    link = new JPanel();
                    if (hasHyperlink) {
                        link.addMouseListener(mouseListener);
                    }
                }

                if (hasHyperlink) {
                    link.setCursor(new Cursor(Cursor.HAND_CURSOR));
                }

                link.setLocation((int) ((element.getX() + offsetX) * realZoom),
                        (int) ((element.getY() + offsetY) * realZoom));
                link.setSize((int) (element.getWidth() * realZoom), (int) (element.getHeight() * realZoom));
                link.setOpaque(false);

                String toolTip = getHyperlinkTooltip(hyperlink);
                if (toolTip == null && hasImageMap) {
                    toolTip = "";//not null to register the panel as having a tool tip
                }
                link.setToolTipText(toolTip);

                pnlLinks.add(link);
                linksMap.put(link, hyperlink);
            }

            if (element instanceof JRPrintFrame) {
                JRPrintFrame frame = (JRPrintFrame) element;
                int frameOffsetX = offsetX + frame.getX() + frame.getLineBox().getLeftPadding().intValue();
                int frameOffsetY = offsetY + frame.getY() + frame.getLineBox().getTopPadding().intValue();
                createHyperlinks(frame.getElements(), frameOffsetX, frameOffsetY);
            }
        }
    }
}