package entrancy;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.beans.PropertyVetoException;
import java.util.Random;
import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JSplitPane;
import javax.swing.JTextArea;
import javax.swing.Timer;
import childFrame.ChildWindow;
import leftArea.LeftPanel;
public class MainFrame extends JFrame {
JSplitPane splitPane = null;
public JDesktopPane desktopPane = null;
public ChildWindow childWindow = null;
public LeftPanel leftPanel = null;
public MainFrame() {
// TODO Auto-generated constructor stub
splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
splitPane.setOneTouchExpandable(true);
splitPane.setDividerLocation(200);
desktopPane = new JDesktopPane();
leftPanel = new LeftPanel(this);
this.add(leftPanel,BorderLayout.WEST);
splitPane.setLeftComponent(leftPanel);
splitPane.setRightComponent(desktopPane);
this.getContentPane().add(splitPane);
JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
AddChild();
AddChild();
AddChild();
PlayWord();
CreateLine();
}
private void AddChild(){
childWindow = new ChildWindow(this);
childWindow.setSize(new Dimension(200, 200));
desktopPane.add(childWindow);
try {
childWindow.setMaximum(true);
} catch (PropertyVetoException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
childWindow.setVisible(true);
childWindow.toFront();
try {
childWindow.setSelected(true);
} catch (PropertyVetoException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private void PlayWord(){
JInternalFrame child[] = desktopPane.getAllFrames();
try {
child[1].setSelected(true);
} catch (PropertyVetoException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
child[1].toFront();
child[1].setTitle("文字动画");
childWindow = (ChildWindow) child[1];
childWindow.textArea = new JTextArea();
childWindow.strAnimation = "文字动画";
Font font = new Font("宋体", Font.BOLD | Font.ITALIC, 22);
childWindow.textArea.setFont(font);
childWindow.textArea.setForeground(Color.MAGENTA);
childWindow.random = new Random();
childWindow.timer = new Timer(1000, childWindow);
childWindow.timer.start();
}
private void CreateLine(){
JInternalFrame child[] = desktopPane.getAllFrames();
try {
child[0].setSelected(true);
} catch (PropertyVetoException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
child[0].toFront();
child[0].setTitle("绘制图形");
childWindow = (ChildWindow) child[0];
childWindow.blLine = true;
childWindow.repaint();
}
}