java如何实现QQ菜单效果 java中酷似QQ界面,类似outlook的垂直菜单或工具条,并可以上下移动 谁有或哪里有下载 。急用,请告知 ,谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://www.learnjava.cn/Article/j2se/jinjie/200706/336.html是你需要的,和QQ基本上一样的。 具体不记得了,可以使用cardLayout尝试。 我这里有一个,不过可能效率不是太高。还有这个只是界面的代码,所以对你来说有些错误,可能要稍做些修改package frisky.client;import java.io.*;import java.util.*;import java.awt.*;import java.awt.event.*;import javax.swing.*;import java.lang.*;public class MCFriendsInterface extends JFrame{ protected MyCallClient clientFriends; protected JPanel friendsPanel;//好友面板 protected JButton friendsButton;//好友按键 protected JTree friendsTree;//好友树 private int heightPanel=630;//和组的值一样 private int widthPanel=145; //全部一样的 protected JPanel groupsPanel;//组面板 protected JButton groupsButton;//组按键 protected JTree groupsTree;//组树 private int yGroupsPanel=630; protected JPanel menuPanel;//按键面板 protected JButton menuButton;//菜单按键 private int yMenuPanel=650; Container contentPane =this.getContentPane(); MCFriendsInterface(MyCallClient clientFriends){ super("Friends"); this.clientFriends = clientFriends; contentPane.setLayout(null); setUpToolBar(); setUpMainInterface(); this.setVisible(true); } protected void setUpToolBar(){ //菜单面板 menuPanel = new JPanel(); menuPanel.setLayout(null); menuPanel.setBounds(0,yMenuPanel,widthPanel,20); menuButton = new JButton("<-菜单"); menuButton.setBounds(0,0,80,20); menuPanel.add(menuButton); contentPane.add(menuPanel); // 组面板 groupsPanel = new JPanel(); groupsPanel.setLayout(null); groupsPanel.setBounds(0,yGroupsPanel,widthPanel,heightPanel); groupsButton = new JButton("我的群"); groupsButton.setBounds(0,0,widthPanel,20); groupsPanel.add(groupsButton); contentPane.add(groupsPanel); //组树 groupsTree = new JTree(); groupsTree.setBounds(0,20, widthPanel, heightPanel-20); groupsPanel.add(groupsTree); //好友面板 friendsPanel = new JPanel(); friendsPanel.setLayout(null); friendsPanel.setBounds(0,0,widthPanel,heightPanel); friendsButton = new JButton("我的好友"); friendsButton.setBounds(0,0,widthPanel,20); friendsPanel.add(friendsButton); contentPane.add(friendsPanel); //好友树 friendsTree = new JTree(); friendsTree.setBounds(0,20,widthPanel,heightPanel-20); friendsPanel.add(friendsTree); } protected void setUpMainInterface(){ this.setSize(150,700); setUpListener(); // 设置窗体位置 Dimension screen=Toolkit.getDefaultToolkit().getScreenSize(); setLocation((screen.width-getSize().width)*4/5,0); //,(screen.height-getSize().height)/4);//使启动窗口居中显示 } protected void setUpListener(){ friendsButton.addActionListener(new FriendsButton()); groupsButton.addActionListener(new GroupsButton()); menuButton.addActionListener(new MenuButton()); this.addComponentListener(new ReSizeWindow()); this.addWindowListener(new OnExit()); } class FriendsButton implements ActionListener{ public void actionPerformed(ActionEvent e){ int y = groupsPanel.getLocation().y; int windowHeight = groupsPanel.getHeight(); if(y==20){ while(true){ yGroupsPanel+=10; if(yGroupsPanel>windowHeight){ yGroupsPanel = windowHeight; groupsPanel.setBounds(0,yGroupsPanel,widthPanel,heightPanel); break; }else{ groupsPanel.setBounds(0,yGroupsPanel,widthPanel,heightPanel); } } } } } class GroupsButton implements ActionListener{ public void actionPerformed(ActionEvent e){ int y = groupsPanel.getLocation().y; if(y==yGroupsPanel){ while(true){ yGroupsPanel -= 10; if(yGroupsPanel<20){ yGroupsPanel = 20; groupsPanel.setBounds(0,yGroupsPanel,widthPanel,heightPanel); break; }else{ groupsPanel.setBounds(0,yGroupsPanel,widthPanel,heightPanel); } } } } } class MenuButton implements ActionListener{ public void actionPerformed(ActionEvent e){ new MCMenuInterface(clientFriends.windowFriendsClient); } } class ReSizeWindow implements ComponentListener{ public void componentMoved(ComponentEvent eMove){ /*不操作*/ } public void componentHidden(ComponentEvent eHidden){ /*不操作*/ } public void componentResized(ComponentEvent eResized){ // int widthWindow = clientFriends.windowFriendsClient.getWidth(); // int heightWindow = clientFriends.windowFriendsClient.getHeight(); int widthWindow =getWidth(); int heightWindow =getHeight(); yMenuPanel = heightWindow-50; widthPanel = widthWindow - 5; heightPanel = heightWindow -70; yGroupsPanel = heightWindow - 70; menuPanel.setBounds(0,yMenuPanel,widthPanel,20); groupsPanel.setBounds(0,yGroupsPanel,widthPanel,heightPanel); groupsButton.setBounds(0,0,widthPanel,20); groupsTree.setBounds(0,20, widthPanel, heightPanel-20); friendsPanel.setBounds(0,0,widthPanel,heightPanel); friendsButton.setBounds(0,0,widthPanel,20); friendsTree.setBounds(0,20,widthPanel,heightPanel-20); } public void componentShown(ComponentEvent eShown){ /*不操作*/ } } class OnExit extends WindowAdapter implements WindowListener{ public void windowClosing(WindowEvent we){ clientFriends.shutDown(); //关闭服务器 } }} 还有~~几个JTree的最好加上JScrollPane 我想知道自定义的窗口怎么做?比如qq的窗口下边是圆角的 好像用IBM的iFrame可以做出来? http://blog.sina.com.cn/s/blog_4b6047bc01000aid.html\推荐 谁能帮我指导一下Java登录界面的SQL验证的实现 想通过JVMTI来加密类文件,但存在疑虑,高手请进 为什么程序生成.exe之后,程序里用的图片显示问题!急! javax.servlet 包在什么地方 初学者关于java的图像显示的问题 java与C++在面向对象方面有哪些不同? 局域网内为何不能通信??? 我想把Java源码编译本地的exe,因为用jvm太慢了,但是不知用啥编译器? 如何存为*.java文件? java中变量的赋值和使用有什么区别? 谁能帮我非常详细的解释一下这个简单的JAVA代码? JTabbedPane的选项卡如何居中
是你需要的,和QQ基本上一样的。
package frisky.client;import java.io.*;
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.lang.*;public class MCFriendsInterface extends JFrame{
protected MyCallClient clientFriends;
protected JPanel friendsPanel;//好友面板
protected JButton friendsButton;//好友按键
protected JTree friendsTree;//好友树
private int heightPanel=630;//和组的值一样
private int widthPanel=145; //全部一样的
protected JPanel groupsPanel;//组面板
protected JButton groupsButton;//组按键
protected JTree groupsTree;//组树
private int yGroupsPanel=630;
protected JPanel menuPanel;//按键面板
protected JButton menuButton;//菜单按键
private int yMenuPanel=650;
Container contentPane =this.getContentPane();
MCFriendsInterface(MyCallClient clientFriends){
super("Friends");
this.clientFriends = clientFriends;
contentPane.setLayout(null);
setUpToolBar();
setUpMainInterface();
this.setVisible(true);
}
protected void setUpToolBar(){
//菜单面板
menuPanel = new JPanel();
menuPanel.setLayout(null);
menuPanel.setBounds(0,yMenuPanel,widthPanel,20);
menuButton = new JButton("<-菜单");
menuButton.setBounds(0,0,80,20);
menuPanel.add(menuButton);
contentPane.add(menuPanel);
// 组面板
groupsPanel = new JPanel();
groupsPanel.setLayout(null);
groupsPanel.setBounds(0,yGroupsPanel,widthPanel,heightPanel);
groupsButton = new JButton("我的群");
groupsButton.setBounds(0,0,widthPanel,20);
groupsPanel.add(groupsButton);
contentPane.add(groupsPanel);
//组树
groupsTree = new JTree();
groupsTree.setBounds(0,20, widthPanel, heightPanel-20);
groupsPanel.add(groupsTree);
//好友面板
friendsPanel = new JPanel();
friendsPanel.setLayout(null);
friendsPanel.setBounds(0,0,widthPanel,heightPanel);
friendsButton = new JButton("我的好友");
friendsButton.setBounds(0,0,widthPanel,20);
friendsPanel.add(friendsButton);
contentPane.add(friendsPanel);
//好友树
friendsTree = new JTree();
friendsTree.setBounds(0,20,widthPanel,heightPanel-20);
friendsPanel.add(friendsTree);
}
protected void setUpMainInterface(){
this.setSize(150,700);
setUpListener();
// 设置窗体位置
Dimension screen=Toolkit.getDefaultToolkit().getScreenSize();
setLocation((screen.width-getSize().width)*4/5,0);
//,(screen.height-getSize().height)/4);//使启动窗口居中显示
}
protected void setUpListener(){
friendsButton.addActionListener(new FriendsButton());
groupsButton.addActionListener(new GroupsButton());
menuButton.addActionListener(new MenuButton());
this.addComponentListener(new ReSizeWindow());
this.addWindowListener(new OnExit());
}
class FriendsButton implements ActionListener{
public void actionPerformed(ActionEvent e){
int y = groupsPanel.getLocation().y;
int windowHeight = groupsPanel.getHeight();
if(y==20){
while(true){
yGroupsPanel+=10;
if(yGroupsPanel>windowHeight){
yGroupsPanel = windowHeight;
groupsPanel.setBounds(0,yGroupsPanel,widthPanel,heightPanel);
break;
}else{
groupsPanel.setBounds(0,yGroupsPanel,widthPanel,heightPanel);
}
}
}
}
}
class GroupsButton implements ActionListener{
public void actionPerformed(ActionEvent e){
int y = groupsPanel.getLocation().y;
if(y==yGroupsPanel){
while(true){
yGroupsPanel -= 10;
if(yGroupsPanel<20){
yGroupsPanel = 20;
groupsPanel.setBounds(0,yGroupsPanel,widthPanel,heightPanel);
break;
}else{
groupsPanel.setBounds(0,yGroupsPanel,widthPanel,heightPanel);
}
}
}
}
}
class MenuButton implements ActionListener{
public void actionPerformed(ActionEvent e){
new MCMenuInterface(clientFriends.windowFriendsClient);
}
}
class ReSizeWindow implements ComponentListener{
public void componentMoved(ComponentEvent eMove){
/*不操作*/
}
public void componentHidden(ComponentEvent eHidden){
/*不操作*/
}
public void componentResized(ComponentEvent eResized){
// int widthWindow = clientFriends.windowFriendsClient.getWidth();
// int heightWindow = clientFriends.windowFriendsClient.getHeight();
int widthWindow =getWidth();
int heightWindow =getHeight();
yMenuPanel = heightWindow-50;
widthPanel = widthWindow - 5;
heightPanel = heightWindow -70;
yGroupsPanel = heightWindow - 70;
menuPanel.setBounds(0,yMenuPanel,widthPanel,20);
groupsPanel.setBounds(0,yGroupsPanel,widthPanel,heightPanel);
groupsButton.setBounds(0,0,widthPanel,20);
groupsTree.setBounds(0,20, widthPanel, heightPanel-20);
friendsPanel.setBounds(0,0,widthPanel,heightPanel);
friendsButton.setBounds(0,0,widthPanel,20);
friendsTree.setBounds(0,20,widthPanel,heightPanel-20);
}
public void componentShown(ComponentEvent eShown){
/*不操作*/
}
}
class OnExit extends WindowAdapter implements WindowListener{
public void windowClosing(WindowEvent we){
clientFriends.shutDown(); //关闭服务器
}
}
}
好像用IBM的iFrame可以做出来?
推荐