[C# WinForm设计]Panel布局及TabControl增加关闭按钮和Treeview导航 源码

article/2025/10/14 22:20:32

前段时间因工作需要做一个类似进销存的系统,这里要用到基于C/S架构的WinForm界面,为了给我一样的菜鸟多一个参考,现将过程及关键界面的实现代码贴在后面,供参考!老鸟飘过~~

一、实现效果 演示
namespace TabTest
{partial class TabTest{/// <summary>/// 必需的设计器变量。/// </summary>private System.ComponentModel.IContainer components = null;/// <summary>/// 清理所有正在使用的资源。/// </summary>/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>protected override void Dispose(bool disposing){if (disposing && (components != null)){components.Dispose();}base.Dispose(disposing);}#region Windows 窗体设计器生成的代码/// <summary>/// 设计器支持所需的方法 - 不要/// 使用代码编辑器修改此方法的内容。/// </summary>private void InitializeComponent(){System.Windows.Forms.TreeNode treeNode13 = new System.Windows.Forms.TreeNode("子节点1-1");System.Windows.Forms.TreeNode treeNode14 = new System.Windows.Forms.TreeNode("子节点1-2");System.Windows.Forms.TreeNode treeNode15 = new System.Windows.Forms.TreeNode("子节点1-3");System.Windows.Forms.TreeNode treeNode16 = new System.Windows.Forms.TreeNode("根节点1", new System.Windows.Forms.TreeNode[] {treeNode13,treeNode14,treeNode15});System.Windows.Forms.TreeNode treeNode17 = new System.Windows.Forms.TreeNode("子节点2-1");System.Windows.Forms.TreeNode treeNode18 = new System.Windows.Forms.TreeNode("根节点2", new System.Windows.Forms.TreeNode[] {treeNode17});System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(TabTest));this.treeView1 = new System.Windows.Forms.TreeView();this.MainTabControl = new System.Windows.Forms.TabControl();this.button1 = new System.Windows.Forms.Button();this.panel1 = new System.Windows.Forms.Panel();this.panel2 = new System.Windows.Forms.Panel();this.panel3 = new System.Windows.Forms.Panel();this.splitContainer1 = new System.Windows.Forms.SplitContainer();this.panel4 = new System.Windows.Forms.Panel();this.panel5 = new System.Windows.Forms.Panel();this.pictureBox1 = new System.Windows.Forms.PictureBox();this.label5 = new System.Windows.Forms.Label();this.tabPage5 = new System.Windows.Forms.TabPage();this.label4 = new System.Windows.Forms.Label();this.tabPage4 = new System.Windows.Forms.TabPage();this.label3 = new System.Windows.Forms.Label();this.tabPage3 = new System.Windows.Forms.TabPage();this.label2 = new System.Windows.Forms.Label();this.tabPage2 = new System.Windows.Forms.TabPage();this.MainTabControl.SuspendLayout();this.panel1.SuspendLayout();this.panel2.SuspendLayout();this.splitContainer1.Panel1.SuspendLayout();this.splitContainer1.Panel2.SuspendLayout();this.splitContainer1.SuspendLayout();this.panel4.SuspendLayout();this.panel5.SuspendLayout();((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();this.tabPage5.SuspendLayout();this.tabPage4.SuspendLayout();this.tabPage3.SuspendLayout();this.tabPage2.SuspendLayout();this.SuspendLayout();// // treeView1// this.treeView1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(224)))), ((int)(((byte)(192)))));this.treeView1.Dock = System.Windows.Forms.DockStyle.Fill;this.treeView1.Location = new System.Drawing.Point(0, 0);this.treeView1.Name = "treeView1";treeNode13.Name = "node1-1";treeNode13.Text = "子节点1-1";treeNode14.Name = "node1-2";treeNode14.Text = "子节点1-2";treeNode15.Name = "node1-3";treeNode15.Text = "子节点1-3";treeNode16.Name = "node1";treeNode16.Text = "根节点1";treeNode17.Name = "node2-1";treeNode17.Text = "子节点2-1";treeNode18.Name = "节点4";treeNode18.Text = "根节点2";this.treeView1.Nodes.AddRange(new System.Windows.Forms.TreeNode[] {treeNode16,treeNode18});this.treeView1.Size = new System.Drawing.Size(153, 441);this.treeView1.TabIndex = 1;this.treeView1.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView1_AfterSelect);// // MainTabControl// this.MainTabControl.Controls.Add(this.tabPage2);this.MainTabControl.Controls.Add(this.tabPage3);this.MainTabControl.Controls.Add(this.tabPage4);this.MainTabControl.Controls.Add(this.tabPage5);this.MainTabControl.Dock = System.Windows.Forms.DockStyle.Fill;this.MainTabControl.HotTrack = true;this.MainTabControl.ItemSize = new System.Drawing.Size(120, 22);this.MainTabControl.Location = new System.Drawing.Point(0, 0);this.MainTabControl.Name = "MainTabControl";this.MainTabControl.Padding = new System.Drawing.Point(3, 3);this.MainTabControl.RightToLeftLayout = true;this.MainTabControl.SelectedIndex = 0;this.MainTabControl.Size = new System.Drawing.Size(791, 441);this.MainTabControl.SizeMode = System.Windows.Forms.TabSizeMode.Fixed;this.MainTabControl.TabIndex = 0;// // button1// this.button1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));this.button1.Cursor = System.Windows.Forms.Cursors.VSplit;this.button1.Dock = System.Windows.Forms.DockStyle.Fill;this.button1.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));this.button1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(192)))));this.button1.Location = new System.Drawing.Point(0, 0);this.button1.Name = "button1";this.button1.Size = new System.Drawing.Size(22, 441);this.button1.TabIndex = 0;this.button1.Text = "<";this.button1.UseVisualStyleBackColor = false;this.button1.Click += new System.EventHandler(this.button1_Click_1);this.button1.MouseEnter += new System.EventHandler(this.button1_MouseEnter);// // panel1// this.panel1.BackColor = System.Drawing.Color.Gray;this.panel1.Controls.Add(this.pictureBox1);this.panel1.Dock = System.Windows.Forms.DockStyle.Top;this.panel1.Location = new System.Drawing.Point(0, 0);this.panel1.Name = "panel1";this.panel1.Size = new System.Drawing.Size(970, 72);this.panel1.TabIndex = 7;// // panel2// this.panel2.Controls.Add(this.splitContainer1);this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;this.panel2.Location = new System.Drawing.Point(0, 72);this.panel2.Name = "panel2";this.panel2.Size = new System.Drawing.Size(970, 441);this.panel2.TabIndex = 8;// // panel3// this.panel3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));this.panel3.Dock = System.Windows.Forms.DockStyle.Bottom;this.panel3.Location = new System.Drawing.Point(0, 469);this.panel3.Name = "panel3";this.panel3.Size = new System.Drawing.Size(970, 44);this.panel3.TabIndex = 9;// // splitContainer1// this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;this.splitContainer1.Location = new System.Drawing.Point(0, 0);this.splitContainer1.Name = "splitContainer1";// // splitContainer1.Panel1// this.splitContainer1.Panel1.Controls.Add(this.treeView1);// // splitContainer1.Panel2// this.splitContainer1.Panel2.Controls.Add(this.panel5);this.splitContainer1.Panel2.Controls.Add(this.panel4);this.splitContainer1.Size = new System.Drawing.Size(970, 441);this.splitContainer1.SplitterDistance = 153;this.splitContainer1.TabIndex = 0;// // panel4// this.panel4.Controls.Add(this.button1);this.panel4.Dock = System.Windows.Forms.DockStyle.Left;this.panel4.Location = new System.Drawing.Point(0, 0);this.panel4.Name = "panel4";this.panel4.Size = new System.Drawing.Size(22, 441);this.panel4.TabIndex = 1;// // panel5// this.panel5.Controls.Add(this.MainTabControl);this.panel5.Dock = System.Windows.Forms.DockStyle.Fill;this.panel5.Location = new System.Drawing.Point(22, 0);this.panel5.Name = "panel5";this.panel5.Size = new System.Drawing.Size(791, 441);this.panel5.TabIndex = 2;// // pictureBox1// this.pictureBox1.Dock = System.Windows.Forms.DockStyle.Fill;this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));this.pictureBox1.Location = new System.Drawing.Point(0, 0);this.pictureBox1.Name = "pictureBox1";this.pictureBox1.Size = new System.Drawing.Size(970, 72);this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;this.pictureBox1.TabIndex = 0;this.pictureBox1.TabStop = false;// // label5// this.label5.AutoSize = true;this.label5.Font = new System.Drawing.Font("微软雅黑", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));this.label5.Location = new System.Drawing.Point(288, 185);this.label5.Name = "label5";this.label5.Size = new System.Drawing.Size(0, 28);this.label5.TabIndex = 1;// // tabPage5// this.tabPage5.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(192)))));this.tabPage5.Controls.Add(this.label5);this.tabPage5.Location = new System.Drawing.Point(4, 26);this.tabPage5.Name = "tabPage5";this.tabPage5.Padding = new System.Windows.Forms.Padding(3);this.tabPage5.Size = new System.Drawing.Size(783, 411);this.tabPage5.TabIndex = 4;this.tabPage5.Text = "子节点2-1";// // label4// this.label4.AutoSize = true;this.label4.Font = new System.Drawing.Font("微软雅黑", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));this.label4.Location = new System.Drawing.Point(288, 185);this.label4.Name = "label4";this.label4.Size = new System.Drawing.Size(0, 28);this.label4.TabIndex = 1;// // tabPage4// this.tabPage4.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(192)))));this.tabPage4.Controls.Add(this.label4);this.tabPage4.Location = new System.Drawing.Point(4, 26);this.tabPage4.Name = "tabPage4";this.tabPage4.Padding = new System.Windows.Forms.Padding(3);this.tabPage4.Size = new System.Drawing.Size(783, 411);this.tabPage4.TabIndex = 3;this.tabPage4.Text = "子节点1-3";// // label3// this.label3.AutoSize = true;this.label3.Font = new System.Drawing.Font("微软雅黑", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));this.label3.Location = new System.Drawing.Point(288, 185);this.label3.Name = "label3";this.label3.Size = new System.Drawing.Size(0, 28);this.label3.TabIndex = 1;// // tabPage3// this.tabPage3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));this.tabPage3.Controls.Add(this.label3);this.tabPage3.Location = new System.Drawing.Point(4, 26);this.tabPage3.Name = "tabPage3";this.tabPage3.Padding = new System.Windows.Forms.Padding(3);this.tabPage3.Size = new System.Drawing.Size(783, 411);this.tabPage3.TabIndex = 2;this.tabPage3.Text = "子节点1-2";// // label2// this.label2.AutoSize = true;this.label2.Font = new System.Drawing.Font("微软雅黑", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));this.label2.Location = new System.Drawing.Point(76, 137);this.label2.Name = "label2";this.label2.Size = new System.Drawing.Size(0, 28);this.label2.TabIndex = 1;// // tabPage2// this.tabPage2.BackColor = System.Drawing.Color.White;this.tabPage2.Controls.Add(this.label2);this.tabPage2.Location = new System.Drawing.Point(4, 26);this.tabPage2.Name = "tabPage2";this.tabPage2.Padding = new System.Windows.Forms.Padding(3);this.tabPage2.Size = new System.Drawing.Size(783, 411);this.tabPage2.TabIndex = 1;this.tabPage2.Text = "子节点1-1";// // TabTest// this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;this.ClientSize = new System.Drawing.Size(970, 513);this.Controls.Add(this.panel3);this.Controls.Add(this.panel2);this.Controls.Add(this.panel1);this.Name = "TabTest";this.Text = "DEMO - Panel布局及TabControl增加关闭按钮和Treeview导航";this.Load += new System.EventHandler(this.TabTest_Load);this.MainTabControl.ResumeLayout(false);this.panel1.ResumeLayout(false);this.panel2.ResumeLayout(false);this.splitContainer1.Panel1.ResumeLayout(false);this.splitContainer1.Panel2.ResumeLayout(false);this.splitContainer1.ResumeLayout(false);this.panel4.ResumeLayout(false);this.panel5.ResumeLayout(false);((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();this.tabPage5.ResumeLayout(false);this.tabPage5.PerformLayout();this.tabPage4.ResumeLayout(false);this.tabPage4.PerformLayout();this.tabPage3.ResumeLayout(false);this.tabPage3.PerformLayout();this.tabPage2.ResumeLayout(false);this.tabPage2.PerformLayout();this.ResumeLayout(false);}#endregionprivate System.Windows.Forms.TreeView treeView1;private System.Windows.Forms.TabControl MainTabControl;private System.Windows.Forms.Button button1;private System.Windows.Forms.Panel panel1;private System.Windows.Forms.Panel panel2;private System.Windows.Forms.SplitContainer splitContainer1;private System.Windows.Forms.Panel panel3;private System.Windows.Forms.Panel panel5;private System.Windows.Forms.Panel panel4;private System.Windows.Forms.PictureBox pictureBox1;private System.Windows.Forms.TabPage tabPage2;private System.Windows.Forms.Label label2;private System.Windows.Forms.TabPage tabPage3;private System.Windows.Forms.Label label3;private System.Windows.Forms.TabPage tabPage4;private System.Windows.Forms.Label label4;private System.Windows.Forms.TabPage tabPage5;private System.Windows.Forms.Label label5;}
}

二、界面绘制代码Designer.cs

三、关键实现代码TabTest.cs

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace TabTest
{public partial class TabTest : Form{public TabTest(){InitializeComponent();//全部展开导航树this.treeView1.ExpandAll();//隐藏tabPagethis.tabPage2.Parent = null;this.tabPage3.Parent = null;this.tabPage4.Parent = null;this.tabPage5.Parent = null;}private void TabTest_Load(object sender, EventArgs e){//清空控件//this.MainTabControl.TabPages.Clear();//绘制的方式OwnerDrawFixed表示由窗体绘制大小也一样this.MainTabControl.DrawMode = TabDrawMode.OwnerDrawFixed;this.MainTabControl.Padding = new System.Drawing.Point(CLOSE_SIZE, CLOSE_SIZE);this.MainTabControl.DrawItem += new DrawItemEventHandler(this.MainTabControl_DrawItem);this.MainTabControl.MouseDown += new System.Windows.Forms.MouseEventHandler(this.MainTabControl_MouseDown);}const int CLOSE_SIZE = 15;//tabPage标签图片Bitmap image = new Bitmap("closeBlack.png");//绘制“X”号即关闭按钮private void MainTabControl_DrawItem(object sender, DrawItemEventArgs e){try{Rectangle myTabRect = this.MainTabControl.GetTabRect(e.Index);                //先添加TabPage属性   //e.Graphics.DrawString(this.MainTabControl.TabPages[e.Index].Text, new Font("微软雅黑", 12), SystemBrushes.ControlText, myTabRect.X + 2, myTabRect.Y + 2);//设置笔刷SolidBrush black = new SolidBrush(Color.Black);SolidBrush white = new SolidBrush(Color.White);//居中显示StringFormat stringFormat = new StringFormat();stringFormat.Alignment = StringAlignment.Center;//绘制背景颜色e.Graphics.FillRectangle(white, myTabRect);//设置文字颜色                e.Graphics.DrawString(this.MainTabControl.TabPages[e.Index].Text, new Font("微软雅黑", 10), black, myTabRect, stringFormat);//再画一个矩形框using (Pen p = new Pen(Color.White)){myTabRect.Offset(myTabRect.Width - (CLOSE_SIZE + 3), 2);myTabRect.Width = CLOSE_SIZE;myTabRect.Height = CLOSE_SIZE;e.Graphics.DrawRectangle(p, myTabRect);}//填充矩形框Color recColor = e.State == DrawItemState.Selected ? Color.Red : Color.White;using (Brush b = new SolidBrush(recColor)){e.Graphics.FillRectangle(b, myTabRect);}//画关闭符号using (Pen objpen = new Pen(Color.Black)){                    //使用图片Bitmap bt = new Bitmap(image);Point p5 = new Point(myTabRect.X, 4);e.Graphics.DrawImage(bt, p5);//e.Graphics.DrawString(this.MainTabControl.TabPages[e.Index].Text, this.Font, objpen.Brush, p5);}e.Graphics.Dispose();}catch (Exception){ }}//关闭按钮功能private void MainTabControl_MouseDown(object sender, MouseEventArgs e){if (e.Button == MouseButtons.Left){int x = e.X, y = e.Y;//计算关闭区域   Rectangle myTabRect = this.MainTabControl.GetTabRect(this.MainTabControl.SelectedIndex);myTabRect.Offset(myTabRect.Width - (CLOSE_SIZE + 3), 2);myTabRect.Width = CLOSE_SIZE;myTabRect.Height = CLOSE_SIZE;//如果鼠标在区域内就关闭选项卡   bool isClose = x > myTabRect.X && x < myTabRect.Right && y > myTabRect.Y && y < myTabRect.Bottom;if (isClose == true){this.MainTabControl.TabPages.Remove(this.MainTabControl.SelectedTab);}}}/// <summary>/// 折叠与还原Panel1/// </summary>/// <param name="sender"></param>/// <param name="e"></param>private void button1_Click_1(object sender, EventArgs e){string btntext = this.button1.Text;if (btntext == "<"){this.splitContainer1.Panel1Collapsed = true;this.button1.Text = ">";}else if (btntext == ">"){this.splitContainer1.Panel1Collapsed = false;this.button1.Text = "<";}}private void button1_MouseEnter(object sender, EventArgs e){ToolTip p = new ToolTip();p.ShowAlways = true;p.SetToolTip(this.button1, "点击展开和隐藏目录面版");}private void treeView1_AfterSelect(object sender, TreeViewEventArgs e){if (treeView1.SelectedNode != null){//string sn = treeView1.SelectedNode.Text;string sn = this.treeView1.SelectedNode.Name;if (sn == "node1-1"){this.tabPage2.Parent = this.MainTabControl; }else if (sn == "node1-2"){this.tabPage3.Parent = this.MainTabControl;}else if (sn == "node1-3"){this.tabPage4.Parent = this.MainTabControl;}else if (sn == "node2-1"){this.tabPage5.Parent = this.MainTabControl;}}}//双击选项卡关闭tab页面private void MainTabControl_MouseDoubleClick(object sender, EventArgs e) {MainTabControl.TabPages.Remove(MainTabControl.SelectedTab); }}
}

 

 

 

 


http://chatgpt.dhexx.cn/article/THu2hOtr.shtml

相关文章

C#Winform中如何将窗体显示在panel中

在窗体中我们有时候做美观就需要将一个窗体显示在panel或SplitContainer里的panel中如何实现呢&#xff1f; 代码&#xff1a; public void Showform(Form form) //定义方法 { //清除panel里面的其他窗体 this.splitContainer1.Panel2&#xff1a;要显示的panel this.splitCont…

从零开始学习CANoe(四)—— 设计panel

相关文章 从零开始学习CANoe&#xff08;一&#xff09;—— 新建工程从零开始学习CANoe&#xff08;二&#xff09;—— CANdb 创建 dbc文件从零开始学习CANoe&#xff08;三&#xff09;—— 系统变量的创建和使用从零开始学习CANoe&#xff08;四&#xff09;—— 设计pane…

winform无边框在panel上拖动窗口位置,改变窗口大小

将窗体的FormBorderStyles属性设置为None 窗体上放一个新的panel&#xff0c;设置Dock属性为Fill 创建变量 private bool isMouseDown false;//表示鼠标当前是否处于按下状态&#xff0c;初始值为否 MouseDirection direction MouseDirection.None;//表示拖动的方向&#x…

C# Winform Panel 内控件大小不随Panel大小改变设置

&#xff08;1&#xff09;将Anchor属性设置为&#xff1a;None &#xff08;2&#xff09;将AutoSize属性设置为&#xff1a;False 不过还存在一个问题点&#xff0c;就是Button的位置还是会随着Panel大小变化而改变。

Panel控件

今天小编来给大家介绍一下panel控件&#xff1b; 首先来看一下panel控件是什么? 是什么&#xff1a; Panel 控件提供了一种用于组织控件的分组机制。Panel 控件可被递归嵌套在 Form 控件&#xff08;Panel 控件最外面的容器&#xff09;中。面板呈现它本身包含的控件。 面板上…

UI的Panel面板

1.Panel panel控件又叫面板&#xff0c;该面板实际就是一个容器&#xff0c;在其上可放置其他UI控件 当移动该面板时&#xff0c;放在其中的UI控件会随着移动&#xff0c;这样更加合理与方便地移动与处理一组控件 当面板被创建时&#xff0c;会默认包含一个Image(Script) Sour…

Unity Panel 控件

Panel 容器组件又叫面板组件&#xff0c;实际上就是一个容器&#xff0c;在其中可以放置其他的UI元素。 注意&#xff0c;在Unity中&#xff0c;子物体的位置是相对于父物体的&#xff0c;而非绝对位置 在Panel的参数区中&#xff0c;除了空间位置这个常用参数外&#xff0c;我…

Linux系统之部署Linux管理面板1Panel

Linux系统之部署Linux管理面板1Panel 一、1Panel介绍1.1Panel简介2.1Panel特点 二、本地环境规划1.本此实践目的2.本地环境规划 三、检查本地环境1.检查操作系统版本2.检查系统内核版本 四、部署1Panel1.创建安装目录2.一键部署1Panel3.检查1Panel服务运行状态4.检查1Panel监听…

javasocket编程(javasocket通信)

Java网络编程&#xff0d;JavaSocket编程是什么呢&#xff1f; Socket传输模式 Sockets有两种主要的操作方式&#xff1a;面向连接的和无连接的。面向连接的sockets操作就像一部电话&#xff0c;他们必须建立一个连接和一人呼叫。所有的事情在到达时的顺序与它们出发时的顺序时…

(Android)JavaSocket编程,文件上传到服务器,客户端Android,服务器端J2SE

SD卡中有encrypt.png文件 在E盘可以看到&#xff0c;从模拟器SD卡中发送来的文件 服务器端代码&#xff0c;我这里是使用CMD命令演示的。服务端等待客户端连接&#xff0c;然后接收客户端的数据。包括文件名&#xff0c;大小&#xff0c;和文件数据。 import java.io.Buffered…

Java Socket实现文件传输

阿里云双11服务器优惠&#xff08;年度最佳优惠&#xff09;&#xff1a; A&#xff1a;1核2GB 1M 服务器年69元 B&#xff1a;1核2GB 1M 服务器三年180元 C&#xff1a;2核4GB 1~10M 服务器三年567元&#xff08;强烈推荐&#xff09; D&#xff1a;4核8GB 1~10M 服务器三年10…

Java Tcp(Socket、ServerSocket)

TCP所提供服务的主要特点&#xff1a; 面向连接的传输&#xff1b;端到端的通信&#xff1b;高可靠性&#xff0c;确保传输数据的正确性&#xff0c;不出现丢失或乱序&#xff1b;全双工方式传输&#xff1b;采用字节流方式&#xff0c;即以字节为单位传输字节序列&#xff1b…

【Socket】Java Socket通信(一)

前段时间在网上学习了Java Socket的应用编程。 端口 用于区分不同应用程序端口号范围065535&#xff0c;其中01023为系统所保留IP地址和端口号组成了所谓的Socket&#xff0c;Socket是网络上运行的程序之间双向通信链路的终结点&#xff0c;是TCP和UDP的基础http&#xff1a;…

java socket编程总结

java socket编程总结 说明一、TCP/IP协议模型二、获取IP相关信息InetAddressInetSocketAddressURL 三、TCP编程四、UDP编程五、关于TCP与UDP 说明 更新时间&#xff1a;2020/12/01 17:17&#xff0c;更新完基本内容 java的socket编程做一个总结&#xff0c;主要是面向Tcp和Ud…

Java Socket网络编程,你要的实验,我都有

JAVA Socket编程 目录 JAVA Socket编程多人聊天室客户端源代码服务器端源代码运行展示 邮件发送客户端运行展示 在线云笔记客户端窗口服务器端代码运行展示 多人聊天室 客户端源代码 import java.awt.BorderLayout; import java.awt.HeadlessException; import java.awt.event…

【Java高级】初探socket编程 ——JavaSocket连接与简单通信

新学期生活开始一段时间了&#xff0c;要继续学习一些新的技术&#xff08;这里指socket /doge&#xff09;&#xff0c;目标是尝试完成一个在线即时聊天的小程序&#xff08;尽量不咕&#xff09;。会更新一系列socket编程的技术文章&#xff0c;欢迎关注交流~ 那么千里之行&…

Java--Socket通信(双向,有界面)

服务端&#xff1a; import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStr…

JAVA 网络编程 Socket

网络&#xff1a;相互连接的计算机&#xff0c;带来的好处有共享资源&#xff0c;交换数据 IP地址&#xff1a;定位计算机地址 通常由网络地址主机地址组合 查看本机IP地址&#xff1a;电脑左下角输入CMD&#xff0c;回车在CMD界面输入ipconfig 127.0.0.1 测试本机网络配置 …

初识Java Socket编程

Java最初是作为网络编程语言出现的&#xff0c;其对网络提供了高度的支持&#xff0c;使得客户端和服务器的沟通变成了现实&#xff0c;而在网络编程中&#xff0c;使用最多的就是Socket。像大家熟悉的QQ、MSN都使用了Socket相关的技术。下面就让我们一起揭开Socket的神秘面纱。…

Java socket详解,看这一篇就够了

刚给大家讲解Java socket通信后&#xff0c;好多童鞋私信我&#xff0c;有好多地方不理解&#xff0c;看不明白。特抽时间整理一下&#xff0c;详细讲述Java socket通信原理和实现案例。整个过程楼主都是通过先简单明了的示例让大家了解整个基本原理&#xff0c;后慢慢接近生产…