|
MenuLayoutTest |
|
1 /* 2 * Copyright (c) 1998-2003, The University of Sheffield. 3 * 4 * This file is part of GATE (see http://gate.ac.uk/), and is free 5 * software, licenced under the GNU Library General Public License, 6 * Version 2, June 1991 (in the distribution as file licence.html, 7 * and also available at http://gate.ac.uk/gate/licence.html). 8 * 9 * Valentin Tablan 20 Feb 2003 10 * 11 * $Id: MenuLayoutTest.java,v 1.3 2003/02/21 14:10:38 valyt Exp $ 12 */ 13 14 package gate.swing; 15 16 import javax.swing.*; 17 import java.awt.*; 18 import java.awt.event.*; 19 20 public class MenuLayoutTest extends JFrame { 21 public MenuLayoutTest() { 22 super("Displaying Long Menus"); 23 JMenuBar menuBar = new JMenuBar(); 24 this.setJMenuBar(menuBar); 25 JMenu bigMenu = new JMenu("bigMenu"); 26 menuBar.add(bigMenu); 27 28 // specify a layout manager for the menu 29 MenuLayout vflayout = new MenuLayout(); 30 bigMenu.getPopupMenu().setLayout(vflayout); 31 for (int i = 1; i < 200; i++) { 32 JMenuItem bigMenuItem = new JMenuItem("bigMenu " + i); 33 //uncomment below for crazy sizes 34 // bigMenuItem.setFont(bigMenuItem.getFont().deriveFont( 35 // 12 + (float)Math.random() * 10)); 36 if(i > 100){ 37 bigMenuItem.setFont(bigMenuItem.getFont().deriveFont((float)20)); 38 } 39 40 bigMenu.add(bigMenuItem); 41 } 42 } 43 44 public static void main(String[] args) { 45 MenuLayoutTest frame = new MenuLayoutTest(); 46 frame.setSize(250, 200); 47 frame.setLocation(200, 300); 48 frame.setVisible(true); 49 } 50 }
|
MenuLayoutTest |
|