📄 mainwindow.java
字号:
package chat.client;import java.awt.CardLayout;import javax.swing.JFrame;public class MainWindow extends JFrame{ /** * */ private static final long serialVersionUID = 1L; //static int width = 300; //static int height = 200; /** * */ //JFrame f; MainPanel mp; LoginPanel lp; public RegisterPanel rp; OnlinePanel op; CardLayout cl; @SuppressWarnings("static-access") public MainWindow(){ //f = new JFrame(); cl = new CardLayout(); mp = new MainPanel(); lp = new LoginPanel(); rp = new RegisterPanel(); op = new OnlinePanel(); this.setLayout(cl); this.add(mp,"mp"); this.add(lp,"lp"); this.add(rp,"rp"); this.add(op,"op"); //addListener(); //this.setDefaultCloseOperation(this.EXIT_ON_CLOSE); this.setSize(mp.getWidth(),mp.getHeight()); this.setVisible(true); } //private void addListener(){ //mp.login.addActionListener(new ActionListener(){ //public void actionPerformed(ActionEvent e){ //show("lp"); //}//}); // mp.register.addActionListener(new ActionListener(){ // public void actionPerformed(ActionEvent e){ // show("rp'"); // } //}); //lp.ok.addActionListener(new ActionListener(){ // public void actionPerformed(ActionEvent e){ // show("op"); // } //}); //rp.ok.addActionListener(new ActionListener(){ //public void actionPerformed(ActionEvent e){ //show("op"); // } // }); //op.qunliao.addActionListener(new ActionListener(){ // public void actionPerformed(ActionEvent e){ // createChatWindow("all"); //} // });//} public void show(String name){ //this.setVisible(false); if(name.equals("mp'")){ //f = new JFrame(); //f.setSize(300,200); this.setSize(mp.getWidth(),mp.getHeight()); }else if(name.equals("lp'")){ //f = new JFrame(); //f.setSize(300,200); this.setSize(lp.getWidth(),lp.getHeight()); }else if(name.equals("rp'")){ //f = new JFrame(); //f.setSize(200,300); this.setSize(rp.getWidth(),rp.getHeight()); }else{ //f = new JFrame(); //f.setSize(200,300); this.setSize(op.getWidth(),op.getHeight()); } //f.setLayout(cl); //f.add(mp,"mp"); //f.add(lp,"lp"); //f.add(rp,"rp"); //f.add(op,"op"); //f.setVisible(true); //f.setDefaultCloseOperation(f.EXIT_ON_CLOSE); cl.show(this.getContentPane(),name); } // public void createChatWindow(String name){ // if(name.equals("all")){ // new ChatWindow("群聊'"); // }else{ // new ChatWindow("与" + "群聊"); // } // } // public static void main(String[] srg){ // new MainWindow(); // } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -