求大神指教,还要实现自动滚屏控制滚屏的速度。以及修改字体大小。
package iReader;import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;public class  ActionHandle implements ActionListener{ @Override
public void actionPerformed(ActionEvent e) {
if(e.getSource()==Client.openFileButton){
ReadFile readFile= new ReadFile();
Client.browserFile.setVisible(true);
String getFile=Client.browserFile.getFile();
String getDir=Client.browserFile.getDirectory();
try{
String readedFile=readFile.iReader(getDir, getFile);
Client.textArea.setText("");
Client.textArea.append(readedFile);
Client.textArea.setCaretPosition(0);
Client.iFrame.setTitle("iReader" + "--"+getFile);
}
catch(Exception e2){};
}
else if(e.getSource()==Client.autoPlayButton){
Client.textArea.setCaretPosition(1000);

}
}}
package iReader;import java.io.*;public class ReadFile { public String iReader(String parent,String child) throws Exception{
File iFile = new File(parent+child);
FileInputStream iStream = new FileInputStream(iFile);
InputStreamReader iStreamReader= new InputStreamReader(iStream);
BufferedReader iBuffer = new BufferedReader(iStreamReader);
char[] a=new char[(int)iFile.length()];
iBuffer.read(a);
String text = new String(a);
iBuffer.close();
return text;
}
}package iReader;import java.awt.Color;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;public class ChangeColor implements ItemListener { static Color black,white,red,green,yellow,blue; @Override
public void itemStateChanged(ItemEvent e) {

black = new Color(0,0,0);
white = new Color(255,255,255);
red = new Color(255,0,0);
green = new Color(0,128,0);
yellow = new Color(255,255,0);
blue =new Color(0,0,255);
if(e.getSource()==Client.fontColorChoice){
String font=Client.fontColorChoice.getSelectedItem();
if(font.equals("黑色")){
Client.textArea.setForeground(black);
}
else if(font.equals("白色")){
Client.textArea.setForeground(white);
}
else if(font.equals("红色")){
Client.textArea.setForeground(red);
}
else if(font.equals("绿色")){
Client.textArea.setForeground(green);
}
else if(font.equals("黄色")){
Client.textArea.setForeground(yellow);
}
else if(font.equals("蓝色")){
Client.textArea.setForeground(blue);
}
}
else if(e.getSource()==Client.backgroundColorChoice){
String background=Client.backgroundColorChoice.getSelectedItem();
if(background.equals("白色")){
Client.textArea.setBackground(white);
}
else if(background.equals("绿色")){
Client.textArea.setBackground(green);
}
else if(background.equals("蓝色")){
Client.textArea.setBackground(blue);
}
if(background.equals("黑色")){
Client.textArea.setBackground(black);
}
}
}}
package iReader;import java.awt.Font;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;public class ChangeFont implements ItemListener { static Font plain,bold,italic;

@Override
public void itemStateChanged(ItemEvent e) {

plain = new Font("",Font.PLAIN,15);
bold =new Font("",Font.BOLD,15);
italic = new Font("",Font.ITALIC,15);
//Defaultsetting = new Font("",Font.CENTER_BASELINE,15);
if(e.getSource()==Client.fontChoice){
String font =Client.fontChoice.getSelectedItem();
if(font.equals("扁平")){
Client.textArea.setFont(plain);
}
else if(font.equals("粗体")){
Client.textArea.setFont(bold);
}
else if(font.equals("斜体")){
Client.textArea.setFont(italic);
}
}
else if(e.getSource()==Client.fontSizeChoice){
String size =Client.fontSizeChoice.getSelectedItem();
if(size.equals("48")){
}
}
}
}package iReader;import java.awt.*;import javax.swing.*;public class Client { static JFrame iFrame = new JFrame("iReader");
static JToolBar iToolBar = new JToolBar();
static JButton openFileButton=new JButton(new ImageIcon("src/images/open_file.png"));
static JButton autoPlayButton=new JButton(new ImageIcon("src/images/auto_play.png"));
static JButton stopButton=new JButton(new ImageIcon("src/images/stop_play.png"));
static Choice fontSizeChoice = new Choice();
static Choice fontChoice =new Choice();
static Choice  fontColorChoice = new Choice();
static Choice backgroundColorChoice = new Choice();
static Choice playSpeedChoice = new Choice(); 
static JLabel backgroundLable = new JLabel("背景颜色");
static JLabel fontColorLabel =new JLabel("字体颜色");
static JLabel playSpeedLabel = new JLabel("播放速度");
static Box toolBarBox =Box.createHorizontalBox();
static Box textAreaBox =Box.createHorizontalBox();
static Box bigBox =Box.createVerticalBox();
static Component iComponent1=Box.createVerticalStrut(20);
static Component iComponent2=Box.createVerticalGlue();
static TextArea textArea=new TextArea("",40,25,TextArea.SCROLLBARS_VERTICAL_ONLY);
static JScrollBar scrollBar= new JScrollBar();
static FileDialog browserFile = new FileDialog(iFrame,"打开文件",FileDialog.LOAD); public void Init(){
iFrame.setVisible(true);
iFrame.setTitle("iReader");
    iFrame.setSize(600, 750);
    iFrame.setLocation(300, 15);
    iFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    textArea.setEditable(false);
    textArea.setForeground(ChangeColor.black);
textArea.setBackground(ChangeColor.white);
    iToolBar.add(openFileButton);
    iToolBar.add(autoPlayButton);
    iToolBar.add(stopButton);
    iToolBar.add(fontChoice);
    iToolBar.add(fontSizeChoice);
    iToolBar.add(fontColorLabel);
        iToolBar.add(fontColorChoice);
    iToolBar.add(backgroundLable);
    iToolBar.add(backgroundColorChoice);
    iToolBar.add(playSpeedLabel);
    iToolBar.add(playSpeedChoice);
    toolBarBox.add(iToolBar);
    toolBarBox.add(iComponent1);
    textAreaBox.add(textArea);
    bigBox.add(toolBarBox);
    bigBox.add(textAreaBox);
    iFrame.add(bigBox);
    fontChoice.add("扁平");
    fontChoice.add("粗体");
    fontChoice.add("斜体");
    fontSizeChoice.add("5");
    fontSizeChoice.add("6");
    fontSizeChoice.add("7");
    fontSizeChoice.add("8");
    fontSizeChoice.add("9");
    fontSizeChoice.add("10");
    fontSizeChoice.add("11");
    fontSizeChoice.add("12");
    fontSizeChoice.add("14");
    fontSizeChoice.add("16");
    fontSizeChoice.add("18");
    fontSizeChoice.add("20");
    fontSizeChoice.add("22");
    fontSizeChoice.add("26");
    fontSizeChoice.add("28");
    fontSizeChoice.add("36");
    fontSizeChoice.add("48");
    fontSizeChoice.add("72");
    fontColorChoice.add("黑色");
    fontColorChoice.add("白色");
    fontColorChoice.add("红色");
    fontColorChoice.add("绿色");
    fontColorChoice.add("黄色");
    fontColorChoice.add("蓝色");
    backgroundColorChoice.add("白色");
    backgroundColorChoice.add("黑色");
    backgroundColorChoice.add("绿色");
    backgroundColorChoice.add("蓝色");
    playSpeedChoice.add("慢");
    playSpeedChoice.add("中");
    playSpeedChoice.add("快");
}
public static void main(String[] args){
ActionHandle iActionHandle = new ActionHandle();
openFileButton.addActionListener(iActionHandle);
ChangeColor iChangeColor = new ChangeColor();
fontColorChoice.addItemListener(iChangeColor);
backgroundColorChoice.addItemListener(iChangeColor);
ChangeFont iChangeFont=new ChangeFont();
fontChoice.addItemListener(iChangeFont);
Client test=new Client();
test.Init();
}

}