⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 10+

📁 本压缩文档为《Java大学实用教程》(7-121-00959-5 电子工业出版社 2005.3) 的电子教案。
💻
字号:
import java.awt.event.*;
import javax.swing.*;
import java.awt.*;
class Win extends JFrame implements ItemListener
{  
    JComboBox list;
    JTextArea text;
    Win(String s) 
    {  
      super(s);        
      setSize(260,270);
      setLocation(120,120);
      setVisible(true);
      setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
      text=new JTextArea(12,12);               
      list=new JComboBox();
      list.setBackground(Color.red);
      text.setForeground(Color.blue);
      GraphicsEnvironment ge=GraphicsEnvironment.getLocalGraphicsEnvironment();
      String fontName[]=ge.getAvailableFontFamilyNames();
      for(int i=0;i<fontName.length;i++)
          { 
             list.addItem(fontName[i]);
          }
      Container con=getContentPane();
      con.add(list,BorderLayout.NORTH);
      con.add(text,BorderLayout.CENTER);
      list.addItemListener(this);
      setVisible(true); 
      setBounds(100,120,300,300);
      validate();
    }
    public void itemStateChanged(ItemEvent e)
    {  
      String name=(String)list.getSelectedItem();
      Font f=new Font(name,Font.BOLD,32);
      text.setFont(f);
      text.setText("\nWelcome 2008北京奥运");
    }
}
public class Example
{  
    public static void main(String args[]) 
    {  
        Win win=new Win("ok");
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -