Per quanto riguarda il menu ho provato setFont ma vale solo per le voci del menu, io devo cambiare proprio la scritta "file".
Io ho usato:
Menu menuFile = new Menu("File");
Per quanto riguarda il problema di allargare la finestra, questo è il mio codice...
codice:
package jcshell.gui;
/*
* This class create a dialog box for choice a font, size and style.
*
* */
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class FontChooser extends JComponent{
private JComboBox fontNameBox;
private JComboBox fontSizeBox;
private JComboBox fontStyleBox;/**/
public JTextArea example;
public FontChooser() {
fontNameBox = new JComboBox();
fontSizeBox = new JComboBox();
fontStyleBox = new JComboBox();/**/
example=new JTextArea("Your Text");
String[] fonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
for ( int i = 0; i < fonts.length; i++)
fontNameBox.addItem(fonts[i]);
for ( int i = 10; i < 40; i++)
fontSizeBox.addItem(new Integer(i));
fontStyleBox.addItem("Normal");
fontStyleBox.addItem("Bold");
fontStyleBox.addItem("Italic");
fontStyleBox.setSelectedItem(Font.PLAIN);
fontSizeBox.setSelectedIndex(12);
setLayout(new GridLayout());
JPanel comboBoxPanel = new JPanel();
comboBoxPanel.add(fontNameBox);
comboBoxPanel.add(fontSizeBox);
comboBoxPanel.add(fontStyleBox);
add(comboBoxPanel);
JPanel TextPanel = new JPanel();
TextPanel.add(example);
add(TextPanel);
setBorder(BorderFactory.createTitledBorder("Font"));
ActionListener eventForwarder = new ActionListener() {
public void actionPerformed(ActionEvent e) {
final int style;
if(fontStyleBox.getSelectedItem()=="Italic")
style = Font.ITALIC;
else if(fontStyleBox.getSelectedItem()=="Bold")
style = Font.BOLD;
else style=Font.PLAIN;
setFont(new Font((String)fontNameBox.getSelectedItem(), style, ((Integer)fontSizeBox.getSelectedItem()).intValue()));
Font unfont = new Font((String)fontNameBox.getSelectedItem(), style, ((Integer)fontSizeBox.getSelectedItem()).intValue());
example.setFont(unfont);
}
};
fontNameBox.addActionListener(eventForwarder);
fontSizeBox.addActionListener(eventForwarder);
fontStyleBox.addActionListener(eventForwarder);
}
public void setFont(Font f) {
super.setFont(f);
// Questa chiamata genera un PropertyChangeEvent
fontNameBox.setSelectedItem(f.getName());
fontSizeBox.setSelectedItem(new Integer(f.getSize()));
fontStyleBox.setSelectedItem(f.getName());
example.setFont(f);
}
public static Font showFontChooser(Component parent, String title, Font initialFont) {
FontChooser fc = new FontChooser();
fc.setFont(initialFont);
int answer = JOptionPane.showConfirmDialog(parent, fc, title, JOptionPane.OK_CANCEL_OPTION);
if ( answer != JOptionPane.OK_OPTION )
return null;
else{
return fc.getFont();
}
}
}