1. package com.xf.jf;
    2. import java.awt.Point;
    3. import javax.swing.*;
    4. import javax.swing.border.LineBorder;
    5. import com.xf.beans.UserInfo;
    6. import java.awt.BorderLayout;
    7. import java.awt.Color;
    8. import java.awt.Font;
    9. import java.awt.GridLayout;
    10. import java.awt.Image;
    11. import java.awt.event.*;
    12. import java.util.ArrayList;
    13. import java.util.List;
    14. /**
    15. * This code was edited or generated using CloudGarden's Jigloo
    16. * SWT/Swing GUI Builder, which is free for non-commercial
    17. * use. If Jigloo is being used commercially (ie, by a corporation,
    18. * company or business for any purpose whatever) then you
    19. * should purchase a license for each developer using Jigloo.
    20. * Please visit www.cloudgarden.com for details.
    21. * Use of Jigloo implies acceptance of these licensing terms.
    22. * A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
    23. * THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
    24. * LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
    25. */
    26. public class QQMainJFrame extends javax.swing.JFrame implements WindowListener {
    27. private JPanel jPanel1;
    28. private JButton jButton1;
    29. private JPanel jPanel6;
    30. private JScrollPane jScrollPane1;
    31. private JPopupMenu jPopupMenu1;
    32. private JLabel jLabel2;
    33. private JLabel jLabel1;
    34. private JButton jButton3;
    35. private JButton jButton2;
    36. private JPanel jPanel5;
    37. private JPanel jPanel4;
    38. private JPanel jPanel3;
    39. private JTabbedPane jTabbedPane1;
    40. private JPanel jPanel2;
    41. //添加好友图标
    42. private JLabel jLabel3;
    43. //右键菜单
    44. JPopupMenu jPopupMenu;
    45. JMenuItem jMenuItem1;//删除好友
    46. JMenuItem jMenuItem2;//删除所有好友
    47. //当前登录用户对象
    48. private UserInfo userInfo ;
    49. /**
    50. * Auto-generated main method to display this JFrame
    51. */
    52. /*
    53. public static void main(String[] args) {
    54. SwingUtilities.invokeLater(new Runnable() {
    55. public void run() {
    56. QQMainJFrame inst = new QQMainJFrame(null);
    57. inst.setLocationRelativeTo(null);
    58. inst.setVisible(true);
    59. }
    60. });
    61. }*/
    62. public QQMainJFrame(UserInfo userInfo) {
    63. super();
    64. this.userInfo=userInfo;
    65. initGUI();
    66. this.setResizable(false);//窗口大小不变
    67. //当窗口关闭的时候,不操作
    68. this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    69. //this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//界面关闭之后,同步关闭程序进程
    70. //添加关闭窗体按钮监听
    71. this.addWindowListener(this);
    72. }
    73. private void initGUI() {
    74. try {
    75. //修改关闭方式为:关闭窗口,退出程序
    76. setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    77. //固定窗口大小
    78. this.setResizable(false);
    79. //给窗口定位
    80. BorderLayout thisLayout = new BorderLayout();
    81. this.setLocation(new Point(800, 30));
    82. getContentPane().setLayout(thisLayout);
    83. {
    84. jPanel1 = new JPanel();
    85. getContentPane().add(jPanel1, BorderLayout.NORTH);
    86. jPanel1.setLayout(null);
    87. jPanel1.setPreferredSize(new java.awt.Dimension(394, 103));
    88. {
    89. jLabel1 = new JLabel();
    90. ImageIcon image1 = new ImageIcon(this.getClass().getResource("../images/QQfaces/LargeImage/"+this.userInfo.getFaceid()+".jpg"));
    91. //ImageIcon image1 = new ImageIcon("../images/1.jpg");
    92. image1.setImage(image1.getImage().getScaledInstance(69, 66, Image.SCALE_DEFAULT));
    93. jLabel1.setIcon(image1);
    94. jPanel1.add(jLabel1);
    95. jLabel1.setBounds(18, 22, 69, 66);
    96. //jLabel1.setBorder(new LineBorder(new java.awt.Color(255,0,128), 1, false));
    97. }
    98. {
    99. jLabel2 = new JLabel();
    100. jPanel1.add(jLabel2);
    101. jLabel2.setBounds(111, 31, 237, 49);
    102. jLabel2.setText(this.userInfo.getNickname());//当前用户昵称赋值
    103. jLabel2.setFont(new Font("微软雅黑", Font.BOLD, 20));
    104. jLabel2.setForeground(Color.BLACK);
    105. }
    106. {
    107. JLabel state = new JLabel();
    108. jPanel1.add(state);
    109. state.setBounds(111, 75, 237, 20);
    110. state.setText("在线");
    111. state.setFont(new Font("微软雅黑", Font.PLAIN, 20));
    112. state.setForeground(Color.green);
    113. }
    114. }
    115. {
    116. jPanel2 = new JPanel();
    117. getContentPane().add(jPanel2, BorderLayout.SOUTH);
    118. jPanel2.setLayout(null);
    119. jPanel2.setPreferredSize(new java.awt.Dimension(394, 40));
    120. jLabel3 = new JLabel(new ImageIcon("images/FormImage/Search.jpg"));
    121. //jLabel3 = new JLabel(new ImageIcon("../images/1.jpg"));
    122. //../images/1.jpg
    123. jPanel2.add(jLabel3);
    124. //设置图标的位置
    125. jLabel3.setBounds(12, 4, 28, 24);
    126. }
    127. {
    128. jTabbedPane1 = new JTabbedPane();
    129. getContentPane().add(jTabbedPane1, BorderLayout.CENTER);
    130. jTabbedPane1.setOpaque(true);
    131. {
    132. jPanel3 = new JPanel();
    133. BorderLayout jPanel3Layout = new BorderLayout();
    134. jTabbedPane1.addTab("好友", null, jPanel3, null);
    135. jPanel3.setLayout(jPanel3Layout);
    136. {
    137. jButton1 = new JButton();
    138. jPanel3.add(jButton1, BorderLayout.NORTH);
    139. jButton1.setText("\u597d\u53cb");
    140. }
    141. {
    142. jPanel5 = new JPanel();
    143. GridLayout jPanel5Layout = new GridLayout(2, 1);
    144. jPanel5Layout.setColumns(1);
    145. jPanel5Layout.setRows(2);
    146. jPanel3.add(jPanel5, BorderLayout.SOUTH);
    147. jPanel5.setLayout(jPanel5Layout);
    148. jPanel5.setPreferredSize(new java.awt.Dimension(389, 75));
    149. {
    150. jButton2 = new JButton();
    151. jPanel5.add(jButton2);
    152. jButton2.setText("\u964c\u751f\u4eba");
    153. jButton2.setPreferredSize(new java.awt.Dimension(389, 31));
    154. }
    155. {
    156. jButton3 = new JButton();
    157. jPanel5.add(jButton3);
    158. jButton3.setText("\u9ed1\u540d\u5355");
    159. jButton3.setPreferredSize(new java.awt.Dimension(389, 33));
    160. }
    161. }
    162. {
    163. jScrollPane1 = new JScrollPane();
    164. jPanel3.add(jScrollPane1, BorderLayout.CENTER);
    165. {
    166. jPanel6 = new JPanel();
    167. //new GridLayout(行数, 列数, 水平间距,垂直间距);
    168. GridLayout jPanel6Layout = new GridLayout(50, 1, 0,10);
    169. //循环创建50个好友
    170. JLabel[] jls = new JLabel[50];
    171. for(int i=0;i<jls.length;i++){
    172. //new JLabel(文本,图片地址,放的位置);
    173. jls[i] = new JLabel("好友"+(i+1), new ImageIcon("images/QQfaces/LargeImage/12.jpg"), JLabel.LEFT);
    174. jPanel6.add(jls[i]);
    175. }
    176. jPanel6.setLayout(jPanel6Layout);
    177. //把面板放到滚动面板里
    178. jScrollPane1.setViewportView(jPanel6);
    179. //创建右键菜单 : 删除好友,删除所有好友
    180. jPopupMenu = new JPopupMenu();
    181. //创建2个右键菜单项目
    182. jMenuItem1 = new JMenuItem();
    183. jMenuItem1.setText("删除好友");
    184. jMenuItem2 = new JMenuItem();
    185. jMenuItem2.setText("删除所有好友");
    186. jPopupMenu.add(jMenuItem1);
    187. jPopupMenu.add(jMenuItem2);
    188. //把jPopupMenu放到jsp1里
    189. jScrollPane1.setComponentPopupMenu(jPopupMenu);
    190. //把jPopupMenu放到jphy2里
    191. jPanel6.setComponentPopupMenu(jPopupMenu);
    192. }
    193. }
    194. }
    195. {
    196. jPanel4 = new JPanel();
    197. jTabbedPane1.addTab("群组", null, jPanel4, null);
    198. jPanel4.setLayout(null);
    199. }
    200. }
    201. pack();
    202. setSize(400, 800);
    203. } catch (Exception e) {
    204. e.printStackTrace();
    205. }
    206. }
    207. public void loadJF() {
    208. }
    209. @Override
    210. public void windowOpened(WindowEvent e) {
    211. }
    212. //点击关闭按钮时触发
    213. @Override
    214. public void windowClosing(WindowEvent e) {
    215. //提示是否关闭qq界面
    216. int i=JOptionPane.showConfirmDialog(QQMainJFrame.this,"您是否确定要关闭盗版OICQ","",JOptionPane.OK_CANCEL_OPTION);
    217. //根据选项关闭qq主界面,
    218. if(i==0){
    219. System.exit(0);//退出程序
    220. }
    221. }
    222. @Override
    223. public void windowClosed(WindowEvent e) {
    224. }
    225. @Override
    226. public void windowIconified(WindowEvent e) {
    227. }
    228. @Override
    229. public void windowDeiconified(WindowEvent e) {
    230. }
    231. @Override
    232. public void windowActivated(WindowEvent e) {
    233. }
    234. @Override
    235. public void windowDeactivated(WindowEvent e) {
    236. }
    237. }