📄 sketcher.java
字号:
import java.util.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
public class Sketcher {
public static void main(String args[]){
app=new Sketcher();
app.init();
}
public void init(){
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception exc) {
System.err.println("Error loading L&F: " + exc);
}
SplashWindow splash=new SplashWindow(new JPanel(),"正在启动 Java网络画图 程序..请稍候..");
splash.setVisible(true);
window=new SketchFrame("画图",this);
Toolkit toolKit=window.getToolkit();
Dimension size=toolKit.getScreenSize();
window.setBounds(size.width/6,size.height/6,size.width*2/3,size.height*2/3);
window.addWindowListener(new WindowHandler());
sketch=new SketchModel();
view=new SketchView(this);
sketch.addObserver((Observer)view);
sketch.addObserver((Observer)window);
window.getContentPane().add(view,BorderLayout.CENTER);
window.addWindowListener(new WindowHandler());
SocketClient chatClient=null;
try{
chatClient=new SocketClient(view,"梁志伟","djinhua**","localhost");
}catch(Exception e){}
if(chatClient!=null)
view.addChat(chatClient);
chatDialog=new JDialog(window,SocketClient.getUser(),false);
chatDialog.getContentPane().add(chatClient,BorderLayout.CENTER);
chatDialog.setSize(400,300);
splash.setVisible(false);
splash.dispose();
splash=null;
window.setVisible(true);
chatDialog.setVisible(true);
}
public SketchFrame getWindow(){
return window;
}
public SketchModel getModel(){
return sketch;
}
public SketchView getView(){
return view;
}
public JDialog getDlg(){
return chatDialog;
}
public void insertModel(SketchModel newSketch){
sketch=newSketch;
sketch.addObserver((Observer)view);
sketch.addObserver((Observer)window);
view.repaint();
}
class WindowHandler extends WindowAdapter{
public void windowClosing(WindowEvent e){
window.checkForSave();
System.exit(0);
}
}
private SketchModel sketch;
private SketchView view;
private static SketchFrame window;
private static Sketcher app;
private static JDialog chatDialog;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -