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:be.ac.ua.comp.scarletnebula.gui.ServerCellRenderer.java

private JLabel getTagComponent(final Server server, final Color foreground) {
    final JLabel tags = new JLabel();

    final Font tagFont = new Font(tags.getFont().getName(), Font.PLAIN, 11);
    tags.setFont(tagFont);
    tags.setText(Utils.implode(new ArrayList<String>(server.getTags()), ", "));
    tags.setForeground(foreground);/*  w w  w. j a  v a 2s .  c o m*/
    return tags;
}

From source file:com.game.ui.views.CharachterEditorPanel.java

public void doGui() {
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    JLabel noteLbl = new JLabel("Pls select a value to choose an enemy or you can create a new "
            + "Enemy entity below. Once selected an Enemy character, its' details will be available below");
    noteLbl.setAlignmentX(0);/*ww  w  .ja  v  a2s .co m*/
    //        noteLbl.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    add(noteLbl);
    DefaultComboBoxModel model = new DefaultComboBoxModel();
    for (GameCharacter character : GameBean.enemyDetails) {
        System.out.println(character.getName());
        model.addElement(character.getName());
    }
    comboBox = new JComboBox(model);
    comboBox.setSelectedIndex(-1);
    comboBox.setMaximumSize(new Dimension(100, 30));
    comboBox.setAlignmentX(0);
    comboBox.setActionCommand("dropDown");
    comboBox.addActionListener(this);
    add(Box.createVerticalStrut(10));
    add(comboBox);
    add(Box.createVerticalStrut(10));
    JPanel panel1 = new JPanel();
    panel1.setAlignmentX(0);
    panel1.setBorder(LineBorder.createGrayLineBorder());
    panel1.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.WEST;
    c.insets = new Insets(5, 5, 5, 5);
    c.weightx = 1;
    c.weighty = 1;
    c.gridwidth = 2;
    JLabel enemyDtlLbl = new JLabel("Enemy Character Details : ");
    enemyDtlLbl.setFont(new Font("Times New Roman", Font.BOLD, 15));
    panel1.add(enemyDtlLbl, c);
    c.gridwidth = 1;
    c.gridy = 1;
    JLabel nameLbl = new JLabel("Name : ");
    panel1.add(nameLbl, c);
    c.gridx = 1;
    JTextField name = new JTextField("");
    name.setColumns(20);
    panel1.add(name, c);
    c.gridx = 0;
    c.gridy = 2;
    JLabel imageLbl = new JLabel("Image Path : ");
    panel1.add(imageLbl, c);
    c.gridx = 1;
    JTextField image = new JTextField("");
    image.setColumns(20);
    panel1.add(image, c);
    c.gridx = 0;
    c.gridy = 3;
    JLabel healthLbl = new JLabel("Health Pts : ");
    panel1.add(healthLbl, c);
    c.gridx = 1;
    JTextField health = new JTextField("");
    health.setColumns(20);
    panel1.add(health, c);
    c.gridx = 0;
    c.gridy = 4;
    JLabel attackPtsLbl = new JLabel("Attack Points : ");
    panel1.add(attackPtsLbl, c);
    c.gridx = 1;
    JTextField attackPts = new JTextField("");
    attackPts.setColumns(20);
    panel1.add(attackPts, c);
    c.gridx = 0;
    c.gridy = 5;
    JLabel armoursPtsLbl = new JLabel("Armour Points : ");
    panel1.add(armoursPtsLbl, c);
    c.gridx = 1;
    JTextField armourPts = new JTextField("");
    armourPts.setColumns(20);
    panel1.add(armourPts, c);
    c.gridx = 0;
    c.gridy = 6;
    JLabel attackRngeLbl = new JLabel("Attack Range : ");
    panel1.add(attackRngeLbl, c);
    c.gridx = 1;
    JTextField attackRnge = new JTextField("");
    attackRnge.setColumns(20);
    panel1.add(attackRnge, c);
    c.gridx = 0;
    c.gridy = 7;
    JLabel movementLbl = new JLabel("Movement : ");
    panel1.add(movementLbl, c);
    c.gridx = 1;
    JTextField movement = new JTextField("");
    movement.setColumns(20);
    panel1.add(movement, c);
    c.gridx = 0;
    c.gridy = 8;
    c.gridwidth = 2;
    JButton submit = new JButton("Save");
    submit.addActionListener(this);
    submit.setActionCommand("button");
    panel1.add(submit, c);
    add(panel1);
    c.gridx = 0;
    c.gridy = 9;
    JLabel validationMess = new JLabel("Pls enter all the fields or pls choose a character from the drop down");
    validationMess.setForeground(Color.red);
    validationMess.setVisible(false);
    add(validationMess, c);
    add(Box.createVerticalGlue());
}

From source file:cn.edu.tsinghua.gui.HistogramDemo.java

/**
 * Initialize display./* ww  w  .  j  a v a  2s.co m*/
 * @author Sun Microsystems
 * @param filename is the image filename
 */
public HistogramDemo(String filename) {
    File f = new File(filename);

    if (f.exists() && f.canRead()) {
        source = JAI.create("fileload", filename);
    } else {
        return;
    }

    canvas = new ImageDisplay(source);
    canvas.setLayout(new FlowLayout(FlowLayout.RIGHT, 2, 2));

    panner = new Panner(canvas, source, 128);
    panner.setBackground(Color.red);
    panner.setBorder(new EtchedBorder());
    canvas.add(panner);

    Font font = new Font("SansSerif", Font.BOLD, 12);
    JLabel title = new JLabel(" Histogram");
    title.setFont(font);
    title.setLocation(0, 32);

    setOpaque(true);
    setLayout(new BorderLayout());
    setBackground(Color.white);

    graph = new XYPlot();
    graph.setBackground(Color.black);
    graph.setBorder(new LineBorder(new Color(0, 0, 255), 1));

    Colorbar cbar = new Colorbar();
    cbar.setBackground(Color.black);
    cbar.setPreferredSize(new Dimension(256, 25));
    cbar.setBorder(new LineBorder(new Color(255, 0, 255), 2));

    JPanel hist_panel = new JPanel();
    hist_panel.setLayout(new BorderLayout());
    hist_panel.setBackground(Color.white);
    hist_panel.add(graph, BorderLayout.CENTER);
    hist_panel.add(cbar, BorderLayout.SOUTH);

    JPanel panel = new JPanel();
    panel.setLayout(new GridLayout(2, 1, 5, 5));
    panel.setBackground(Color.white);
    panel.add(canvas);
    panel.add(hist_panel);

    JPanel controlPanel = new JPanel();
    controlPanel.setLayout(new FlowLayout());

    reset = new JButton("Reset");
    equal = new JButton("Uniform");
    norm = new JButton("Gaussian");
    piece = new JButton("Piecewise");

    reset.addActionListener(this);
    equal.addActionListener(this);
    norm.addActionListener(this);
    piece.addActionListener(this);

    controlPanel.add(reset);
    controlPanel.add(equal);
    controlPanel.add(norm);
    controlPanel.add(piece);

    add(title, BorderLayout.NORTH);
    add(panel, BorderLayout.CENTER);
    add(controlPanel, BorderLayout.SOUTH);

    // original histogram (remains unmodified)
    // graph.plot( getHistogram(source) );
    graph.plot(getMultiHistogram(source));
}

From source file:net.sf.firemox.ui.wizard.About.java

/**
 * Creates a new instance of About <br>
 * //  ww w.j  a  va2s. c  o m
 * @param parent
 */
public About(JFrame parent) {
    super(LanguageManager.getString("wiz_about.title"), LanguageManager.getString("wiz_about.description"),
            "mp64.gif", LanguageManager.getString("close"), 420, 620);
    JPanel thanksPanel = new JPanel();

    thanksPanel.setLayout(new BoxLayout(thanksPanel, BoxLayout.X_AXIS));
    thanksPanel.setMaximumSize(new Dimension(32767, 26));
    thanksPanel.setOpaque(false);
    JLabel jLabel5 = new JLabel(LanguageManager.getString("version") + " : ");
    jLabel5.setFont(MToolKit.defaultFont);
    jLabel5.setHorizontalAlignment(SwingConstants.RIGHT);
    jLabel5.setMaximumSize(new Dimension(100, 16));
    jLabel5.setMinimumSize(new Dimension(100, 16));
    jLabel5.setPreferredSize(new Dimension(100, 16));
    thanksPanel.add(jLabel5);
    jLabel5 = new JLabel(IdConst.VERSION);
    thanksPanel.add(jLabel5);
    gameParamPanel.add(thanksPanel);

    thanksPanel = new JPanel();
    thanksPanel.setLayout(new BoxLayout(thanksPanel, BoxLayout.X_AXIS));
    thanksPanel.setOpaque(false);
    JPanel thanksPanelLeft = new JPanel(new FlowLayout(FlowLayout.LEADING));
    thanksPanelLeft.setLayout(new BoxLayout(thanksPanelLeft, BoxLayout.Y_AXIS));
    thanksPanelLeft.setMaximumSize(new Dimension(100, 2000));
    thanksPanelLeft.setMinimumSize(new Dimension(100, 16));
    jLabel5 = new JLabel(LanguageManager.getString("thanks") + " : ");
    jLabel5.setFont(MToolKit.defaultFont);
    jLabel5.setHorizontalAlignment(SwingConstants.RIGHT);
    jLabel5.setMaximumSize(new Dimension(100, 16));
    jLabel5.setMinimumSize(new Dimension(100, 16));
    jLabel5.setPreferredSize(new Dimension(100, 16));
    thanksPanelLeft.add(jLabel5);
    thanksPanel.add(thanksPanelLeft);
    thanksPanelLeft = new JPanel();
    thanksPanelLeft.setLayout(new BoxLayout(thanksPanelLeft, BoxLayout.Y_AXIS));
    StringBuilder contributors = new StringBuilder();
    addContributor(contributors, "Fabrice Daugan", "developper", "france");
    addContributor(contributors, "Hoani Cross", "developper", "frenchpolynesia");
    addContributor(contributors, "nico100", "graphist", "france");
    addContributor(contributors, "seingalt_tm", "graphist", "france");
    addContributor(contributors, "surtur2", "tester", null);
    addContributor(contributors, "Jan Blaha", "developper", "cz");
    addContributor(contributors, "Tureba", "developper", "brazil");
    addContributor(contributors, "hakvf", "tester", "france");
    addContributor(contributors, "Stefano \"Kismet\" Lenzi", "developper", "italian");
    jLabel5 = new JLabel(contributors.toString());
    jLabel5.setFont(MToolKit.defaultFont);
    jLabel5.setHorizontalAlignment(SwingConstants.LEFT);
    thanksPanelLeft.add(jLabel5);
    jLabel5 = new JLink("http://obsidiurne.free.fr", "morgil has designed the splash screen");
    jLabel5.setFont(MToolKit.defaultFont);
    thanksPanelLeft.add(jLabel5);
    thanksPanel.add(thanksPanelLeft);

    gameParamPanel.add(thanksPanel);

    thanksPanel = new JPanel();
    thanksPanel.setLayout(new BoxLayout(thanksPanel, BoxLayout.X_AXIS));
    thanksPanel.setMaximumSize(new Dimension(32767, 26));
    thanksPanel.setOpaque(false);
    JLabel blanklbl = new JLabel();
    blanklbl.setHorizontalAlignment(SwingConstants.RIGHT);
    blanklbl.setMaximumSize(new Dimension(100, 16));
    blanklbl.setMinimumSize(new Dimension(100, 16));
    blanklbl.setPreferredSize(new Dimension(100, 16));
    thanksPanel.add(blanklbl);

    jLabel5 = new JLink(
            "http://sourceforge.net/tracker/?func=add&group_id=" + IdConst.PROJECT_ID + "&atid=601043",
            LanguageManager.getString("joindev"));
    jLabel5.setFont(MToolKit.defaultFont);
    thanksPanel.add(jLabel5);
    gameParamPanel.add(thanksPanel);

    thanksPanel = new JPanel();
    thanksPanel.setLayout(new BoxLayout(thanksPanel, BoxLayout.X_AXIS));
    thanksPanel.setOpaque(false);
    jLabel5 = new JLabel(LanguageManager.getString("projecthome") + " : ");
    jLabel5.setFont(MToolKit.defaultFont);
    jLabel5.setHorizontalAlignment(SwingConstants.RIGHT);
    jLabel5.setMaximumSize(new Dimension(100, 16));
    jLabel5.setMinimumSize(new Dimension(100, 16));
    jLabel5.setPreferredSize(new Dimension(100, 16));
    thanksPanel.add(jLabel5);
    jLabel5 = new JLink(IdConst.MAIN_PAGE, IdConst.MAIN_PAGE);
    jLabel5.setFont(MToolKit.defaultFont);
    thanksPanel.add(jLabel5);
    gameParamPanel.add(thanksPanel);

    // forum francais
    thanksPanel = new JPanel();
    thanksPanel.setLayout(new BoxLayout(thanksPanel, BoxLayout.X_AXIS));
    thanksPanel.setOpaque(false);
    jLabel5 = new JLabel(LanguageManager.getString("othersites") + " : ");
    jLabel5.setFont(MToolKit.defaultFont);
    jLabel5.setHorizontalAlignment(SwingConstants.RIGHT);
    jLabel5.setMaximumSize(new Dimension(100, 16));
    jLabel5.setMinimumSize(new Dimension(100, 16));
    jLabel5.setPreferredSize(new Dimension(100, 16));
    thanksPanel.add(jLabel5);
    jLabel5 = new JLink("http://www.Firemox.fr.st", UIHelper.getIcon("mpfrsml.gif"), SwingConstants.LEFT);
    jLabel5.setToolTipText(LanguageManager.getString("frenchforum.tooltip"));
    thanksPanel.add(jLabel5);
    jLabel5 = new JLabel();
    jLabel5.setMaximumSize(new Dimension(1000, 16));
    thanksPanel.add(jLabel5);
    gameParamPanel.add(thanksPanel);

    JTextArea disclaimer = new JTextArea();
    disclaimer.setEditable(false);
    disclaimer.setLineWrap(true);
    disclaimer.setWrapStyleWord(true);
    disclaimer.setAutoscrolls(true);
    disclaimer.setTabSize(2);
    disclaimer.setFont(new Font("Arial", 0, 10));
    // Then try and read it locally
    BufferedReader inGPL = null;
    try {
        inGPL = new BufferedReader(new InputStreamReader(MToolKit.getResourceAsStream(IdConst.FILE_LICENSE)));
        disclaimer.read(inGPL, "");
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        IOUtils.closeQuietly(inGPL);
    }
    JScrollPane disclaimerSPanel = new JScrollPane();
    disclaimerSPanel.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    MToolKit.addOverlay(disclaimerSPanel);
    disclaimerSPanel.setViewportView(disclaimer);
    gameParamPanel.add(disclaimerSPanel);
}

From source file:net.phyloviz.project.action.LoadDataSetAction.java

private JDialog createLoadingDialog() {
    JDialog d = new JDialog(WindowManager.getDefault().getMainWindow(), null, true);
    d.setLayout(new GridBagLayout());
    JPanel panel = new JPanel();
    JLabel jlabel = new JLabel("Loading DataSet.....");
    jlabel.setFont(new Font("Verdana", 1, 14));
    panel.add(jlabel);/* ww w. j av a2 s  . co m*/
    d.add(panel, new GridBagConstraints());
    d.setSize(200, 50);
    d.setLocationRelativeTo(null);
    d.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
    return d;
}

From source file:com.codedx.burp.security.InvalidCertificateDialogStrategy.java

@Override
public CertificateAcceptance checkAcceptance(Certificate genericCert, CertificateException certError) {
    if (genericCert instanceof X509Certificate && defaultHostVerifier instanceof DefaultHostnameVerifier) {
        X509Certificate cert = (X509Certificate) genericCert;
        DefaultHostnameVerifier verifier = (DefaultHostnameVerifier) defaultHostVerifier;

        JPanel message = new JPanel(new GridBagLayout());
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.gridwidth = 2;//from  w w  w  . j  av a 2s  .  co  m
        gbc.insets = new Insets(0, 0, 10, 0);
        gbc.anchor = GridBagConstraints.WEST;
        message.add(
                new JLabel("Unable to establish a secure connection because the certificate is not trusted"),
                gbc);

        gbc = new GridBagConstraints();
        gbc.gridy = 2;
        gbc.insets = new Insets(2, 0, 2, 0);
        gbc.anchor = GridBagConstraints.WEST;

        JLabel issuer = new JLabel("Issuer: ");
        Font defaultFont = issuer.getFont();
        Font bold = new Font(defaultFont.getName(), Font.BOLD, defaultFont.getSize());
        issuer.setFont(bold);

        message.add(issuer, gbc);
        gbc.gridx = 1;
        message.add(new JLabel(cert.getIssuerDN().toString()), gbc);

        try {
            JLabel fingerprint = new JLabel("Thumbprint: ");
            fingerprint.setFont(bold);
            gbc.gridx = 0;
            gbc.gridy += 1;
            message.add(fingerprint, gbc);

            gbc.gridx = 1;
            message.add(new JLabel(toHexString(getSHA1(cert.getEncoded()), " ")), gbc);
        } catch (CertificateEncodingException e) {
            // this shouldn't actually ever happen
        }

        try {
            verifier.verify(host, cert);
        } catch (SSLException e) {
            String cn = getCN(cert);

            JLabel mismatch = new JLabel("Host Mismatch: ");
            mismatch.setFont(bold);
            gbc.gridx = 0;
            gbc.gridy += 1;
            message.add(mismatch, gbc);

            String msg;
            if (cn != null) {
                msg = String.format("Expected '%s', but the certificate is for '%s'.", host, cn);
            } else {
                msg = e.getMessage();
            }

            gbc.gridx = 1;
            message.add(new JLabel(msg), gbc);
        }

        // Open the dialog, and return its result
        int choice = JOptionPane.showOptionDialog(burpExtender.getUiComponent(), message, dialogTitle,
                JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, dialogButtons, null);
        switch (choice) {
        case (0):
            return CertificateAcceptance.REJECT;
        case (1):
            return CertificateAcceptance.ACCEPT_TEMPORARILY;
        case (2):
            return CertificateAcceptance.ACCEPT_PERMANENTLY;
        }
    }
    return CertificateAcceptance.REJECT;
}

From source file:com.hp.alm.ali.idea.content.settings.SettingsPanel.java

public SettingsPanel(final Project prj, Color bgColor) {
    this.prj = prj;
    this.projectConf = prj.getComponent(AliProjectConfiguration.class);

    previewAndConnection = new JPanel(new GridBagLayout());
    previewAndConnection.setOpaque(false);
    GridBagConstraints c2 = new GridBagConstraints();
    c2.gridx = 0;/* www .  j a  va  2s  . c o  m*/
    c2.gridy = 1;
    c2.gridwidth = 2;
    c2.weighty = 1;
    c2.fill = GridBagConstraints.VERTICAL;
    JPanel filler = new JPanel();
    filler.setOpaque(false);
    previewAndConnection.add(filler, c2);

    passwordPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    passwordPanel.setBackground(bgColor);
    JLabel label = new JLabel("Password");
    label.setFont(label.getFont().deriveFont(Font.BOLD));
    passwordPanel.add(label);
    final JPasswordField password = new JPasswordField(24);
    passwordPanel.add(password);
    JButton connect = new JButton("Login");
    passwordPanel.add(connect);
    final JLabel message = new JLabel();
    passwordPanel.add(message);
    ActionListener connectionAction = new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            try {
                checkConnection(projectConf.getLocation(), projectConf.getDomain(), projectConf.getProject(),
                        projectConf.getUsername(), password.getText());
            } catch (AuthenticationFailed e) {
                message.setText(e.getMessage());
                return;
            }
            projectConf.ALM_PASSWORD = password.getText();
            projectConf.fireChanged();
        }
    };
    password.addActionListener(connectionAction);
    connect.addActionListener(connectionAction);

    restService = prj.getComponent(RestService.class);
    restService.addServerTypeListener(this);

    location = createTextPane(bgColor);
    domain = createTextPane(bgColor);
    project = createTextPane(bgColor);
    username = createTextPane(bgColor);

    final JPanel panel = new JPanel(new BorderLayout());
    panel.setBackground(bgColor);
    panel.setBorder(new EmptyBorder(10, 10, 10, 10));

    final JTextPane textPane = new JTextPane();
    textPane.setEditorKit(new HTMLEditorKit());
    textPane.setText(
            "<html><body>HP ALM integration can be configured on <a href=\"ide\">IDE</a> and overridden on <a href=\"project\">project</a> level.</body></html>");
    textPane.setEditable(false);
    textPane.addHyperlinkListener(this);
    textPane.setBackground(bgColor);
    textPane.setCaret(new NonAdjustingCaret());
    panel.add(textPane, BorderLayout.CENTER);

    JPanel content = new JPanel(new BorderLayout());
    content.setBackground(bgColor);
    content.add(panel, BorderLayout.NORTH);
    content.add(previewAndConnection, BorderLayout.WEST);

    preview = new JPanel(new GridBagLayout()) {
        public Dimension getPreferredSize() {
            Dimension dim = super.getPreferredSize();
            // make enough room for the connection status message
            dim.width = Math.max(dim.width, 300);
            return dim;
        }

        public Dimension getMinimumSize() {
            return getPreferredSize();
        }
    };
    connectedTo(restService.getServerTypeIfAvailable());
    preview.setBackground(bgColor);

    final GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1;
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 2;
    c.anchor = GridBagConstraints.WEST;
    preview.add(location, c);
    c.gridwidth = 1;
    c.gridy++;
    preview.add(domain, c);
    c.gridy++;
    preview.add(project, c);
    c.gridy++;
    preview.add(username, c);
    c.gridx++;
    c.gridy--;
    c.gridheight = 2;
    c.weightx = 0;
    c.anchor = GridBagConstraints.SOUTHEAST;
    final LinkLabel reload = new LinkLabel("Reload", IconLoader.getIcon("/actions/sync.png"));
    reload.setListener(new LinkListener() {
        public void linkSelected(LinkLabel linkLabel, Object o) {
            projectConf.fireChanged();
        }
    }, null);
    preview.add(reload, c);

    JPanel previewNorth = new JPanel(new BorderLayout());
    previewNorth.setBackground(bgColor);
    previewNorth.add(preview, BorderLayout.NORTH);

    addToGridBagPanel(0, 0, previewAndConnection, previewNorth);

    setBackground(bgColor);
    setLayout(new BorderLayout());
    add(content, BorderLayout.CENTER);

    onChanged();
    ApplicationManager.getApplication().getComponent(AliConfiguration.class).addListener(this);
    projectConf.addListener(this);
}

From source file:be.ac.ua.comp.scarletnebula.gui.ServerCellRenderer.java

private Component getNewServerServer(final JList list, final int index, final boolean isSelected) {
    final JPanel p = createServerPanel(null, list, index, isSelected);
    final JLabel label = new JLabel("Start a new server",
            new ImageIcon(getClass().getResource("/images/add.png")), SwingConstants.LEFT);
    label.setFont(new Font(label.getFont().getName(), Font.PLAIN, 16));
    // Border for better horizontal alignment
    label.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 12));
    p.add(label);//from   w w  w.  j  av  a 2s .  com

    return p;
}

From source file:com.github.alexfalappa.nbspringboot.projects.initializr.BootDependenciesPanel.java

public void init(JsonNode metaData) {
    JsonNode depArray = metaData.path("dependencies").path("values");
    final int nodeNum = depArray.size();
    // remove informative label
    if (nodeNum > 0) {
        this.remove(lNotInitialized);
    }/*from   w  ww .  j  a v  a 2  s .com*/
    // prepare dependencies checkboxes
    for (int i = 0; i < nodeNum; i++) {
        JsonNode gn = depArray.get(i);
        final String groupName = gn.path("name").asText();
        // group label
        JLabel lGroup = new JLabel(groupName);
        lGroup.setFont(lGroup.getFont().deriveFont(Font.BOLD, lGroup.getFont().getSize() + 2));
        grpLabels.add(lGroup);
        this.add(lGroup, constraintsForGroupLabel(i == 0));
        // starter checkboxes in two columns
        final JsonNode valArray = gn.path("values");
        for (int j = 0; j < valArray.size(); j++) {
            // first column
            JsonNode dn = valArray.get(j);
            this.add(checkBoxForNode(groupName, dn), constraintsForFirstColumnCheckbox());
            // second column (optional)
            if (++j < valArray.size()) {
                dn = valArray.get(j);
                this.add(checkBoxForNode(groupName, dn), constraintsForSecondColumnCheckbox());
            }
        }
    }
    initialized = true;
    // force recompute of increments
    unitIncrement = null;
    blockIncrement = null;
}

From source file:org.gdms.usm.view.ProgressFrame.java

public ProgressFrame(Step s, boolean modifyThresholds) {
    super("Progress");
    simulation = s;/*from  w w w  .j  a v a 2 s  . c o  m*/
    s.registerStepListener(this);
    stepSeconds = new LinkedList<Integer>();

    s.getManager().setModifyThresholds(modifyThresholds);
    s.getManager().setAdvisor(this);

    JPanel statusPanel = new JPanel(new BorderLayout());
    JPanel globalPanel = new JPanel(new SpringLayout());

    //Time elapsed panel
    JPanel timePanel = new JPanel(new BorderLayout(5, 5));
    final JLabel timeLabel = new JLabel("00:00:00", SwingConstants.CENTER);
    timeLabel.setFont(new Font("Serif", Font.BOLD, 45));
    timePanel.add(timeLabel, BorderLayout.SOUTH);
    JLabel elapsed = new JLabel("Time Elapsed :", SwingConstants.CENTER);
    timePanel.add(elapsed, BorderLayout.NORTH);
    statusPanel.add(timePanel, BorderLayout.NORTH);

    ActionListener timerListener = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            totalSeconds++;
            int hours = totalSeconds / 3600;
            String hourss;
            if (hours < 10) {
                hourss = "0" + hours;
            } else {
                hourss = "" + hours;
            }
            int minutes = (totalSeconds % 3600) / 60;
            String minutess;
            if (minutes < 10) {
                minutess = "0" + minutes;
            } else {
                minutess = "" + minutes;
            }
            int seconds = totalSeconds % 60;
            String secondss;
            if (seconds < 10) {
                secondss = "0" + seconds;
            } else {
                secondss = seconds + "";
            }
            timeLabel.setText(hourss + ":" + minutess + ":" + secondss);
        }
    };
    timer = new Timer(1000, timerListener);
    timer.start();

    //Turn progress panel
    JPanel turnPanel = new JPanel(new BorderLayout(5, 5));
    JLabel turnLabel = new JLabel("Current Step :", SwingConstants.CENTER);
    turnPanel.add(turnLabel, BorderLayout.NORTH);
    currentTurn = new JLabel("Init", SwingConstants.CENTER);
    currentTurn.setFont(new Font("Serif", Font.BOLD, 30));
    turnPanel.add(currentTurn, BorderLayout.SOUTH);
    globalPanel.add(turnPanel);

    //Movers panel
    JPanel moversPanel = new JPanel(new BorderLayout(5, 5));
    JLabel moversLabel = new JLabel("Last movers count :", SwingConstants.CENTER);
    moversPanel.add(moversLabel, BorderLayout.NORTH);
    lastMoversCount = new JLabel("Init", SwingConstants.CENTER);
    lastMoversCount.setFont(new Font("Serif", Font.BOLD, 30));
    moversPanel.add(lastMoversCount, BorderLayout.SOUTH);
    globalPanel.add(moversPanel);

    //Initial population panel
    JPanel initPopPanel = new JPanel(new BorderLayout(5, 5));
    JLabel initialPopulationLabel = new JLabel("Initial population :", SwingConstants.CENTER);
    initPopPanel.add(initialPopulationLabel, BorderLayout.NORTH);
    initialPopulationCount = new JLabel("Init", SwingConstants.CENTER);
    initialPopulationCount.setFont(new Font("Serif", Font.BOLD, 30));
    initPopPanel.add(initialPopulationCount, BorderLayout.SOUTH);
    globalPanel.add(initPopPanel);

    //Current population panel
    JPanel curPopPanel = new JPanel(new BorderLayout(5, 5));
    JLabel currentPopulationLabel = new JLabel("Current population :", SwingConstants.CENTER);
    curPopPanel.add(currentPopulationLabel, BorderLayout.NORTH);
    currentPopulation = new JLabel("Init", SwingConstants.CENTER);
    currentPopulation.setFont(new Font("Serif", Font.BOLD, 30));
    curPopPanel.add(currentPopulation, BorderLayout.SOUTH);
    globalPanel.add(curPopPanel);

    //Dead panel
    JPanel deadPanel = new JPanel(new BorderLayout(5, 5));
    JLabel deadLabel = new JLabel("Last death toll :", SwingConstants.CENTER);
    deadPanel.add(deadLabel, BorderLayout.NORTH);
    lastDeathToll = new JLabel("Init", SwingConstants.CENTER);
    lastDeathToll.setFont(new Font("Serif", Font.BOLD, 30));
    deadPanel.add(lastDeathToll, BorderLayout.SOUTH);
    globalPanel.add(deadPanel);

    //Newborn panel
    JPanel newbornPanel = new JPanel(new BorderLayout(5, 5));
    JLabel newbornLabel = new JLabel("Last newborn count :", SwingConstants.CENTER);
    newbornPanel.add(newbornLabel, BorderLayout.NORTH);
    lastNewbornCount = new JLabel("Init", SwingConstants.CENTER);
    lastNewbornCount.setFont(new Font("Serif", Font.BOLD, 30));
    newbornPanel.add(lastNewbornCount, BorderLayout.SOUTH);
    globalPanel.add(newbornPanel);

    SpringUtilities.makeCompactGrid(globalPanel, 3, 2, 5, 5, 20, 10);
    statusPanel.add(globalPanel, BorderLayout.SOUTH);

    add(statusPanel, BorderLayout.WEST);

    //Graph tabbed pane
    JTabbedPane tabbedPane = new JTabbedPane();
    timeChart = new XYSeries("Step time", true, false);
    tabbedPane.addTab("Step time", createChartPanel("Step time", timeChart));
    currentPopulationChart = new XYSeries("Population", true, false);
    tabbedPane.addTab("Population", createChartPanel("Population", currentPopulationChart));
    deathTollChart = new XYSeries("Deaths", true, false);
    tabbedPane.addTab("Deaths", createChartPanel("Deaths", deathTollChart));
    newbornCountChart = new XYSeries("Newborn", true, false);
    tabbedPane.addTab("Newborn", createChartPanel("Newborn", newbornCountChart));
    moversCountChart = new XYSeries("Movers", true, false);
    tabbedPane.addTab("Movers", createChartPanel("Movers", moversCountChart));
    add(tabbedPane, BorderLayout.EAST);

    getRootPane().setBorder(BorderFactory.createEmptyBorder(10, 20, 10, 10));
    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    pack();
    setLocationRelativeTo(null);
    setVisible(true);
}