Example usage for javax.swing JPanel getFont

List of usage examples for javax.swing JPanel getFont

Introduction

In this page you can find the example usage for javax.swing JPanel getFont.

Prototype

@Transient
public Font getFont() 

Source Link

Document

Gets the font of this component.

Usage

From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositPresenterTest.java

@Test
public final void testFormUtilities() {
    JFrame frame = new JFrame();
    Font theFont = new Font("Arial", Font.BOLD, 14);
    javax.swing.JMenuBar mnuMain = new JMenuBar();
    JMenu menu1 = new JMenu();
    JMenuItem menu1_1 = new JMenuItem();
    JMenuItem menu1_2 = new JMenuItem();
    JMenuItem menu1_3 = new JMenuItem();
    menu1.add(menu1_1);/*from   w  w w .  jav  a2s . c o  m*/
    menu1.add(menu1_2);
    menu1.add(menu1_3);
    JMenu menu2 = new JMenu();
    JMenuItem menu2_1 = new JMenuItem();
    JMenuItem menu2_2 = new JMenuItem();
    JMenuItem menu2_3 = new JMenuItem();
    menu1.add(menu2_1);
    menu1.add(menu2_2);
    menu1.add(menu2_3);
    JMenu menu3 = new JMenu();
    JMenuItem menu3_1 = new JMenuItem();
    JMenuItem menu3_2 = new JMenuItem();
    JMenuItem menu3_3 = new JMenuItem();
    menu1.add(menu3_1);
    menu1.add(menu3_2);
    menu1.add(menu3_3);
    frame.setJMenuBar(mnuMain);
    mnuMain.add(menu1);
    mnuMain.add(menu2);
    mnuMain.add(menu3);

    JPanel pnlTest = new JPanel();
    pnlTest.setBorder(javax.swing.BorderFactory.createTitledBorder("Test Border"));
    frame.add(pnlTest);
    JLabel label1 = new JLabel();
    JTextField text1 = new JTextField();
    pnlTest.add(label1);
    pnlTest.add(text1);
    JLabel label2 = new JLabel();
    JTextField text2 = new JTextField();
    frame.add(label2);
    frame.add(text2);

    assertFalse(menu1.getFont().equals(theFont));
    assertFalse(menu2.getFont().equals(theFont));
    assertFalse(menu3.getFont().equals(theFont));
    assertFalse(menu1_1.getFont().equals(theFont));
    assertFalse(menu1_2.getFont().equals(theFont));
    assertFalse(menu1_3.getFont().equals(theFont));
    assertFalse(menu2_1.getFont().equals(theFont));
    assertFalse(menu2_2.getFont().equals(theFont));
    assertFalse(menu2_3.getFont().equals(theFont));
    assertFalse(menu3_1.getFont().equals(theFont));
    assertFalse(menu3_2.getFont().equals(theFont));
    assertFalse(menu3_3.getFont().equals(theFont));
    assertFalse(pnlTest.getFont().equals(theFont));
    assertFalse(label1.getFont().equals(theFont));
    assertFalse(label2.getFont().equals(theFont));
    assertFalse(text1.getFont().equals(theFont));
    assertFalse(text2.getFont().equals(theFont));

    FormUtilities.setFormFont(frame, theFont);

    assertTrue(menu1.getFont().equals(theFont));
    assertTrue(menu2.getFont().equals(theFont));
    assertTrue(menu3.getFont().equals(theFont));
    assertTrue(menu1_1.getFont().equals(theFont));
    assertTrue(menu1_2.getFont().equals(theFont));
    assertTrue(menu1_3.getFont().equals(theFont));
    assertTrue(menu2_1.getFont().equals(theFont));
    assertTrue(menu2_2.getFont().equals(theFont));
    assertTrue(menu2_3.getFont().equals(theFont));
    assertTrue(menu3_1.getFont().equals(theFont));
    assertTrue(menu3_2.getFont().equals(theFont));
    assertTrue(menu3_3.getFont().equals(theFont));
    assertTrue(pnlTest.getFont().equals(theFont));
    assertTrue(label1.getFont().equals(theFont));
    assertTrue(label2.getFont().equals(theFont));
    assertTrue(text1.getFont().equals(theFont));
    assertTrue(text2.getFont().equals(theFont));
}

From source file:org.ut.biolab.medsavant.client.view.genetics.variantinfo.OtherIndividualsGeneSubInspector.java

@Override
protected JPanel getIndividualSummaryPanel(String dnaID) {
    JPanel outerPanel = new JPanel();
    outerPanel.setLayout(new BoxLayout(outerPanel, BoxLayout.Y_AXIS));

    //dnaIDVariantMap.get(DNAId) -- all variants within gene corresponding to individual
    Set<VariantRecord> variantRecords = getVariantRecords(dnaID);

    Map<Long, Set<VariantRecord>> positionVariantMap = new TreeMap<Long, Set<VariantRecord>>();
    for (VariantRecord variantRecord : variantRecords) {
        //Get all variants at that overlap at that position, regardless of individual.
        Set<VariantRecord> variantsAtPosition = positionVariantMap.get(variantRecord.getStartPosition());
        if (variantsAtPosition == null) {
            variantsAtPosition = new HashSet<VariantRecord>();
        }//from  ww  w  .  jav a2  s .  c  o m
        variantsAtPosition.add(variantRecord);
        positionVariantMap.put(variantRecord.getStartPosition(), variantsAtPosition);
    }

    for (Map.Entry<Long, Set<VariantRecord>> e : positionVariantMap.entrySet()) {
        Long pos = e.getKey();
        Set<VariantRecord> variantsAtPosition = e.getValue();
        for (final VariantRecord variantRecord : variantsAtPosition) {
            final JPanel rowContainer = new JPanel();
            rowContainer.setLayout(new BoxLayout(rowContainer, BoxLayout.Y_AXIS));
            final JPanel row = new JPanel();
            row.setLayout(new BoxLayout(row, BoxLayout.X_AXIS));
            row.setBorder(new EmptyBorder(0, MIDDLE_LEVEL_INDENT, 0, 0));
            final JLabel showDetailsButton = ViewUtil
                    .createIconButton(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.EXPAND));
            String posStr = NumberFormat.getNumberInstance().format(pos);
            JLabel rowTitle = new JLabel(
                    " " + variantRecord.getZygosity().name() + " " + variantRecord.getType() + " @ " + posStr);
            row.add(showDetailsButton);
            row.add(rowTitle);
            row.add(Box.createHorizontalGlue());
            rowContainer.add(row);
            outerPanel.add(rowContainer);

            showDetailsButton.addMouseListener(new MouseAdapter() {
                private boolean expanded = true;

                @Override
                public void mousePressed(MouseEvent me) {
                    if (expanded) {
                        showDetailsButton
                                .setIcon(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.COLLAPSE));
                        int last_level_indent = MIDDLE_LEVEL_INDENT
                                + IconFactory.getInstance().getIcon(IconFactory.StandardIcon.EXPAND)
                                        .getIconWidth()
                                + rowContainer.getFontMetrics(rowContainer.getFont()).charWidth(' ');
                        JPanel p = new JPanel();
                        p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
                        p.setBorder(new EmptyBorder(0, last_level_indent, 0, 0));
                        JPanel textPanel = new JPanel();
                        textPanel.setLayout(new BoxLayout(textPanel, BoxLayout.X_AXIS));
                        textPanel.add(new JLabel("Ref: " + variantRecord.getRef()));
                        textPanel.add(Box.createHorizontalGlue());
                        p.add(textPanel);

                        textPanel = new JPanel();
                        textPanel.setLayout(new BoxLayout(textPanel, BoxLayout.X_AXIS));
                        textPanel.add(new JLabel("Alt: " + variantRecord.getAlt()));
                        textPanel.add(Box.createHorizontalGlue());
                        p.add(textPanel);

                        rowContainer.add(p);
                    } else {
                        showDetailsButton
                                .setIcon(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.EXPAND));
                        rowContainer.removeAll();
                        rowContainer.add(row);
                    }
                    rowContainer.revalidate();
                    rowContainer.repaint();
                    expanded = !expanded;
                }
            });

        }
    }
    return outerPanel;
}