Example usage for javax.swing JLabel setFont

List of usage examples for javax.swing JLabel setFont

Introduction

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

Prototype

@BeanProperty(preferred = true, visualUpdate = true, description = "The font for the component.")
public void setFont(Font font) 

Source Link

Document

Sets the font for this component.

Usage

From source file:edu.ku.brc.specify.config.init.secwiz.DatabasePanel.java

/**
 * Creates a dialog for entering database name and selecting the appropriate driver.
 *///  w  w  w.  j a va  2  s  .  c  o  m
public DatabasePanel(final JButton nextBtn, final JButton prevBtn, final String helpContext,
        final boolean doSetDefaultValues) {
    super("DATABASE", helpContext, nextBtn, prevBtn);

    this.doSetDefaultValues = doSetDefaultValues;

    String header = getResourceString("ENTER_DB_INFO") + ":";

    CellConstraints cc = new CellConstraints();

    String rowDef = "p,2px," + UIHelper.createDuplicateJGoodiesDef("p", "2px", isMobile() ? 5 : 4)
            + ",10px,p,10px,p,4px,p,4px,p,10px,f:p:g";
    PanelBuilder builder = new PanelBuilder(new FormLayout("p,2px,p:g", rowDef), this);
    int row = 1;

    builder.add(createLabel(header, SwingConstants.CENTER), cc.xywh(1, row, 3, 1));
    row += 2;

    usernameTxt = createField(builder, "IT_USERNAME", true, row);
    row += 2;
    passwordTxt = createField(builder, "IT_PASSWORD", true, row, true, null);
    row += 2;
    if (isMobile()) {
        dbNameTxt = createField(builder, "DB_NAME", true, row);
        row += 2;
    } else {
        dbNameTxt = createTextField();
    }
    hostNameTxt = createField(builder, "HOST_NAME", true, row);
    row += 2;

    driverList = DatabaseDriverInfo.getDriversList();
    drivers = createComboBox(driverList);

    // MySQL as the default
    drivers.setSelectedItem(DatabaseDriverInfo.getDriver("MySQL"));

    JLabel lbl = createI18NFormLabel("DRIVER", SwingConstants.RIGHT);
    lbl.setFont(bold);
    builder.add(lbl, cc.xy(1, row));
    builder.add(drivers, cc.xy(3, row));
    row += 2;

    label = UIHelper.createLabel("", SwingConstants.CENTER);

    PanelBuilder panelPB = new PanelBuilder(new FormLayout("f:p:g", "20px,p,8px,p"));
    panelPB.add(getProgressBar(), cc.xy(1, 2));
    panelPB.add(label, cc.xy(1, 4));

    builder.add(panelPB.getPanel(), cc.xy(3, row));
    row += 2;

    //panelPB.getPanel().setBackground(Color.RED);
    //setBackground(Color.GREEN);

    // Advance part of pane
    advLabel = UIHelper.createI18NLabel("SEC_ADV_MU_DESC", SwingConstants.CENTER);
    skipStepBtn = UIHelper.createI18NButton("ADV_DB_TEST");
    builder.add(advLabel, cc.xyw(3, row, 1));
    row += 2;

    PanelBuilder tstPB = new PanelBuilder(new FormLayout("f:p:g,p,f:p:g", "p"));
    tstPB.add(skipStepBtn, cc.xy(2, 1));
    builder.add(tstPB.getPanel(), cc.xyw(3, row, 1));
    row += 2;

    JComponent helpComponent = createHelpPanel(getBackground(), "database");
    builder.add(helpComponent, cc.xyw(3, row, 1));
    row += 2;

    skipStepBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            skipStepBtn.setEnabled(false);
            boolean ok = skipDBCreate();

            if (ok) {
                ok = checkForPermissions();
            }

            isOK = ok;
            skipStepBtn.setEnabled(true);
            advLabel.setText(getResourceString(ok ? "ADV_DB_OK" : "ADV_DB_ERR"));
            advLabel.setForeground(ok ? Color.BLACK : Color.RED);
            nextBtn.setEnabled(isOK);
        }
    });

    if (isMobile()) {
        skipStepBtn.setVisible(false);
        advLabel.setVisible(false);
    }

    progressBar.setVisible(false);

    updateBtnUI();
}

From source file:com.edduarte.protbox.ui.windows.RestoreFileWindow.java

private RestoreFileWindow(final PReg registry) {
    super();//from   w  ww. j  a v  a  2 s .  co  m
    setLayout(null);

    final JTextField searchField = new JTextField();
    searchField.setLayout(null);
    searchField.setBounds(2, 2, 301, 26);
    searchField.setBorder(new LineBorder(Color.lightGray));
    searchField.setFont(Constants.FONT);
    add(searchField);

    final JLabel noBackupFilesLabel = new JLabel("<html>No backups files were found!<br><br>"
            + "<font color=\"gray\">If you think there is a problem with the<br>"
            + "backup system, please create an issue here:<br>"
            + "<a href=\"#\">https://github.com/com.edduarte/protbox/issues</a></font></html>");
    noBackupFilesLabel.setLayout(null);
    noBackupFilesLabel.setBounds(20, 50, 300, 300);
    noBackupFilesLabel.setFont(Constants.FONT.deriveFont(14f));
    noBackupFilesLabel.addMouseListener((OnMouseClick) e -> {
        String urlPath = "https://github.com/com.edduarte/protbox/issues";

        try {

            if (Desktop.isDesktopSupported()) {
                Desktop.getDesktop().browse(new URI(urlPath));

            } else {
                if (SystemUtils.IS_OS_WINDOWS) {
                    Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + urlPath);

                } else {
                    java.util.List<String> browsers = Lists.newArrayList("firefox", "opera", "safari",
                            "mozilla", "chrome");

                    for (String browser : browsers) {
                        if (Runtime.getRuntime().exec(new String[] { "which", browser }).waitFor() == 0) {

                            Runtime.getRuntime().exec(new String[] { browser, urlPath });
                            break;
                        }
                    }
                }
            }

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

    DefaultMutableTreeNode rootTreeNode = registry.buildEntryTree();
    final JTree tree = new JTree(rootTreeNode);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    if (rootTreeNode.getChildCount() == 0) {
        searchField.setEnabled(false);
        add(noBackupFilesLabel);
    }
    expandTree(tree);
    tree.setLayout(null);
    tree.setRootVisible(false);
    tree.setEditable(false);
    tree.setCellRenderer(new SearchableTreeCellRenderer(searchField));
    searchField.addKeyListener((OnKeyReleased) e -> {

        // update and expand tree
        DefaultTreeModel model = (DefaultTreeModel) tree.getModel();
        model.nodeStructureChanged((TreeNode) model.getRoot());
        expandTree(tree);
    });
    final JScrollPane scroll = new JScrollPane(tree, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scroll.setBorder(new DropShadowBorder());
    scroll.setBorder(new LineBorder(Color.lightGray));
    scroll.setBounds(2, 30, 334, 360);
    add(scroll);

    JLabel close = new JLabel(new ImageIcon(Constants.getAsset("close.png")));
    close.setLayout(null);
    close.setBounds(312, 7, 18, 18);
    close.setFont(Constants.FONT);
    close.setForeground(Color.gray);
    close.addMouseListener((OnMouseClick) e -> dispose());
    add(close);

    final JLabel permanentDeleteButton = new JLabel(new ImageIcon(Constants.getAsset("permanent.png")));
    permanentDeleteButton.setLayout(null);
    permanentDeleteButton.setBounds(91, 390, 40, 39);
    permanentDeleteButton.setBackground(Color.black);
    permanentDeleteButton.setEnabled(false);
    permanentDeleteButton.addMouseListener((OnMouseClick) e -> {
        if (permanentDeleteButton.isEnabled()) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
            PbxEntry entry = (PbxEntry) node.getUserObject();

            if (JOptionPane.showConfirmDialog(null,
                    "Are you sure you wish to permanently delete '" + entry.realName()
                            + "'?\nThis file and its "
                            + "backup copies will be deleted immediately. You cannot undo this action.",
                    "Confirm Cancel", JOptionPane.YES_NO_OPTION,
                    JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION) {

                registry.permanentDelete(entry);
                dispose();
                RestoreFileWindow.getInstance(registry);

            } else {
                setVisible(true);
            }
        }
    });
    add(permanentDeleteButton);

    final JLabel configBackupsButton = new JLabel(new ImageIcon(Constants.getAsset("config.png")));
    configBackupsButton.setLayout(null);
    configBackupsButton.setBounds(134, 390, 40, 39);
    configBackupsButton.setBackground(Color.black);
    configBackupsButton.setEnabled(false);
    configBackupsButton.addMouseListener((OnMouseClick) e -> {
        if (configBackupsButton.isEnabled()) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
            PbxEntry entry = (PbxEntry) node.getUserObject();
            if (entry instanceof PbxFile) {
                PbxFile pbxFile = (PbxFile) entry;

                JFrame frame = new JFrame("Choose backup policy");
                Object option = JOptionPane.showInputDialog(frame,
                        "Choose below the backup policy for this file:", "Choose backup",
                        JOptionPane.QUESTION_MESSAGE, null, PbxFile.BackupPolicy.values(),
                        pbxFile.getBackupPolicy());

                if (option == null) {
                    setVisible(true);
                    return;
                }
                PbxFile.BackupPolicy pickedPolicy = PbxFile.BackupPolicy.valueOf(option.toString());
                pbxFile.setBackupPolicy(pickedPolicy);
            }
            setVisible(true);
        }
    });
    add(configBackupsButton);

    final JLabel restoreBackupButton = new JLabel(new ImageIcon(Constants.getAsset("restore.png")));
    restoreBackupButton.setLayout(null);
    restoreBackupButton.setBounds(3, 390, 85, 39);
    restoreBackupButton.setBackground(Color.black);
    restoreBackupButton.setEnabled(false);
    restoreBackupButton.addMouseListener((OnMouseClick) e -> {
        if (restoreBackupButton.isEnabled()) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
            PbxEntry entry = (PbxEntry) node.getUserObject();
            if (entry instanceof PbxFolder) {
                registry.restoreFolderFromEntry((PbxFolder) entry);

            } else if (entry instanceof PbxFile) {
                PbxFile pbxFile = (PbxFile) entry;
                java.util.List<String> snapshots = pbxFile.snapshotsToString();
                if (snapshots.isEmpty()) {
                    setVisible(true);
                    return;
                }

                JFrame frame = new JFrame("Choose backup");
                Object option = JOptionPane.showInputDialog(frame,
                        "Choose below what backup snapshot would you like restore:", "Choose backup",
                        JOptionPane.QUESTION_MESSAGE, null, snapshots.toArray(), snapshots.get(0));

                if (option == null) {
                    setVisible(true);
                    return;
                }
                int pickedIndex = snapshots.indexOf(option.toString());
                registry.restoreFileFromEntry((PbxFile) entry, pickedIndex);
            }
            dispose();
        }
    });
    add(restoreBackupButton);

    tree.addMouseListener((OnMouseClick) e -> {
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
        if (node != null) {
            PbxEntry entry = (PbxEntry) node.getUserObject();
            if ((entry instanceof PbxFolder && entry.areNativeFilesDeleted())) {
                permanentDeleteButton.setEnabled(true);
                restoreBackupButton.setEnabled(true);
                configBackupsButton.setEnabled(false);

            } else if (entry instanceof PbxFile) {
                permanentDeleteButton.setEnabled(true);
                restoreBackupButton.setEnabled(true);
                configBackupsButton.setEnabled(true);

            } else {
                permanentDeleteButton.setEnabled(false);
                restoreBackupButton.setEnabled(false);
                configBackupsButton.setEnabled(false);
            }
        }
    });

    final JLabel cancel = new JLabel(new ImageIcon(Constants.getAsset("cancel.png")));
    cancel.setLayout(null);
    cancel.setBounds(229, 390, 122, 39);
    cancel.setBackground(Color.black);
    cancel.addMouseListener((OnMouseClick) e -> dispose());
    add(cancel);

    addWindowFocusListener(new WindowFocusListener() {
        private boolean gained = false;

        @Override
        public void windowGainedFocus(WindowEvent e) {
            gained = true;
        }

        @Override
        public void windowLostFocus(WindowEvent e) {
            if (gained) {
                dispose();
            }
        }
    });

    setSize(340, 432);
    setUndecorated(true);
    getContentPane().setBackground(Color.white);
    setResizable(false);
    getRootPane().setBorder(BorderFactory.createLineBorder(new Color(100, 100, 100)));
    Utils.setComponentLocationOnCenter(this);
    setVisible(true);
}

From source file:com.polivoto.vistas.AnalistaLocal.java

private void setPreguntasText() {
    JSONArray js = accionesConsultor.getPreguntas();
    for (int i = 0; i < js.length(); i++) {
        try {// w  w w  .  ja  va 2  s  .  c  o  m
            JPanel panel = new JPanel(new GridBagLayout());
            panel.setBackground(new Color(255, 255, 255));
            panelPreguntas.add(panel, "Pregunta " + (i + 1));
            JLabel lab1 = new JLabel(
                    "Pregunta " + (i + 1) + ": " + ((JSONObject) js.get(i)).getString("pregunta"),
                    JLabel.CENTER);
            lab1.setFont(new Font("Roboto", 1, 18));
            lab1.setForeground(new Color(134, 36, 31));
            GridBagConstraints gridBagConstraints = new java.awt.GridBagConstraints();
            gridBagConstraints.gridx = 0;
            gridBagConstraints.gridy = 0;
            gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
            gridBagConstraints.weightx = 0.1;
            gridBagConstraints.weighty = 0.2;
            gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
            panel.add(lab1, gridBagConstraints);
            JSONArray jarr = ((JSONObject) js.get(i)).getJSONArray("opciones");
            for (int j = 0; j < jarr.length(); j++) {
                JLabel lab2 = new JLabel("Opcin " + (j + 1) + ": " + jarr.getString(j), JLabel.CENTER);
                lab2.setFont(new Font("Roboto", 1, 15));
                lab2.setForeground(new Color(0, 0, 0));
                gridBagConstraints = new java.awt.GridBagConstraints();
                gridBagConstraints.gridx = 0;
                gridBagConstraints.gridy = j + 1;
                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
                gridBagConstraints.weightx = 0.1;
                gridBagConstraints.weighty = 0.1;
                gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
                panel.add(lab2, gridBagConstraints);
            }

            JPanel panelRelleno = new JPanel(new BorderLayout(20, 20));
            panelRelleno.setBackground(Color.white);
            gridBagConstraints = new GridBagConstraints();
            gridBagConstraints.gridx = 0;
            gridBagConstraints.gridy = jarr.length() + 1;
            gridBagConstraints.fill = GridBagConstraints.BOTH;
            gridBagConstraints.weightx = 0.1;
            gridBagConstraints.weighty = 0.9;
            gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
            panel.add(panelRelleno, gridBagConstraints);
        } catch (JSONException ex) {
            Logger.getLogger(AnalistaLocal.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    cardsPreguntas.show(panelPreguntas, "Pregunta " + 1);
}

From source file:gov.nih.nci.nbia.StandaloneDMV3.java

/**
 * Create the panel.//from   ww w  .j av a  2  s .c  o m
 */
private JPanel createloginPanelV2() {
    JPanel contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(36, 36, 36, 36));
    contentPane.setLayout(null);

    JPanel loginUserPanel = new JPanel();
    loginUserPanel.setBounds(40, 91, 825, 306);
    contentPane.add(loginUserPanel);
    loginUserPanel
            .setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, new Color(153, 180, 209), null),
                    "", TitledBorder.CENTER, TitledBorder.TOP, null, new Color(0, 120, 215)));
    loginUserPanel.setLayout(null);

    JLabel lblNewLabel_1 = new JLabel("User Name");
    lblNewLabel_1.setBounds(70, 80, 118, 36);
    loginUserPanel.add(lblNewLabel_1);

    JButton submitBtn = new JButton(SubmitBtnLbl);
    submitBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            userId = userNameFld.getText();
            password = passwdFld.getText();
            if ((userId.length() < 1) || (password.length() < 1)) {
                setStatus(statusLbl, "Please enter a valid user name and password.", Color.red);
            } else {
                setStatus(statusLbl, "Checking your access permission...", Color.blue);
                SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        submitRequest(userId, password);
                    }
                });
            }
        }
    });
    submitBtn.setBounds(606, 238, 140, 36);
    loginUserPanel.add(submitBtn);

    userNameFld = new JTextField();
    userNameFld.setBounds(200, 80, 333, 36);
    loginUserPanel.add(userNameFld);
    userNameFld.setColumns(10);

    JLabel lblPassword = new JLabel("Password");
    lblPassword.setBounds(70, 156, 118, 36);
    loginUserPanel.add(lblPassword);

    passwdFld = new JPasswordField();
    passwdFld.setBounds(200, 156, 333, 36);
    loginUserPanel.add(passwdFld);

    statusLbl = new JLabel("");
    statusLbl.setBounds(70, 226, 524, 36);
    statusLbl.setFont(new Font("SansSerif", Font.PLAIN, 13));
    statusLbl.setVerticalAlignment(SwingConstants.BOTTOM);
    loginUserPanel.add(statusLbl);

    JLabel versionLabel = new JLabel("Release " + DownloaderProperties.getAppVersion() + " Build \""
            + DownloaderProperties.getBuildTime() + "\"");
    versionLabel.setHorizontalAlignment(SwingConstants.CENTER);
    versionLabel.setForeground(new Color(70, 130, 180));
    versionLabel.setBounds(318, 427, 266, 20);
    contentPane.add(versionLabel);

    JLabel infoLbl = new JLabel(
            "This download contains restricted data. Log in or contact the help desk for access.");
    infoLbl.setForeground(new Color(105, 105, 105));
    infoLbl.setFont(new Font("SansSerif", Font.BOLD, 13));
    infoLbl.setBounds(40, 34, 796, 42);
    contentPane.add(infoLbl);

    JLabel helpDeskLbl;

    helpDeskLbl = new JLabel();
    ImageIcon image = new ImageIcon(this.getClass().getClassLoader().getResource("info.png"));
    helpDeskLbl = new JLabel(image);
    helpDeskLbl.setToolTipText("Click to get phone number/email address of the Help Desk.");
    helpDeskLbl.setBounds(826, 20, 36, 36);
    contentPane.add(helpDeskLbl);

    helpDeskLbl.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            System.out.println("mouse clicked");
            //BrowserLauncher.openUrl(DownloaderProperties.getHelpDeskUrl());
            BrowserLauncher.openUrlForHelpDesk();
        }

    });

    userNameFld.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            passwdFld.requestFocus();
        }
    });

    userNameFld.addFocusListener(new FocusListener() {

        @Override
        public void focusGained(FocusEvent e) {
            statusLbl.setText("");
        }

        @Override
        public void focusLost(FocusEvent e) {
        }
    });

    passwdFld.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            userId = userNameFld.getText();
            password = passwdFld.getText();
            if ((userId.length() < 1) || (password.length() < 1)) {
                setStatus(statusLbl, "Please enter a valid user name and password.", Color.red);
            } else {
                setStatus(statusLbl, "Checking your access permission...", Color.blue);
                SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        submitRequest(userId, password);
                    }
                });
            }
        }
    });

    passwdFld.addFocusListener(new FocusListener() {

        @Override
        public void focusGained(FocusEvent e) {
            statusLbl.setText("");
        }

        @Override
        public void focusLost(FocusEvent e) {
        }
    });

    return contentPane;
}

From source file:sim.util.media.chart.ChartGenerator.java

/** Generates a new ChartGenerator with a blank chart.  Before anything else, buildChart() is called.  */
public ChartGenerator() {
    // create the chart
    buildChart();//from w ww  .j av a  2 s. c om
    chart.getPlot().setBackgroundPaint(Color.WHITE);
    chart.setAntiAlias(true);

    JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true);
    split.setBorder(new EmptyBorder(0, 0, 0, 0));
    JScrollPane scroll = new JScrollPane();
    JPanel b = new JPanel();
    b.setLayout(new BorderLayout());
    b.add(seriesAttributes, BorderLayout.NORTH);
    b.add(new JPanel(), BorderLayout.CENTER);
    scroll.getViewport().setView(b);
    scroll.setBackground(getBackground());
    scroll.getViewport().setBackground(getBackground());
    JPanel p = new JPanel();
    p.setLayout(new BorderLayout());

    LabelledList list = new LabelledList("Chart Properties");
    DisclosurePanel pan1 = new DisclosurePanel("Chart Properties", list);
    globalAttributes.add(pan1);

    JLabel j = new JLabel("Right-Click or Control-Click");
    j.setFont(j.getFont().deriveFont(10.0f).deriveFont(java.awt.Font.ITALIC));
    list.add(j);
    j = new JLabel("on Chart for More Options");
    j.setFont(j.getFont().deriveFont(10.0f).deriveFont(java.awt.Font.ITALIC));
    list.add(j);

    titleField = new PropertyField() {
        public String newValue(String newValue) {
            setTitle(newValue);
            getChartPanel().repaint();
            return newValue;
        }
    };
    titleField.setValue(chart.getTitle().getText());

    list.add(new JLabel("Title"), titleField);

    buildGlobalAttributes(list);

    final JCheckBox legendCheck = new JCheckBox();
    ItemListener il = new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                LegendTitle title = new LegendTitle(chart.getPlot());
                title.setLegendItemGraphicPadding(new org.jfree.ui.RectangleInsets(0, 8, 0, 4));
                chart.addLegend(title);
            } else {
                chart.removeLegend();
            }
        }
    };
    legendCheck.addItemListener(il);
    list.add(new JLabel("Legend"), legendCheck);
    legendCheck.setSelected(true);

    /*
      final JCheckBox aliasCheck = new JCheckBox();
      aliasCheck.setSelected(chart.getAntiAlias());
      il = new ItemListener()
      {
      public void itemStateChanged(ItemEvent e)
      {
      chart.setAntiAlias( e.getStateChange() == ItemEvent.SELECTED );
      }
      };
      aliasCheck.addItemListener(il);
      list.add(new JLabel("Antialias"), aliasCheck);
    */

    JPanel pdfButtonPanel = new JPanel();
    pdfButtonPanel.setBorder(new javax.swing.border.TitledBorder("Chart Output"));
    DisclosurePanel pan2 = new DisclosurePanel("Chart Output", pdfButtonPanel);

    pdfButtonPanel.setLayout(new BorderLayout());
    Box pdfbox = new Box(BoxLayout.Y_AXIS);
    pdfButtonPanel.add(pdfbox, BorderLayout.WEST);

    JButton pdfButton = new JButton("Save as PDF");
    pdfbox.add(pdfButton);
    pdfButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            FileDialog fd = new FileDialog(frame, "Choose PDF file...", FileDialog.SAVE);
            fd.setFile(chart.getTitle().getText() + ".pdf");
            fd.setVisible(true);
            String fileName = fd.getFile();
            if (fileName != null) {
                Dimension dim = chartPanel.getPreferredSize();
                PDFEncoder.generatePDF(chart, dim.width, dim.height,
                        new File(fd.getDirectory(), Utilities.ensureFileEndsWith(fd.getFile(), ".pdf")));
            }
        }
    });
    movieButton = new JButton("Create a Movie");
    pdfbox.add(movieButton);
    pdfbox.add(Box.createGlue());
    movieButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (movieMaker == null)
                startMovie();
            else
                stopMovie();
        }
    });

    globalAttributes.add(pan2);

    // we add into an outer box so we can later on add more global seriesAttributes
    // as the user instructs and still have glue be last
    Box outerAttributes = Box.createVerticalBox();
    outerAttributes.add(globalAttributes);
    outerAttributes.add(Box.createGlue());

    p.add(outerAttributes, BorderLayout.NORTH);
    p.add(scroll, BorderLayout.CENTER);
    p.setMinimumSize(new Dimension(0, 0));
    p.setPreferredSize(new Dimension(200, 0));
    split.setLeftComponent(p);

    // Add scale and proportion fields
    Box header = Box.createHorizontalBox();

    final double MAXIMUM_SCALE = 8;

    fixBox = new JCheckBox("Fill");
    fixBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            setFixed(fixBox.isSelected());
        }
    });
    header.add(fixBox);
    fixBox.setSelected(true);

    // add the scale field
    scaleField = new NumberTextField("  Scale: ", 1.0, true) {
        public double newValue(double newValue) {
            if (newValue <= 0.0)
                newValue = currentValue;
            if (newValue > MAXIMUM_SCALE)
                newValue = currentValue;
            scale = newValue;
            resizeChart();
            return newValue;
        }
    };
    scaleField.setToolTipText("Zoom in and out");
    scaleField.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 2));
    scaleField.setEnabled(false);
    scaleField.setText("");
    header.add(scaleField);

    // add the proportion field
    proportionField = new NumberTextField("  Proportion: ", 1.5, true) {
        public double newValue(double newValue) {
            if (newValue <= 0.0)
                newValue = currentValue;
            proportion = newValue;
            resizeChart();
            return newValue;
        }
    };
    proportionField.setToolTipText("Change the chart proportions (ratio of width to height)");
    proportionField.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 2));
    header.add(proportionField);

    chartHolder.setMinimumSize(new Dimension(0, 0));
    chartHolder.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    chartHolder.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    chartHolder.getViewport().setBackground(Color.gray);
    JPanel p2 = new JPanel();
    p2.setLayout(new BorderLayout());
    p2.add(chartHolder, BorderLayout.CENTER);
    p2.add(header, BorderLayout.NORTH);
    split.setRightComponent(p2);
    setLayout(new BorderLayout());
    add(split, BorderLayout.CENTER);

    // set the default to be white, which looks good when printed
    chart.setBackgroundPaint(Color.WHITE);

    // JFreeChart has a hillariously broken way of handling font scaling.
    // It allows fonts to scale independently in X and Y.  We hack a workaround here.
    chartPanel.setMinimumDrawHeight((int) DEFAULT_CHART_HEIGHT);
    chartPanel.setMaximumDrawHeight((int) DEFAULT_CHART_HEIGHT);
    chartPanel.setMinimumDrawWidth((int) (DEFAULT_CHART_HEIGHT * proportion));
    chartPanel.setMaximumDrawWidth((int) (DEFAULT_CHART_HEIGHT * proportion));
    chartPanel.setPreferredSize(new java.awt.Dimension((int) (DEFAULT_CHART_HEIGHT * DEFAULT_CHART_PROPORTION),
            (int) (DEFAULT_CHART_HEIGHT)));
}

From source file:com.juanhg.pattern.PatternApplet.java

private void autogeneratedCode() {
    JPanel panel_control = new JPanel();
    panel_control.setBorder(new CompoundBorder(new EtchedBorder(EtchedBorder.RAISED, null, null),
            new BevelBorder(BevelBorder.RAISED, null, null, null, null)));

    JPanel panelInputs = new JPanel();
    panelInputs.setToolTipText("");
    panelInputs.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0)));

    JPanel panelOutputs = new JPanel();
    panelOutputs.setToolTipText("");
    panelOutputs.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0)));

    JPanel panelTitleOutputs = new JPanel();
    panelTitleOutputs.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null));

    JLabel labelOutputData = new JLabel("Datos de la Simulaci\u00F3n");
    labelOutputData.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panelTitleOutputs.add(labelOutputData);

    lblO1 = new JLabel("O1:");
    lblO1.setFont(new Font("Tahoma", Font.PLAIN, 14));

    lblO1Value = new JLabel();
    lblO1Value.setText("0");
    lblO1Value.setFont(new Font("Tahoma", Font.PLAIN, 14));

    JLabel lblO2 = new JLabel("O2:");
    lblO2.setFont(new Font("Tahoma", Font.PLAIN, 14));

    lblO2Value = new JLabel();
    lblO2Value.setText("0");
    lblO2Value.setFont(new Font("Tahoma", Font.PLAIN, 14));

    lblO3 = new JLabel("O3:");
    lblO3.setFont(new Font("Tahoma", Font.PLAIN, 14));

    lblO3Value = new JLabel();
    lblO3Value.setText("0");
    lblO3Value.setFont(new Font("Tahoma", Font.PLAIN, 14));

    GroupLayout gl_panelOutputs = new GroupLayout(panelOutputs);
    gl_panelOutputs.setHorizontalGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING)
            .addComponent(panelTitleOutputs, GroupLayout.DEFAULT_SIZE, 344, Short.MAX_VALUE)
            .addGroup(gl_panelOutputs.createSequentialGroup().addGap(22).addGroup(gl_panelOutputs
                    .createParallelGroup(Alignment.LEADING)
                    .addGroup(gl_panelOutputs.createSequentialGroup()
                            .addComponent(lblO3, GroupLayout.PREFERRED_SIZE, 84, GroupLayout.PREFERRED_SIZE)
                            .addGap(26)/*  www  .  j  a  v  a 2s .  co  m*/
                            .addComponent(lblO3Value, GroupLayout.DEFAULT_SIZE, 103, Short.MAX_VALUE))
                    .addGroup(gl_panelOutputs.createSequentialGroup()
                            .addGroup(gl_panelOutputs.createParallelGroup(Alignment.TRAILING)
                                    .addGroup(gl_panelOutputs.createSequentialGroup()
                                            .addComponent(lblO1, GroupLayout.DEFAULT_SIZE,
                                                    GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addGap(26))
                                    .addGroup(gl_panelOutputs.createSequentialGroup()
                                            .addComponent(lblO2, GroupLayout.PREFERRED_SIZE, 81,
                                                    GroupLayout.PREFERRED_SIZE)
                                            .addGap(29)))
                            .addGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING, false)
                                    .addComponent(lblO2Value, GroupLayout.DEFAULT_SIZE,
                                            GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(lblO1Value, GroupLayout.PREFERRED_SIZE, 103,
                                            GroupLayout.PREFERRED_SIZE))))
                    .addGap(109)));
    gl_panelOutputs
            .setVerticalGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING)
                    .addGroup(gl_panelOutputs.createSequentialGroup()
                            .addComponent(panelTitleOutputs, GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(ComponentPlacement.UNRELATED)
                            .addGroup(gl_panelOutputs.createParallelGroup(Alignment.BASELINE)
                                    .addComponent(lblO1Value).addComponent(lblO1))
                            .addPreferredGap(ComponentPlacement.UNRELATED)
                            .addGroup(gl_panelOutputs.createParallelGroup(Alignment.BASELINE)
                                    .addComponent(lblO2, GroupLayout.PREFERRED_SIZE, 17,
                                            GroupLayout.PREFERRED_SIZE)
                                    .addComponent(lblO2Value, GroupLayout.PREFERRED_SIZE, 17,
                                            GroupLayout.PREFERRED_SIZE))
                            .addPreferredGap(ComponentPlacement.UNRELATED)
                            .addGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING)
                                    .addComponent(lblO3, GroupLayout.PREFERRED_SIZE, 17,
                                            GroupLayout.PREFERRED_SIZE)
                                    .addComponent(lblO3Value, GroupLayout.PREFERRED_SIZE, 17,
                                            GroupLayout.PREFERRED_SIZE))
                            .addGap(79)));
    panelOutputs.setLayout(gl_panelOutputs);

    JPanel panelLicense = new JPanel();
    panelLicense.setBorder(new LineBorder(new Color(0, 0, 0)));

    JPanel panel_6 = new JPanel();
    panel_6.setBorder(new LineBorder(new Color(0, 0, 0)));
    GroupLayout gl_panel_control = new GroupLayout(panel_control);
    gl_panel_control.setHorizontalGroup(gl_panel_control.createParallelGroup(Alignment.TRAILING)
            .addGroup(gl_panel_control.createSequentialGroup().addContainerGap().addGroup(gl_panel_control
                    .createParallelGroup(Alignment.LEADING)
                    .addComponent(panelInputs, GroupLayout.PREFERRED_SIZE, 346, Short.MAX_VALUE)
                    .addComponent(panelOutputs, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(panel_6, Alignment.TRAILING, GroupLayout.PREFERRED_SIZE, 346, Short.MAX_VALUE)
                    .addComponent(panelLicense, GroupLayout.DEFAULT_SIZE, 346, Short.MAX_VALUE))
                    .addContainerGap()));
    gl_panel_control.setVerticalGroup(gl_panel_control.createParallelGroup(Alignment.TRAILING)
            .addGroup(gl_panel_control.createSequentialGroup().addContainerGap()
                    .addComponent(panelInputs, GroupLayout.PREFERRED_SIZE, 213, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addComponent(panelOutputs, GroupLayout.PREFERRED_SIZE, 129, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addComponent(panel_6, GroupLayout.PREFERRED_SIZE, 146, Short.MAX_VALUE)
                    .addPreferredGap(ComponentPlacement.RELATED).addComponent(panelLicense,
                            GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                    .addGap(24)));

    btnLaunchSimulation = new JButton("Iniciar");
    btnLaunchSimulation.setFont(new Font("Tahoma", Font.PLAIN, 16));
    btnLaunchSimulation.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            btnLaunchSimulationEvent(event);
        }
    });
    GroupLayout gl_panel_6 = new GroupLayout(panel_6);
    gl_panel_6.setHorizontalGroup(gl_panel_6.createParallelGroup(Alignment.TRAILING).addGroup(Alignment.LEADING,
            gl_panel_6.createSequentialGroup().addContainerGap()
                    .addComponent(btnLaunchSimulation, GroupLayout.DEFAULT_SIZE, 324, Short.MAX_VALUE)
                    .addContainerGap()));
    gl_panel_6.setVerticalGroup(gl_panel_6.createParallelGroup(Alignment.TRAILING).addGroup(Alignment.LEADING,
            gl_panel_6.createSequentialGroup().addGap(80)
                    .addComponent(btnLaunchSimulation, GroupLayout.PREFERRED_SIZE, 55,
                            GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
    panel_6.setLayout(gl_panel_6);

    JLabel lblNewLabel = new JLabel("GNU GENERAL PUBLIC LICENSE");
    panelLicense.add(lblNewLabel);

    JLabel LabelI1 = new JLabel("I1");
    LabelI1.setFont(new Font("Tahoma", Font.PLAIN, 14));

    JLabel labelI2 = new JLabel("I2");
    labelI2.setFont(new Font("Tahoma", Font.PLAIN, 14));

    JLabel labelI3 = new JLabel("I3");
    labelI3.setFont(new Font("Tahoma", Font.PLAIN, 14));

    JPanel panelTitle = new JPanel();
    panelTitle.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null));

    lblI2Value = new JLabel("5");
    lblI2Value.setFont(new Font("Tahoma", Font.PLAIN, 14));

    lblI3Value = new JLabel("5");
    lblI3Value.setFont(new Font("Tahoma", Font.PLAIN, 14));

    lblI1Value = new JLabel("5");
    lblI1Value.setFont(new Font("Tahoma", Font.PLAIN, 14));

    sliderI1 = new JSlider();
    sliderI1.setMaximum(10);
    sliderI1.setMinorTickSpacing(1);
    sliderI1.setValue(5);
    sliderI1.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent event) {
            sliderI1Event();
        }
    });

    sliderI2 = new JSlider();
    sliderI2.setMaximum(10);
    sliderI2.setMinorTickSpacing(1);
    sliderI2.setValue(5);
    sliderI2.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            sliderI2Event();
        }
    });

    sliderI3 = new JSlider();
    sliderI3.setMaximum(10);
    sliderI3.setValue(5);
    sliderI3.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            sliderI3Event();
        }
    });

    JLabel lblI4 = new JLabel("I4");
    lblI4.setFont(new Font("Tahoma", Font.PLAIN, 14));

    lblI4Value = new JLabel("5");
    lblI4Value.setFont(new Font("Tahoma", Font.PLAIN, 14));

    sliderI4 = new JSlider();
    sliderI4.setMaximum(10);
    sliderI4.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent arg0) {
            sliderI4Event();
        }
    });
    sliderI4.setValue(5);
    sliderI4.setMinorTickSpacing(1);

    JLabel lblI5 = new JLabel("I5");
    lblI5.setFont(new Font("Tahoma", Font.PLAIN, 14));

    lblI5Value = new JLabel("5");
    lblI5Value.setFont(new Font("Tahoma", Font.PLAIN, 14));

    sliderI5 = new JSlider();
    sliderI5.setMaximum(10);
    sliderI5.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            sliderI5Event();
        }
    });
    sliderI5.setValue(5);
    sliderI5.setMinorTickSpacing(1);

    GroupLayout gl_panelInputs = new GroupLayout(panelInputs);
    gl_panelInputs.setHorizontalGroup(gl_panelInputs.createParallelGroup(Alignment.TRAILING)
            .addGroup(gl_panelInputs.createSequentialGroup().addGroup(gl_panelInputs
                    .createParallelGroup(Alignment.LEADING)
                    .addGroup(gl_panelInputs.createSequentialGroup()
                            .addGroup(gl_panelInputs.createParallelGroup(Alignment.TRAILING, false)
                                    .addComponent(labelI3, Alignment.LEADING, GroupLayout.DEFAULT_SIZE,
                                            GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(LabelI1, Alignment.LEADING, GroupLayout.DEFAULT_SIZE,
                                            GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(labelI2, Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 120,
                                            GroupLayout.PREFERRED_SIZE))
                            .addGap(18)
                            .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING)
                                    .addComponent(lblI1Value, GroupLayout.PREFERRED_SIZE, 42,
                                            GroupLayout.PREFERRED_SIZE)
                                    .addComponent(lblI2Value, GroupLayout.PREFERRED_SIZE, 56,
                                            GroupLayout.PREFERRED_SIZE)
                                    .addComponent(lblI3Value, GroupLayout.PREFERRED_SIZE, 56,
                                            GroupLayout.PREFERRED_SIZE))
                            .addGap(18)
                            .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING, false)
                                    .addComponent(sliderI1, 0, 0, Short.MAX_VALUE)
                                    .addComponent(sliderI2, 0, 0, Short.MAX_VALUE).addComponent(
                                            sliderI3, GroupLayout.PREFERRED_SIZE, 88,
                                            GroupLayout.PREFERRED_SIZE)))
                    .addGroup(gl_panelInputs.createSequentialGroup()
                            .addComponent(lblI4, GroupLayout.PREFERRED_SIZE, 120, GroupLayout.PREFERRED_SIZE)
                            .addGap(18)
                            .addComponent(lblI4Value, GroupLayout.PREFERRED_SIZE, 56,
                                    GroupLayout.PREFERRED_SIZE)
                            .addGap(18)
                            .addComponent(sliderI4, GroupLayout.PREFERRED_SIZE, 88, GroupLayout.PREFERRED_SIZE))
                    .addGroup(gl_panelInputs.createSequentialGroup()
                            .addComponent(lblI5, GroupLayout.PREFERRED_SIZE, 120, GroupLayout.PREFERRED_SIZE)
                            .addGap(18)
                            .addComponent(lblI5Value, GroupLayout.PREFERRED_SIZE, 56,
                                    GroupLayout.PREFERRED_SIZE)
                            .addGap(18).addComponent(sliderI5, GroupLayout.PREFERRED_SIZE, 88,
                                    GroupLayout.PREFERRED_SIZE)))
                    .addGap(19))
            .addComponent(panelTitle, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 352, Short.MAX_VALUE));
    gl_panelInputs.setVerticalGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING)
            .addGroup(gl_panelInputs.createSequentialGroup()
                    .addComponent(panelTitle, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addGap(18)
                    .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING)
                            .addGroup(gl_panelInputs.createParallelGroup(Alignment.BASELINE)
                                    .addComponent(LabelI1).addComponent(lblI1Value, GroupLayout.PREFERRED_SIZE,
                                            17, GroupLayout.PREFERRED_SIZE))
                            .addComponent(sliderI1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING)
                            .addGroup(gl_panelInputs.createParallelGroup(Alignment.BASELINE)
                                    .addComponent(labelI2).addComponent(lblI2Value, GroupLayout.PREFERRED_SIZE,
                                            17, GroupLayout.PREFERRED_SIZE))
                            .addComponent(sliderI2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE))
                    .addGap(11)
                    .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING).addComponent(labelI3)
                            .addComponent(lblI3Value, GroupLayout.PREFERRED_SIZE, 17,
                                    GroupLayout.PREFERRED_SIZE)
                            .addComponent(sliderI3, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(ComponentPlacement.UNRELATED)
                    .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING)
                            .addComponent(lblI4, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblI4Value, GroupLayout.PREFERRED_SIZE, 17,
                                    GroupLayout.PREFERRED_SIZE)
                            .addComponent(sliderI4, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(ComponentPlacement.UNRELATED)
                    .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING)
                            .addComponent(lblI5, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblI5Value, GroupLayout.PREFERRED_SIZE, 17,
                                    GroupLayout.PREFERRED_SIZE)
                            .addComponent(sliderI5, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE))
                    .addGap(429)));

    JLabel lblDatosDeEntrada = new JLabel("Datos de Entrada");
    lblDatosDeEntrada.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panelTitle.add(lblDatosDeEntrada);
    panelInputs.setLayout(gl_panelInputs);
    panel_control.setLayout(gl_panel_control);

    JPanel panel_visualizar = new JPanel();
    panel_visualizar.setBackground(Color.WHITE);

    GroupLayout groupLayout = new GroupLayout(getContentPane());
    groupLayout.setHorizontalGroup(groupLayout.createParallelGroup(Alignment.LEADING)
            .addGroup(groupLayout.createSequentialGroup().addContainerGap()
                    .addComponent(panel_control, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(panel_visualizar, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addContainerGap()));
    groupLayout.setVerticalGroup(groupLayout.createParallelGroup(Alignment.TRAILING).addGroup(groupLayout
            .createSequentialGroup()
            .addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
                    .addGroup(groupLayout.createSequentialGroup().addContainerGap().addComponent(panel_control,
                            GroupLayout.PREFERRED_SIZE, 568, GroupLayout.PREFERRED_SIZE))
                    .addGroup(groupLayout.createSequentialGroup().addGap(12).addComponent(panel_visualizar,
                            GroupLayout.DEFAULT_SIZE, 567, Short.MAX_VALUE)))
            .addContainerGap()));
    GroupLayout gl_panel_visualizar = new GroupLayout(panel_visualizar);
    gl_panel_visualizar.setHorizontalGroup(
            gl_panel_visualizar.createParallelGroup(Alignment.LEADING).addGap(0, 845, Short.MAX_VALUE));
    gl_panel_visualizar.setVerticalGroup(
            gl_panel_visualizar.createParallelGroup(Alignment.LEADING).addGap(0, 567, Short.MAX_VALUE));

    panel_visualizar.setLayout(gl_panel_visualizar);

    getContentPane().setLayout(groupLayout);
}

From source file:com.isencia.passerelle.hmi.generic.GenericHMI.java

private JPanel createTitlePanel(final String name) {
    final JPanel result = new JPanel(new BorderLayout());
    final ImageIcon icon = new ImageIcon(Toolkit.getDefaultToolkit()
            .getImage(getClass().getResource("/com/isencia/passerelle/hmi/resources/param.gif")));
    final JLabel startLabel = new JLabel(icon);
    result.add(startLabel, BorderLayout.LINE_START);

    final JLabel nameLabel = new JLabel(name);
    final Font f = nameLabel.getFont();
    nameLabel.setFont(new Font(f.getName(), f.getStyle(), f.getSize() + 2));
    nameLabel.setForeground(new Color(49, 106, 196));
    result.add(nameLabel);//ww w.j  a va2 s .  c o m

    return result;
}

From source file:edu.gmu.cs.sim.util.media.chart.ChartGenerator.java

/** Generates a new ChartGenerator with a blank chart.  Before anything else, buildChart() is called.  */
public ChartGenerator() {
    // create the chart
    buildChart();/*from   ww  w .  j  a  va 2s  .  c om*/
    chart.getPlot().setBackgroundPaint(Color.WHITE);
    chart.setAntiAlias(true);

    JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true);
    split.setBorder(new EmptyBorder(0, 0, 0, 0));
    JScrollPane scroll = new JScrollPane();
    JPanel b = new JPanel();
    b.setLayout(new BorderLayout());
    b.add(seriesAttributes, BorderLayout.NORTH);
    b.add(new JPanel(), BorderLayout.CENTER);
    scroll.getViewport().setView(b);
    scroll.setBackground(getBackground());
    scroll.getViewport().setBackground(getBackground());
    JPanel p = new JPanel();
    p.setLayout(new BorderLayout());

    LabelledList list = new LabelledList("Chart Properties");
    DisclosurePanel pan1 = new DisclosurePanel("Chart Properties", list);
    globalAttributes.add(pan1);

    JLabel j = new JLabel("Right-Click or Control-Click");
    j.setFont(j.getFont().deriveFont(10.0f).deriveFont(java.awt.Font.ITALIC));
    list.add(j);
    j = new JLabel("on Chart for More Options");
    j.setFont(j.getFont().deriveFont(10.0f).deriveFont(java.awt.Font.ITALIC));
    list.add(j);

    titleField = new PropertyField() {
        public String newValue(String newValue) {
            setTitle(newValue);
            getChartPanel().repaint();
            return newValue;
        }
    };
    titleField.setValue(chart.getTitle().getText());

    list.add(new JLabel("Title"), titleField);

    buildGlobalAttributes(list);

    final JCheckBox legendCheck = new JCheckBox();
    ItemListener il = new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                LegendTitle title = new LegendTitle(chart.getPlot());
                title.setLegendItemGraphicPadding(new org.jfree.ui.RectangleInsets(0, 8, 0, 4));
                chart.addLegend(title);
            } else {
                chart.removeLegend();
            }
        }
    };
    legendCheck.addItemListener(il);
    list.add(new JLabel("Legend"), legendCheck);
    legendCheck.setSelected(true);

    /*
      final JCheckBox aliasCheck = new JCheckBox();
      aliasCheck.setSelected(chart.getAntiAlias());
      il = new ItemListener()
      {
      public void itemStateChanged(ItemEvent e)
      {
      chart.setAntiAlias( e.getStateChange() == ItemEvent.SELECTED );
      }
      };
      aliasCheck.addItemListener(il);
      list.add(new JLabel("Antialias"), aliasCheck);
    */

    JPanel pdfButtonPanel = new JPanel();
    pdfButtonPanel.setBorder(new javax.swing.border.TitledBorder("Chart Output"));
    DisclosurePanel pan2 = new DisclosurePanel("Chart Output", pdfButtonPanel);

    pdfButtonPanel.setLayout(new BorderLayout());
    Box pdfbox = new Box(BoxLayout.Y_AXIS);
    pdfButtonPanel.add(pdfbox, BorderLayout.WEST);

    JButton pdfButton = new JButton("Save as PDF");
    pdfbox.add(pdfButton);
    pdfButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            FileDialog fd = new FileDialog(frame, "Choose PDF file...", FileDialog.SAVE);
            fd.setFile(chart.getTitle().getText() + ".pdf");
            fd.setVisible(true);
            String fileName = fd.getFile();
            if (fileName != null) {
                Dimension dim = chartPanel.getPreferredSize();
                PDFEncoder.generatePDF(chart, dim.width, dim.height,
                        new File(fd.getDirectory(), Utilities.ensureFileEndsWith(fd.getFile(), ".pdf")));
            }
        }
    });
    movieButton = new JButton("Create a Movie");
    pdfbox.add(movieButton);
    pdfbox.add(Box.createGlue());
    movieButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (movieMaker == null) {
                startMovie();
            } else {
                stopMovie();
            }
        }
    });

    globalAttributes.add(pan2);

    // we add into an outer box so we can later on add more global seriesAttributes
    // as the user instructs and still have glue be last
    Box outerAttributes = Box.createVerticalBox();
    outerAttributes.add(globalAttributes);
    outerAttributes.add(Box.createGlue());

    p.add(outerAttributes, BorderLayout.NORTH);
    p.add(scroll, BorderLayout.CENTER);
    p.setMinimumSize(new Dimension(0, 0));
    p.setPreferredSize(new Dimension(200, 0));
    split.setLeftComponent(p);

    // Add scale and proportion fields
    Box header = Box.createHorizontalBox();

    final double MAXIMUM_SCALE = 8;

    fixBox = new JCheckBox("Fill");
    fixBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            setFixed(fixBox.isSelected());
        }
    });
    header.add(fixBox);
    fixBox.setSelected(true);

    // add the scale field
    scaleField = new NumberTextField("  Scale: ", 1.0, true) {
        public double newValue(double newValue) {
            if (newValue <= 0.0) {
                newValue = currentValue;
            }
            if (newValue > MAXIMUM_SCALE) {
                newValue = currentValue;
            }
            scale = newValue;
            resizeChart();
            return newValue;
        }
    };
    scaleField.setToolTipText("Zoom in and out");
    scaleField.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 2));
    scaleField.setEnabled(false);
    scaleField.setText("");
    header.add(scaleField);

    // add the proportion field
    proportionField = new NumberTextField("  Proportion: ", 1.5, true) {
        public double newValue(double newValue) {
            if (newValue <= 0.0) {
                newValue = currentValue;
            }
            proportion = newValue;
            resizeChart();
            return newValue;
        }
    };
    proportionField.setToolTipText("Change the chart proportions (ratio of width to height)");
    proportionField.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 2));
    header.add(proportionField);

    chartHolder.setMinimumSize(new Dimension(0, 0));
    chartHolder.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    chartHolder.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    chartHolder.getViewport().setBackground(Color.gray);
    JPanel p2 = new JPanel();
    p2.setLayout(new BorderLayout());
    p2.add(chartHolder, BorderLayout.CENTER);
    p2.add(header, BorderLayout.NORTH);
    split.setRightComponent(p2);
    setLayout(new BorderLayout());
    add(split, BorderLayout.CENTER);

    // set the default to be white, which looks good when printed
    chart.setBackgroundPaint(Color.WHITE);

    // JFreeChart has a hillariously broken way of handling font scaling.
    // It allows fonts to scale independently in X and Y.  We hack a workaround here.
    chartPanel.setMinimumDrawHeight((int) DEFAULT_CHART_HEIGHT);
    chartPanel.setMaximumDrawHeight((int) DEFAULT_CHART_HEIGHT);
    chartPanel.setMinimumDrawWidth((int) (DEFAULT_CHART_HEIGHT * proportion));
    chartPanel.setMaximumDrawWidth((int) (DEFAULT_CHART_HEIGHT * proportion));
    chartPanel.setPreferredSize(new java.awt.Dimension((int) (DEFAULT_CHART_HEIGHT * DEFAULT_CHART_PROPORTION),
            (int) (DEFAULT_CHART_HEIGHT)));
}

From source file:com.atlassian.theplugin.idea.jira.IssueCreateDialog.java

/**
 * Method generated by IntelliJ IDEA GUI Designer
 * >>> IMPORTANT!! <<<
 * DO NOT edit this method OR call it in your code!
 *
 * @noinspection ALL/*  w ww.j  a  v a2  s.com*/
 */
private void $$$setupUI$$$() {
    mainPanel = new JPanel();
    mainPanel.setLayout(new GridLayoutManager(10, 3, new Insets(5, 5, 5, 5), -1, -1));
    mainPanel.setMinimumSize(new Dimension(480, 500));
    final JScrollPane scrollPane1 = new JScrollPane();
    mainPanel.add(scrollPane1,
            new GridConstraints(7, 1, 2, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null,
                    null, 0, false));
    description = new JTextArea();
    description.setLineWrap(true);
    description.setWrapStyleWord(true);
    scrollPane1.setViewportView(description);
    final JLabel label1 = new JLabel();
    label1.setText("Summary:");
    mainPanel.add(label1,
            new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE,
                    GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0,
                    false));
    final JLabel label2 = new JLabel();
    label2.setText("Project:");
    mainPanel.add(label2,
            new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE,
                    GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0,
                    false));
    projectComboBox = new JComboBox();
    mainPanel.add(projectComboBox,
            new GridConstraints(0, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW,
                    GridConstraints.SIZEPOLICY_FIXED, new Dimension(100, -1), null, null, 0, false));
    summary = new JTextField();
    mainPanel.add(summary,
            new GridConstraints(6, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW,
                    GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(100, -1), null, 0, false));
    final JLabel label3 = new JLabel();
    label3.setText("Description:");
    mainPanel.add(label3,
            new GridConstraints(7, 0, 1, 1, GridConstraints.ANCHOR_NORTHEAST, GridConstraints.FILL_NONE,
                    GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0,
                    false));
    final JLabel label4 = new JLabel();
    label4.setText("Assignee:");
    mainPanel.add(label4,
            new GridConstraints(9, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE,
                    GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0,
                    false));
    final JLabel label5 = new JLabel();
    label5.setFont(new Font(label5.getFont().getName(), label5.getFont().getStyle(), 10));
    label5.setHorizontalTextPosition(10);
    label5.setText("Warning! This field is not validated prior to sending to JIRA");
    mainPanel.add(label5,
            new GridConstraints(9, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW,
                    GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    final JLabel label6 = new JLabel();
    label6.setText("Type:");
    mainPanel.add(label6,
            new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE,
                    GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0,
                    false));
    typeComboBox = new JComboBox();
    mainPanel.add(typeComboBox,
            new GridConstraints(1, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW,
                    GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    final JLabel label7 = new JLabel();
    label7.setText("Priority:");
    mainPanel.add(label7,
            new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE,
                    GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0,
                    false));
    priorityComboBox = new JComboBox();
    mainPanel.add(priorityComboBox,
            new GridConstraints(5, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW,
                    GridConstraints.SIZEPOLICY_FIXED, new Dimension(100, -1), null, null, 0, false));
    final JLabel label8 = new JLabel();
    label8.setText("Component/s:");
    mainPanel.add(label8,
            new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_NORTHEAST, GridConstraints.FILL_NONE,
                    GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0,
                    false));
    final JScrollPane scrollPane2 = new JScrollPane();
    mainPanel.add(scrollPane2,
            new GridConstraints(2, 1, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW,
                    GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    componentsList = new JList();
    componentsList.setToolTipText("Select Affected Components ");
    componentsList.setVisibleRowCount(5);
    scrollPane2.setViewportView(componentsList);
    final JLabel label9 = new JLabel();
    label9.setText("Affects Version/s:");
    mainPanel.add(label9,
            new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_NORTHWEST, GridConstraints.FILL_NONE,
                    GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0,
                    false));
    final JScrollPane scrollPane3 = new JScrollPane();
    mainPanel.add(scrollPane3,
            new GridConstraints(3, 1, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null,
                    null, 0, false));
    versionsList = new JList();
    versionsList.setVisibleRowCount(5);
    scrollPane3.setViewportView(versionsList);
    final JScrollPane scrollPane4 = new JScrollPane();
    mainPanel.add(scrollPane4,
            new GridConstraints(4, 1, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null,
                    null, 0, false));
    fixVersionsList = new JList();
    fixVersionsList.setVisible(true);
    fixVersionsList.setVisibleRowCount(5);
    scrollPane4.setViewportView(fixVersionsList);
    final JLabel label10 = new JLabel();
    label10.setText("Fix Version/s:");
    mainPanel.add(label10,
            new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_NORTHEAST, GridConstraints.FILL_NONE,
                    GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0,
                    false));
    label1.setLabelFor(summary);
    label2.setLabelFor(projectComboBox);
    label3.setLabelFor(description);
    label6.setLabelFor(typeComboBox);
}

From source file:diet.gridr.g5k.gui.ClusterInfoPanel.java

/**
 * This method initializes jPanel2//from   w  w w . j ava  2s  .c o m
 *
 * @return javax.swing.JPanel
 */
private JPanel getJPanel2() {
    if (jPanel2 == null) {
        jPanel2 = new JPanel();
        jPanel2.setLayout(new BoxLayout(jPanel2, BoxLayout.Y_AXIS));
        jPanel2.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
        jobsTable = new JTable();
        jobsModel = new ClusterJobsSummaryModel();
        jobsTable.setModel(jobsModel);
        ClusterJobsSummaryCellRenderer renderer = new ClusterJobsSummaryCellRenderer();
        jobsTable.setDefaultRenderer(String.class, renderer);
        //jobsTable.createDefaultColumnsFromModel();
        JLabel jobsTableTitle = new JLabel("Jobs status");
        jobsTableTitle.setAlignmentX(JLabel.CENTER_ALIGNMENT);
        jobsTableTitle.setFont(new Font("Dialog", Font.BOLD, 14));
        jPanel2.add(Box.createVerticalStrut(5));
        jPanel2.add(jobsTableTitle);
        jPanel2.add(Box.createVerticalStrut(10));
        jPanel2.add(jobsTable.getTableHeader());
        jPanel2.add(jobsTable);
        LoggingManager.log(Level.FINER, LoggingManager.RESOURCESTOOL, this.getClass().getName(), "getJPanel2",
                "Cluster jobs summary table added");
    }
    return jPanel2;
}