java在线聊天项目 swt可视化窗口Design 重新设计好友列表窗口 增加菜单栏
增加的菜单栏效果图如下:
eclipse 中调整到 swt的design视图下
控件区域选择Menu Controls
将Menu Bar拖动到窗口标题栏
将Cascaded Menu拖动到Menu Bar
依次将多个Menu Item加入到New SubMenu
Separator是分隔符
也可以再放入Cascaded Menu级联菜单
好友列表窗口的代码如下:
package com.swift.frame; import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.FlowLayout;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent; import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JTabbedPane;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException; public class FriendsDialog extends JDialog { public static void main(String args[]) { JFrame.setDefaultLookAndFeelDecorated(true);
JDialog.setDefaultLookAndFeelDecorated(true); try {
UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");
} catch (ClassNotFoundException e1) {
e1.printStackTrace();
} catch (InstantiationException e1) {
e1.printStackTrace();
} catch (IllegalAccessException e1) {
e1.printStackTrace();
} catch (UnsupportedLookAndFeelException e1) {
e1.printStackTrace();
} EventQueue.invokeLater(new Runnable() {
public void run() {
try {
FriendsDialog dialog = new FriendsDialog();
dialog.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
dialog.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
} public FriendsDialog() {
super();
setTitle("飞燕聊天");
setBounds(100, 100, 247, 581); final JPanel panel = new JPanel();
panel.setLayout(new BorderLayout());
getContentPane().add(panel, BorderLayout.NORTH); final JLabel label = new JLabel(new ImageIcon("Images/logo.jpg"));
label.setText("New JLabel");
panel.add(label, BorderLayout.WEST);
label.setPreferredSize(new Dimension(74,74)); final JPanel panel_1 = new JPanel();
panel_1.setLayout(new BorderLayout());
panel.add(panel_1, BorderLayout.CENTER); final JLabel advancingSwiftLabel = new JLabel();
advancingSwiftLabel.setText("Advancing Swift");
panel_1.add(advancingSwiftLabel, BorderLayout.CENTER); final JLabel neverWasterLabel = new JLabel();
neverWasterLabel.setText("Never waste time any more");
panel_1.add(neverWasterLabel, BorderLayout.SOUTH); final JPanel panel_2 = new JPanel();
panel_2.setLayout(new BorderLayout());
getContentPane().add(panel_2, BorderLayout.SOUTH); final JPanel panel_3 = new JPanel();
final FlowLayout flowLayout = new FlowLayout();
flowLayout.setAlignment(FlowLayout.LEFT);
panel_3.setLayout(flowLayout);
panel_2.add(panel_3); final JButton button = new JButton();
panel_3.add(button);
button.setHorizontalTextPosition(SwingConstants.LEFT);
button.setHorizontalAlignment(SwingConstants.LEFT);
button.setText("设置"); final JButton button_1 = new JButton();
panel_3.add(button_1);
button_1.setText("查找"); final JPanel panel_4 = new JPanel();
panel_2.add(panel_4, BorderLayout.EAST); final JButton button_2 = new JButton();
panel_4.add(button_2);
button_2.setText("退出"); final JTabbedPane tabbedPane = new JTabbedPane();
getContentPane().add(tabbedPane, BorderLayout.CENTER); final JPanel panel_5 = new JPanel();
tabbedPane.addTab("好友列表", null, panel_5, null); final JPanel panel_6 = new JPanel();
tabbedPane.addTab("群聊", null, panel_6, null); final JPanel panel_7 = new JPanel();
tabbedPane.addTab("聊天记录", null, panel_7, null); final JMenuBar menuBar = new JMenuBar();
setJMenuBar(menuBar); final JMenu menu = new JMenu();
menu.setText("操作");
menuBar.add(menu); final JMenuItem newItemMenuItem = new JMenuItem();
newItemMenuItem.setText("设置");
menu.add(newItemMenuItem); final JMenuItem newItemMenuItem_1 = new JMenuItem();
newItemMenuItem_1.setText("空间");
menu.add(newItemMenuItem_1); final JMenuItem newItemMenuItem_2 = new JMenuItem();
newItemMenuItem_2.setText("邮箱");
menu.add(newItemMenuItem_2); final JMenu menu_1 = new JMenu();
menu_1.setText("会员");
menu.add(menu_1); final JMenuItem newItemMenuItem_3 = new JMenuItem();
newItemMenuItem_3.setText("会员官网");
menu_1.add(newItemMenuItem_3); final JMenuItem newItemMenuItem_4 = new JMenuItem();
newItemMenuItem_4.setText("会员专区");
menu_1.add(newItemMenuItem_4); menu.addSeparator(); final JMenu menu_2 = new JMenu();
menu_2.setText("安全");
menu.add(menu_2); final JMenuItem newItemMenuItem_5 = new JMenuItem();
newItemMenuItem_5.setText("紧急冻结");
menu_2.add(newItemMenuItem_5); final JMenuItem newItemMenuItem_6 = new JMenuItem();
newItemMenuItem_6.setText("密码保护");
menu_2.add(newItemMenuItem_6); final JMenuItem newItemMenuItem_7 = new JMenuItem();
newItemMenuItem_7.setText("退出");
menu.add(newItemMenuItem_7);
final FlowLayout flowLayout_1 = new FlowLayout();
flowLayout_1.setAlignment(FlowLayout.RIGHT);
} /**
* WindowBuilder generated method.<br>
* Please don't remove this method or its invocations.<br>
* It used by WindowBuilder to associate the {@link javax.swing.JPopupMenu} with parent.
*/
private static void addPopup(Component component, final JPopupMenu popup) {
component.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
if (e.isPopupTrigger())
showMenu(e);
}
public void mouseReleased(MouseEvent e) {
if (e.isPopupTrigger())
showMenu(e);
}
private void showMenu(MouseEvent e) {
popup.show(e.getComponent(), e.getX(), e.getY());
}
});
}
}
java在线聊天项目 swt可视化窗口Design 重新设计好友列表窗口 增加菜单栏的更多相关文章
- java在线聊天项目 swt可视化窗口Design 好友列表窗口
熟练使用各种布局方式 FlowLayout 流布局 left center right等 BorderLayout 边框布局 east west sorth north center Absolute ...
- java在线聊天项目 swt可视化窗口Design 登录框注册按钮点击改变窗口大小——出现注册面板 实现打开登录框时屏幕居中
登录框注册按钮点击改变窗口大小——出现注册面板 首先用swt可视化设计登录窗口如下图: 此时窗口高度为578 没点击注册时高度为301(可自己定) 注意:注册用户的Jpanel 的border选择T ...
- java在线聊天项目 swt可视化窗口Design 重新设计聊天窗口
设计的聊天窗口如下: 制作过程: 首先,在默认的BorderLayout视图下, 上边也就是North处添加一个JPanel,将Layout调整为BorderLayout,West放一个JLabel用 ...
- java在线聊天项目 实现基本聊天功能后补充的其他功能详细需求分析 及所需要掌握的Java知识基础 SWT的激活方法,swt开发包下载,及破解激活码
补充聊天项目功能,做如下需求分析: 梳理项目开发所需的必要Java知识基础 GUI将使用更快速的swt实现 SWT(Standard Widget Toolkit) Standard Widget T ...
- java在线聊天项目 客户端登陆窗口LoginDialog的注册用户功能 修改注册逻辑 增空用户名密码的反馈 增加showMessageDialog()提示框
LoginDialog类的代码修改如下: package com.swift.frame; import java.awt.EventQueue; import java.awt.event.Acti ...
- java在线聊天项目0.9版 实现把服务端接收到的信息返回给每一个客户端窗口中显示功能之客户端接收
客户端要不断接收服务端发来的信息 与服务端不断接收客户端发来信息相同,使用线程的方法,在线程中循环接收 客户端修改后代码如下: package com.swift; import java.awt.B ...
- java在线聊天项目0.4版本 制作服务端接收连接,客户端连接功能 新增客户端窗口打开时光标指向下边文本域功能,使用WindowListener监听WindowAdapter
建一个服务端类ChatServer,用于设置端口接收连接 package com.swift; import java.io.IOException; import java.net.ServerSo ...
- java在线聊天项目1.1版 ——开启多个客户端,分别实现注册和登录功能,使用客户端与服务端信息request机制,重构线程,将单独的登录和注册线程合并
实现效果图: eclipse项目中初步整合之前的各个客户端和服务端的窗口与工具类,效果如下图: 已将注册服务器线程RegServer功能放到LoginServer中,使用客户端与服务端的request ...
- java在线聊天项目1.3版 ——设计好友列表框功能
设计好友列表框功能,思路—— 1.当客户端成功登陆后,则客户端把成功登陆信息发送给服务端, 2.由服务端将接收到来自各个成功登陆的客户端的用户信息添加进好友列表, 3.每当有成功登陆的用户就向各个客户 ...
随机推荐
- String.Format 大全
0.0的格式化 string.Format("{0:8D8}", 3)//第一个8表示空8个位置,后一个8表示用0填写最多8位数据 1.格式化货币(跟系统的环境有关,中文系统默认格 ...
- Codevs 1140 Jam的计数法
1140 Jam的计数法 题目描述 Description Jam是个喜欢标新立异的科学怪人.他不使用阿拉伯数字计数,而是使用小写英文字母计数,他觉得这样做,会使世界更加丰富多彩.在他的计数法中,每个 ...
- 洛谷P2480 [SDOI2010]古代猪文(卢卡斯定理+中国剩余定理)
传送门 好吧我数学差的好像不是一点半点…… 题目求的是$G^{\sum_{d|n}C^d_n}mod\ 999911659$ 我们可以利用费马小定理$a^{k}\equiv a^{k\ mod\ (p ...
- [Xcode 实际操作]九、实用进阶-(27)字符串文件(Localizable.strings)的本地化
目录:[Swift]Xcode实际操作 本文将演示字符串文件(Localizable.strings)的本地化. 在项目[DemoApp]文件夹下点击鼠标右键,弹出右键菜单 ->[New Fil ...
- [題解](最短路/二分)luogu_P1462通往奧格瑞瑪的道路
看到最大的最小值應該想到二分答案,這樣就解決了最小點權的問題,判血量就很好說,直接比較就行, 一個點是二分點權數組,複製一份然後排序,二分下標,速度較快 這麼簡單的題我竟然寫了這麼長時間 #inclu ...
- [題解]TYVJ_2032(搜索/最短路)
搜索:https://www.cnblogs.com/SiriusRen/p/6532506.html?tdsourcetag=s_pctim_aiomsg 來自 SiriusRen 數據範圍小,考慮 ...
- tcp端口扫描(python多线程)
1 使用单线程扫描单台主机 首先实现的是对单台主机中0-1024端口的扫描,发现差不多每秒扫描一个端口,很慢. import socket def tcp_scanner(host,port): cl ...
- 用apache commons-pool2建立thrift连接池
Apache Thrift 是 Facebook 实现的一种高效的.支持多种编程语言的远程服务调用的框架.具体的介绍可以看Apache的官方网站:http://thrift.apache.org/ . ...
- Dubbo端口占用错误信息
SEVERE: Exception sending context initialized event to listener instance of class com.common.SysCont ...
- HTML超链接的使用
基本语法 <a href="" target="打开方式" name="页面锚点名称">链接文字或图片</a> 属性 ...