List of usage examples for javax.swing JMenu getFont
@Transient
public Font getFont()
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 ww .j a v a2 s . com 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)); }