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

📄 maingui.java

📁 java简易在线聊天程序
💻 JAVA
字号:
package chatDog;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class mainGUI extends JFrame implements Const{
	private Friend[] friend=new Friend[30];
	private JMenuBar menuBar=new  JMenuBar();
	private JMenu manage=new  JMenu(MENU_MAINGUI);
	public JMenuItem addFriend=new  JMenuItem(MENU_ADDFRIEND);
	public JMenuItem delFriend=new  JMenuItem(MENU_DELFRIEND);
	private JMenuItem author=new JMenuItem("作者");
	private JMenu help=new JMenu("关于");
	private JPanel friendPanel=new JPanel();
	private JScrollPane fSPane;

	mainGUI(String cap){
		super(cap);
		this.setSize(150,500);
		this.setLocation(1100,30);
		this.setLayout(new BorderLayout());
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		addFriend.setActionCommand(BTN_ADDFRIEND);
		delFriend.setActionCommand(BTN_DELFRIEND);
		
		author.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				(new JOptionPane()).showMessageDialog(null,new JLabel("本软件由计算机科学与技术学院胡柏毓,罗帧怡,韩巍伟联合开发"),
			                                      "作者",JOptionPane.INFORMATION_MESSAGE);
			}
		});
		help.add(author);
		manage.add(addFriend);
		manage.add(delFriend);
		menuBar.add(manage);
		menuBar.add(help);
		
		//for(int i=1;i<=2;i++)
		  //friend[i]=new Friend("hubaiyu","127.0.0.1","head.jpg");
		
		this.getContentPane().add(menuBar,"North");
		
		friendPanel.setLayout(new BoxLayout(friendPanel,BoxLayout.Y_AXIS));
		//for(int i=1;i<=2;i++)
		   //friendPanel.add(friend[i].getPane());
		
		fSPane=new JScrollPane(friendPanel);
		fSPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
		this.getContentPane().add(fSPane,"Center");
	}
	public void setFriend(Friend[] frd){
		friend=frd;
		JFrame t=new JFrame();
		
	}
	public void showGUI(Friend[] frd,int fNum){
		friendPanel.removeAll();
		if(frd!=null)
		  for(int i=0;i<=fNum-1;i++)
		      friendPanel.add(frd[i].getPane());  
		this.setVisible(true);
		this.repaint();
	}
}

⌨️ 快捷键说明

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