Java online Chat Project swt Visual window design Redesign Chat window

Source: Internet
Author: User

The Chat window is designed as follows:

Production process:

first , in the default BorderLayout view,

Add a JPanel to the north, and adjust the layout to Borderlayout,west to put a jlabel for the photo,

Center again put a jpanel, layout adjustment for Borderlayout,center and South Parties a JLabel, respectively put user nickname and famous.

below The Imitation QQ is a up and down can split the size of the jsplitpane, adjust to vertical mode.

Under the splitter box, place a JPanel, set the layout to BorderLayout,

And then put Jpanel,jscrollpane,jpanel in the upper and lower places respectively.

Put a button on the top to align to the left, two buttons below to align to the right, and a jtextarea in the middle

Finally, put a jscrollpane on top of the splitter box and put a jtextarea inside.

The complete code is as follows:

 PackageCom.swift;Importjava.awt.BorderLayout;Importjava.awt.Dimension;ImportJava.awt.EventQueue;Importjava.awt.FlowLayout;ImportJavax.swing.ImageIcon;ImportJavax.swing.JButton;ImportJavax.swing.JDialog;ImportJavax.swing.JFrame;ImportJavax.swing.JLabel;ImportJavax.swing.JPanel;ImportJavax.swing.JScrollPane;ImportJavax.swing.JSplitPane;ImportJavax.swing.JTextArea;ImportJavax.swing.UIManager;Importjavax.swing.UnsupportedLookAndFeelException; Public classChatFrameextendsJFrame {PrivateJTextArea textarea_1; PrivateJTextArea TextArea;  Public Static voidMain (String args[]) {jframe.setdefaultlookandfeeldecorated (true); Jdialog.setdefaultlookandfeeldecorated (true); Try{Uimanager.setlookandfeel ("Javax.swing.plaf.nimbus.NimbusLookAndFeel"); } Catch(ClassNotFoundException E1) {//TODO auto-generated Catch blockE1.printstacktrace (); } Catch(instantiationexception E1) {//TODO auto-generated Catch blockE1.printstacktrace (); } Catch(illegalaccessexception E1) {//TODO auto-generated Catch blockE1.printstacktrace (); } Catch(unsupportedlookandfeelexception E1) {//TODO auto-generated Catch blockE1.printstacktrace (); } eventqueue.invokelater (NewRunnable () { Public voidrun () {Try{chatframe Frame=NewChatFrame (); Frame.setvisible (true); } Catch(Exception e) {e.printstacktrace ();    }            }        }); }     PublicChatFrame () {Super(); Settitle ("Swallow-Chat window"); SetBounds (100, 100, 558, 576);        Setdefaultcloseoperation (Jframe.exit_on_close); FinalJPanel Panel =NewJPanel (); Panel.setlayout (NewBorderLayout (5,5));        Getcontentpane (). Add (Panel, Borderlayout.north); FinalJLabel label =NewJLabel (NewImageIcon ("Images/logo.jpg"));        Panel.add (label, borderlayout.west); Label.settext ("New JLabel"); Label.setpreferredsize (NewDimension (74,74)); FinalJPanel Panel_1 =NewJPanel (); Panel_1.setlayout (NewBorderLayout ());        Panel.add (Panel_1, Borderlayout.center); FinalJLabel Advancingswiftlabel =NewJLabel (); Advancingswiftlabel.settext ("Advancing Swift");        Panel_1.add (Advancingswiftlabel, Borderlayout.center); FinalJLabel Neverwastetimelabel =NewJLabel (); Neverwastetimelabel.settext ("Never waste time any more");        Panel_1.add (Neverwastetimelabel, Borderlayout.south); FinalJSplitPane Splitpane =NewJSplitPane (); Splitpane.setdividerlocation (300);        Splitpane.setorientation (Jsplitpane.vertical_split);        Getcontentpane (). Add (Splitpane, borderlayout.center); FinalJPanel panel_2 =NewJPanel (); Panel_2.setlayout (NewBorderLayout ());        Splitpane.setrightcomponent (panel_2); FinalJPanel Panel_3 =NewJPanel (); FinalFlowLayout FlowLayout =NewFlowLayout ();        Flowlayout.setalignment (Flowlayout.left);        Panel_3.setlayout (FlowLayout);        Panel_2.add (Panel_3, Borderlayout.north); FinalJButton button =NewJButton (); Button.settext (Font);        Panel_3.add (button); FinalJPanel Panel_4 =NewJPanel (); FinalFlowLayout flowlayout_1 =NewFlowLayout ();        Flowlayout_1.setalignment (Flowlayout.right);        Panel_4.setlayout (flowlayout_1);        Panel_2.add (Panel_4, Borderlayout.south); FinalJButton button_1 =NewJButton (); Button_1.settext (Close);        Panel_4.add (button_1); FinalJButton button_2 =NewJButton (); Button_2.settext (Send);        Panel_4.add (button_2); FinalJScrollPane ScrollPane =NewJScrollPane ();        Panel_2.add (ScrollPane, Borderlayout.center); Textarea_1=NewJTextArea ();        Scrollpane.setviewportview (textarea_1); FinalJScrollPane scrollpane_1 =NewJScrollPane ();        Splitpane.setleftcomponent (scrollpane_1); TextArea=NewJTextArea ();    Scrollpane_1.setviewportview (TextArea); }}

Java online Chat Project swt Visual window design Redesign Chat window

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.