下面列出了javax.swing.JMenu#setFont ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
protected void addSoundMenu( JPopupMenu parent ){
JMenu soundMenu = new JMenu("Sound");
soundMenu.setFont( TGConfig.FONT_WIDGETS );
JMenuItem soundMixer = new JMenuItem("Open Mixer");
soundMixer.addActionListener(new TGActionProcessorListener(getContext(), TransportMixerAction.NAME));
soundMixer.setFont( TGConfig.FONT_WIDGETS );
soundMenu.add( soundMixer );
JMenuItem soundSetup = new JMenuItem("Sound Settings");
soundSetup.addActionListener(new TGActionProcessorListener(getContext(), TransportSetupAction.NAME));
soundSetup.setFont( TGConfig.FONT_WIDGETS );
soundMenu.add( soundSetup );
parent.add( soundMenu );
}
private JMenu createMenu(String title) {
JMenu menu = new JMenu(title);
// menu.setForeground(ColorResource.getDeepFontColor());
menu.setFont(FontResource.getBoldFont());
menu.setBorderPainted(false);
menu.setBorder(new EmptyBorder(getScaledInt(5), getScaledInt(5), getScaledInt(5), getScaledInt(5)));
return menu;
}
private JMenu addSubMenu(String id, JMenu parentMenu, PopupMenuListener popupListener) {
JMenu menu = new JMenu(StringResource.get(id));
menu.setName(id);
menu.setFont(FontResource.getNormalFont());
// menu.setForeground(ColorResource.getLightFontColor());
menu.addActionListener(this);
// menu.setBackground(ColorResource.getDarkerBgColor());
menu.setBorderPainted(false);
menu.getPopupMenu().addPopupMenuListener(popupListener);
parentMenu.add(menu);
return menu;
}
protected void addViewMenu( JPopupMenu parent ){
int style = TuxGuitar.instance().getTablatureEditor().getTablature().getViewLayout().getStyle();
JMenu showMenu = new JMenu("View");
showMenu.setFont( TGConfig.FONT_WIDGETS );
JMenuItem showScore = new JCheckBoxMenuItem("Show Score", ( style & TGLayout.DISPLAY_SCORE) != 0 );
showScore.addActionListener(new TGActionProcessorListener(getContext(), SetScoreEnabledAction.NAME));
showScore.setFont( TGConfig.FONT_WIDGETS );
showMenu.add( showScore );
JMenuItem showTablature = new JCheckBoxMenuItem("Show Tablature", ( style & TGLayout.DISPLAY_TABLATURE) != 0 );
showTablature.addActionListener(new TGActionProcessorListener(getContext(), SetTablatureEnabledAction.NAME));
showTablature.setFont( TGConfig.FONT_WIDGETS );
showMenu.add( showTablature );
JMenuItem showChordName = new JCheckBoxMenuItem("Show Chord Names", ( style & TGLayout.DISPLAY_CHORD_NAME) != 0 );
showChordName.addActionListener(new TGActionProcessorListener(getContext(), SetChordNameEnabledAction.NAME));
showChordName.setFont( TGConfig.FONT_WIDGETS );
showMenu.add( showChordName );
JMenuItem showChordDiagram = new JCheckBoxMenuItem("Show Chord Diagrams", ( style & TGLayout.DISPLAY_CHORD_DIAGRAM) != 0 );
showChordDiagram.addActionListener(new TGActionProcessorListener(getContext(), SetChordDiagramEnabledAction.NAME));
showChordDiagram.setFont( TGConfig.FONT_WIDGETS );
showMenu.add( showChordDiagram );
parent.add( showMenu );
}
public static JMenu createJMenu(String description, ImageInfoReader imageInfoReader, SoundIdReader soundIdReader) {
JMenu menu = new TiledImageJMenu(description, imageInfoReader);
menu.setBackground(ColorPalette.DARK_BACKGROUND_COLOR);
menu.setForeground(ColorPalette.FOREGROUND_COLOR);
menu.setFont(Fonts.FONT);
menu.setCursor(Cursors.CURSOR);
addRollOverSoundEffect(menu, soundIdReader);
return menu;
}
public static JMenu createMenu(String text) {
JMenu optionsMenu = new JMenu();
optionsMenu.setText(text);
optionsMenu.setBackground(JPlagCreator.SYSTEMCOLOR);
optionsMenu.setFont(SYSTEM_FONT);
return optionsMenu;
}
/**
* Sets the menu font.
*
* @param m a menu
* @param font the font
*/
private static void setMenuFont(JMenu m, Font font) {
m.setFont(font);
for(int i = 0; i<m.getMenuComponentCount(); i++) {
m.getMenuComponent(i).setFont(font);
if(m.getMenuComponent(i) instanceof JMenu) {
setMenuFont((JMenu) m.getMenuComponent(i), font);
}
}
}
private JMenu changeFont(JMenu menu) {
menu.setFont(new Font("Default", Font.BOLD, 11));
return menu;
}
public void setClock(JMenuBar panel) {
JMenu clockMenu = new JMenu();
// List of possible GMT
JButton[] timeZones = new JButton[24];
timeZones[0] = new JButton("GMT-12");
timeZones[1] = new JButton("GMT-11");
timeZones[2] = new JButton("GMT-10");
timeZones[3] = new JButton("GMT-9");
timeZones[4] = new JButton("GMT-8");
timeZones[5] = new JButton("GMT-7");
timeZones[6] = new JButton("GMT-6");
timeZones[7] = new JButton("GMT-5");
timeZones[8] = new JButton("GMT-4");
timeZones[9] = new JButton("GMT-3");
timeZones[10] = new JButton("GMT-2");
timeZones[11] = new JButton("GMT-1");
timeZones[12] = new JButton("GMT");
timeZones[13] = new JButton("GMT+1");
timeZones[14] = new JButton("GMT+2");
timeZones[15] = new JButton("GMT+3");
timeZones[16] = new JButton("GMT+4");
timeZones[17] = new JButton("GMT+5");
timeZones[18] = new JButton("GMT+6");
timeZones[19] = new JButton("GMT+7");
timeZones[20] = new JButton("GMT+8");
timeZones[21] = new JButton("GMT+9");
timeZones[22] = new JButton("GMT+10");
timeZones[23] = new JButton("GMT+11");
clockMenu.setFont(new Font(clockMenu.getFont().getName(), Font.PLAIN, 28));
panel.add(clockMenu, BorderLayout.LINE_END);
// Every button will have the same listener
ClockController listener = new ClockController();
for (int i = 0; i < timeZones.length; i++) {
timeZones[i].addActionListener(listener);
timeZones[i].setMargin(new Insets(0, 0, 0, 0));
timeZones[i].setContentAreaFilled(false);
timeZones[i].setBorderPainted(false);
timeZones[i].setOpaque(false);
clockMenu.add(timeZones[i]);
}
Thread clock = new Thread() {
public void run() {
String GMT;
for (;;) {
GMT = listener.getButtonPressedText();
Calendar cal;
if (GMT == null) {
cal = Calendar.getInstance();
} else {
cal = Calendar.getInstance(TimeZone.getTimeZone(GMT));
}
int second = cal.get(Calendar.SECOND);
int minute = cal.get(Calendar.MINUTE);
int hours = cal.get(Calendar.HOUR_OF_DAY);
clockMenu.setText(hours + ":" + minute + ":" + second);
try {
sleep(100);
} catch (InterruptedException e) {
}
}
}
};
clock.start();
}
public static JMenu createMenu(String label) {
JMenu subMenu = new JMenu(label);
subMenu.setForeground(UI.FOREGROUND);
subMenu.setFont(UI.FONT);
return subMenu;
}
public static JMenu createMenu(String label) {
JMenu subMenu = new JMenu(label);
subMenu.setForeground(UI.FOREGROUND);
subMenu.setFont(UI.FONT);
return subMenu;
}