求高人道破玄机!!!

咚咚来了 咚咚来了 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
package xiaomo;

import java.sql.*;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

class BuildButton extends JDialog{
static Connection con;
static PreparedStatement sql;

public BuildButton(MessageFace messageface,String title){

super(messageface,"Please finish writing .",true);

//利用箱式布局管理器设计Name栏mb
//Birthday标签
Box IDBox = Box.createHorizontalBox();
IDBox.add(Box.createHorizontalStrut(30));
JLabel IDLabel = new JLabel("ID:");
IDBox.add(IDLabel);

IDBox.add(Box.createHorizontalStrut(20));
final JTextField IDTextField = new JTextField(30);
IDBox.add(IDTextField);
IDBox.add(Box.createHorizontalStrut(200));

//Name标签
Box NameBox = Box.createHorizontalBox();
// container.add(NameBox,BorderLayout.NORTH);
NameBox.add(Box.createHorizontalStrut(30));
JLabel NameLabel = new JLabel("NAME:");
NameBox.add(NameLabel);


NameBox.add(Box.createHorizontalStrut(20));
final JTextField NameTextField = new JTextField(30);
NameBox.add(NameTextField);
NameBox.add(Box.createHorizontalStrut(200));

//Number标签
Box NumberBox = Box.createHorizontalBox();
NumberBox.add(Box.createHorizontalStrut(30));
JLabel NumberLabel = new JLabel("MobilePhone:");
NumberBox.add(NumberLabel);

NumberBox.add(Box.createHorizontalStrut(20));
final JTextField NumberTextField = new JTextField(30);
NumberBox.add(NumberTextField);
NumberBox.add(Box.createHorizontalStrut(200));

//QQNumber标签
Box QQNumberBox = Box.createHorizontalBox();
QQNumberBox.add(Box.createHorizontalStrut(30));
JLabel QQNumberLabel = new JLabel("QQNumber:");
QQNumberBox.add(QQNumberLabel);

QQNumberBox.add(Box.createHorizontalStrut(20));
final JTextField QQNumberTextField = new JTextField(30);
QQNumberBox.add(QQNumberTextField);
QQNumberBox.add(Box.createHorizontalStrut(200));

//Company标签
Box CompanyBox = Box.createHorizontalBox();
CompanyBox.add(Box.createHorizontalStrut(30));
JLabel CompanyLabel = new JLabel("Company:");
CompanyBox.add(CompanyLabel);

CompanyBox.add(Box.createHorizontalStrut(20));
final JTextField CompanyTextField = new JTextField(30);
CompanyBox.add(CompanyTextField);
CompanyBox.add(Box.createHorizontalStrut(200));

JButton b1 = new JButton("Finish");
JButton b2 = new JButton("Continue");

/*
* 要想使得JPanel面板划分窗体空间,
* 就必须使用网格布局管理器GridLayout和边界布局管理器BorderLayout
* 而且在添加组件是要注意:
* 先在container里对面板进行整体设置
* 而后在个面板中设置GridLayout
* 最后再添加到container中...
*/


//对container进行设置
Container container = getContentPane();
container.setLayout(new GridLayout(6,2,8,9));
setBounds(900, 50, 415, 220);
container.setBackground(Color.pink);

//对面板(容器的一种)进行设置
JPanel p1 = new JPanel(new GridLayout(1,2,8,9)); //行,列,水平,垂直
p1.setBackground(Color.pink);
JPanel p2 = new JPanel(new GridLayout(1,2,8,9));
p2.setBackground(Color.pink);
JPanel p3 = new JPanel(new GridLayout(1,2,8,9));
p3.setBackground(Color.pink);
JPanel p4 = new JPanel(new GridLayout(1,2,8,9));
p4.setBackground(Color.pink);
JPanel p5 = new JPanel(new GridLayout(1,2,8,9));
p5.setBackground(Color.pink);
JPanel p6 = new JPanel(new GridLayout(1,2));

//将组件添加到面板,再添加到container
p1.add(IDBox,BorderLayout.NORTH);
p1.add(IDTextField);

p2.add(NameBox,BorderLayout.NORTH);
p2.add(NameTextField);

p3.add(NumberBox,BorderLayout.NORTH);
p3.add(NumberTextField);

p4.add(QQNumberBox,BorderLayout.NORTH);
p4.add(QQNumberTextField);

p5.add(CompanyBox,BorderLayout.NORTH);
p5.add(CompanyTextField);

p6.add(b1,BorderLayout.NORTH);
p6.add(b2,BorderLayout.NORTH);

container.add(p1);
container.add(p2);
container.add(p3);
container.add(p4);
container.add(p5);
container.add(p6);

b1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0){



try {

sql = con.prepareStatement("insert into xiaomotable" + "values(?,?,?,?,?)");
sql.setString(1, IDTextField.getText());
sql.setString(2, NameTextField.getText());
sql.setString(3, NumberTextField.getText());
sql.setString(4, QQNumberTextField.getText());
sql.setString(5, CompanyTextField.getText());

} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}

});
}
}




此代码的错误反馈:
引用
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at xiaomo.BuildButton$1.actionPerformed(BuildButton.java:149)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.WaitDispatchSupport$2.run(Unknown Source)
at java.awt.WaitDispatchSupport$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.WaitDispatchSupport.enter(Unknown Source)
at java.awt.Dialog.show(Unknown Source)
at java.awt.Component.show(Unknown Source)
at java.awt.Component.setVisible(Unknown Source)
at java.awt.Window.setVisible(Unknown Source)
at java.awt.Dialog.setVisible(Unknown Source)
at xiaomo.MessageFace$1.actionPerformed(MessageFace.java:70)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
...全文

相关推荐

大盘深V生死劫:且看对冲基金经理雄文如何道破玄机.doc.pdf

大盘深V生死劫:且看对冲基金经理雄文如何道破玄机.doc

T0620514

【深度学习预测】项目介绍 Python实现基于BO-Transformer-LSTM贝叶斯优化算法(BO)优化Transformer-LSTM模型进行多变量时间序列预测(含模型描述及部分示例代码)

内容概要:本文详细介绍了一个基于BO-Transformer-LSTM的多变量时间序列预测项目,通过结合Transformer的全局自注意力机制与LSTM的局部时序建模能力,构建了适用于复杂业务场景的深度学习预测模型。模型输入采用多变量滑动窗口结构,并引入正弦余弦位置编码以保留时间顺序信息;Transformer编码器提取变量间长距离依赖关系,LSTM进一步捕捉动态演化特征,最终通过回归层输出预测值。为优化模型性能,采用贝叶斯优化算法(基于Tree-structured Parzen Estimator)自动搜索最优超参数组合,包括嵌入维度、注意力头数、学习率、窗口长度等,显著提升了调参效率与模型泛化能力。项目还设计了包含周期性、趋势性、均值回归、突发事件和异方差噪声的五因素模拟数据生成机制,确保数据贴近真实业务场景,并建立了从数据预处理、模型训练、验证评估到结果恢复的完整技术链路。; 适合人群:具备一定机器学习与深度学习基础,熟悉PyTorch框架,从事时间序列预测相关研究或工程应用的研发人员、数据科学家及研究生。; 使用场景及目标:①应用于能源负荷预测、设备状态监测、金融风控、供应链需求预测等多变量时间序列预测任务;②解决传统模型在长时依赖、非线性关系和高维特征下的预测瓶颈;③实现高效超参数优化,提升模型调优自动化水平与部署可行性。; 阅读建议:本文含核心模型结构与部分示例代码,建议结合完整项目代码(如GitHub或博客资源)进行复现实践,重点关注数据生成逻辑、模型前向传播流程及贝叶斯优化集成方式,同时可通过调整网络结构或优化策略进一步拓展至多步预测、概率输出与可视化分析等高级功能。

nantangyuxi

城市生命线之长距离输水管线的监测与检测.pdf

城市生命线之长距离输水管线的监测与检测.pdf

公众号:优享智库

复现水下航行器(NMPC)非线性模型预测控制分布式轨迹跟踪(Matlab代码实现)

内容概要:本文档围绕水下航行器(AUV)的非线性模型预测控制(NMPC)分布式轨迹跟踪技术展开,重点复现并实现了国际顶级期刊中提出的先进控制算法。该资源详细提供了基于Matlab的仿真代码,涵盖AUV的非线性动力学建模、多智能体系统协同控制、事件触发通信机制以及复杂海洋环境下分布式轨迹跟踪的优化求解过程。通过系统地构建NMPC控制器,实现对预设轨迹的高精度跟踪,同时有效处理系统约束与外部扰动。研究强调算法在多AUV协同任务中的适用性,突出其在节能通信与实时性方面的优势,是控制理论与工程实践相结合的典型范例; 适合人群:具备自动控制原理、非线性系统理论及Matlab编程基础的研究生、科研人员和工程技术开发者,尤其适用于从事水下机器人、智能控制、多智能体协同、路径规划与优化控制等方向的研究者; 使用场景及目标:① 深入理解非线性模型预测控制(NMPC)在欠驱动AUV轨迹跟踪中的设计与实现机制;② 复现并验证高水平学术论文中的控制策略,支撑科研创新与论文撰写;③ 探索事件触发机制下的分布式协同控制架构,提升多智能体系统的通信效率与控制性能; 阅读建议:建议结合现代控制理论相关教材与原始参考文献,逐行分析Matlab代码结构与算法流程,重点关注系统建模、代价函数构造、约束处理与优化求解器的调用方式。可通过调整控制参数、初始状态或引入环境干扰等方式进行仿真实验,以评估算法的鲁棒性、收敛性与工程实用性。

天天程序猿

AI大模型训练大规模智算中心建设方案.pdf

AI大模型训练大规模智算中心建设方案.pdf

公众号:优享智库
评论 15
收藏 已收藏
分享
返回顶部
咚咚来了
Eclipse 58,440 成员 49,457 内容