- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我使用java swing设计了一个表单。但我不知道如何将它部署在网站中。我创建的表单是“.java”扩展名,如何将它部署在网页中?我真的很陌生网络开发。我知道这可能是一个奇怪的问题,但我仍然无法在任何地方找到我想要的东西,所以这就是为什么我在这里问这个。如果有人可以帮助我。我已经给出了我的部分代码
package Students;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.ResultSet;
import javax.swing.JOptionPane;
/**
*
* @author user
*/
public class student extends javax.swing.JFrame {
Connection con;
Statement stmt;
ResultSet rs;
int curRow = 0;
/** Creates new form student */
public student() {
initComponents();
DoConnect();
}
public void DoConnect( ) {
try{
//connect to a database
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/student","root","");
//Execute some sql and load the recrds into result set
stmt = con.createStatement( ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE );
String sql="SELECT * FROM students";
rs=stmt.executeQuery(sql);
rs.next();
int id_col=rs.getInt("ID");
String id=Integer.toString(id_col);
String name=rs.getString("Name");
String address=rs.getString("Address");
String course=rs.getString("Course");
String semester=rs.getString("Semester");
//Display the first record in the text fields
jTextField1.setText(id);
jTextField2.setText(name);
jTextField3.setText(address);
jTextField4.setText(course);
jTextField5.setText(semester);
}
catch(SQLException err){
JOptionPane.showMessageDialog(student.this,err.getMessage());
}
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jTextField1 = new javax.swing.JTextField();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jTextField2 = new javax.swing.JTextField();
jTextField3 = new javax.swing.JTextField();
jTextField4 = new javax.swing.JTextField();
jTextField5 = new javax.swing.JTextField();
jPanel1 = new javax.swing.JPanel();
btnPrevious = new javax.swing.JButton();
btnNext = new javax.swing.JButton();
btnLast = new javax.swing.JButton();
btnFirst = new javax.swing.JButton();
jPanel2 = new javax.swing.JPanel();
btnNewRecord = new javax.swing.JButton();
btnDeleteRecord = new javax.swing.JButton();
btnSaveRecord = new javax.swing.JButton();
btnCancelNewRecord = new javax.swing.JButton();
btnUpdateRecord = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jTextField1.setText("id");
jTextField1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField1ActionPerformed(evt);
}
});
jLabel1.setText("ID");
jLabel2.setText("Name");
jLabel3.setText("Address");
jLabel4.setText("Course");
jLabel5.setText("Semester");
jTextField2.setText("name");
jTextField3.setText("add");
jTextField4.setText("cs");
jTextField5.setText("sem");
btnPrevious.setText("Next");
btnPrevious.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnPreviousActionPerformed(evt);
}
});
btnNext.setText("Previous");
btnNext.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnNextActionPerformed(evt);
}
});
btnLast.setText("First");
btnLast.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnLastActionPerformed(evt);
}
});
btnFirst.setText("Last");
btnFirst.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnFirstActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(btnPrevious, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btnLast, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 125, Short.MAX_VALUE))
.addContainerGap(18, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(btnNext, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 125, Short.MAX_VALUE)
.addComponent(btnFirst, javax.swing.GroupLayout.DEFAULT_SIZE, 125, Short.MAX_VALUE))
.addGap(18, 18, 18))))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(btnLast)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnPrevious)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(btnNext)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnFirst)
.addContainerGap(16, Short.MAX_VALUE))
);
btnNewRecord.setText("New Record");
btnNewRecord.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnNewRecordActionPerformed(evt);
}
});
btnDeleteRecord.setText("Delete Record");
btnDeleteRecord.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnDeleteRecordActionPerformed(evt);
}
});
btnSaveRecord.setText("Save New Record");
btnSaveRecord.setEnabled(false);
btnSaveRecord.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnSaveRecordActionPerformed(evt);
}
});
btnCancelNewRecord.setText("Cancel New Record");
btnCancelNewRecord.setEnabled(false);
btnCancelNewRecord.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnCancelNewRecordActionPerformed(evt);
}
});
btnUpdateRecord.setText("Update Record");
btnUpdateRecord.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnUpdateRecordActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(btnUpdateRecord, javax.swing.GroupLayout.DEFAULT_SIZE, 125, Short.MAX_VALUE)
.addComponent(btnNewRecord, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 125, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(btnDeleteRecord, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btnCancelNewRecord, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btnSaveRecord, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.addContainerGap())
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(40, 40, 40)
.addComponent(btnNewRecord, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(btnDeleteRecord)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(btnSaveRecord)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(btnCancelNewRecord)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(btnUpdateRecord)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addGap(11, 11, 11)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.addContainerGap())
);
pack();
}// </editor-fold>
private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void btnFirstActionPerformed(java.awt.event.ActionEvent evt) {
try {
rs.first( ) ;
int id_col=rs.getInt("ID");
String id=Integer.toString(id_col);
String name=rs.getString("Name");
String address=rs.getString("Address");
String course=rs.getString("Course");
String semester=rs.getString("Semester");
//Display the first record in the text fields
jTextField1.setText(id);
jTextField2.setText(name);
jTextField3.setText(address);
jTextField4.setText(course);
jTextField5.setText(semester);
}
catch (SQLException err) {
JOptionPane.showMessageDialog(student.this, err.getMessage()); // TODO add your handling gcode here:
}
}
private void btnNextActionPerformed(java.awt.event.ActionEvent evt) {
try {
if ( rs.next( ) ) {
int id_col=rs.getInt("ID");
String id=Integer.toString(id_col);
String name=rs.getString("Name");
String address=rs.getString("Address");
String course=rs.getString("Course");
String semester=rs.getString("Semester");
//Display the first record in the text fields
jTextField1.setText(id);
jTextField2.setText(name);
jTextField3.setText(address);
jTextField4.setText(course);
jTextField5.setText(semester);
}
else {
rs.previous( );
JOptionPane.showMessageDialog(student.this, "First of File");
}
}
catch (SQLException err) {
JOptionPane.showMessageDialog(student.this, err.getMessage());
} // TODO add your handling code here:
}
private void btnPreviousActionPerformed(java.awt.event.ActionEvent evt) {
try {
if ( rs.previous( ) ) {
int id_col=rs.getInt("ID");
String id=Integer.toString(id_col);
String name=rs.getString("Name");
String address=rs.getString("Address");
String course=rs.getString("Course");
String semester=rs.getString("Semester");
//Display the first record in the text fields
jTextField1.setText(id);
jTextField2.setText(name);
jTextField3.setText(address);
jTextField4.setText(course);
jTextField5.setText(semester);
}
else {
rs.next( );
JOptionPane.showMessageDialog(student.this, "End of File");
}
}
catch (SQLException err) {
JOptionPane.showMessageDialog(student.this, err.getMessage());
} // TODO add your handling code here:
}
private void btnLastActionPerformed(java.awt.event.ActionEvent evt) {
try {
rs.last( ) ;
int id_col=rs.getInt("ID");
String id=Integer.toString(id_col);
String name=rs.getString("Name");
String address=rs.getString("Address");
String course=rs.getString("Course");
String semester=rs.getString("Semester");
//Display the first record in the text fields
jTextField1.setText(id);
jTextField2.setText(name);
jTextField3.setText(address);
jTextField4.setText(course);
jTextField5.setText(semester);
}
catch (SQLException err) {
JOptionPane.showMessageDialog(student.this, err.getMessage()); // TODO add your handling gcode here:
} // TODO add your handling code here:
}
private void btnNewRecordActionPerformed(java.awt.event.ActionEvent evt) {
btnFirst.setEnabled( false );
btnPrevious.setEnabled( false ) ;
btnNext.setEnabled( false );
btnLast.setEnabled( false );
btnUpdateRecord.setEnabled( false );
btnDeleteRecord.setEnabled( false );
btnNewRecord.setEnabled( false );
btnSaveRecord.setEnabled( true );
btnCancelNewRecord.setEnabled( true );
try{
curRow = rs.getRow( );
jTextField1.setText("");
jTextField2.setText("");
jTextField3.setText("");
jTextField4.setText("");
jTextField5.setText("");
}catch(SQLException err){
System.out.println(err.getMessage());
}
}
private void btnSaveRecordActionPerformed(java.awt.event.ActionEvent evt) {
JOptionPane.showMessageDialog(student.this, "Saved !");
btnFirst.setEnabled( true );
btnPrevious.setEnabled( true ) ;
btnNext.setEnabled( true );
btnLast.setEnabled( true );
btnUpdateRecord.setEnabled( true );
btnDeleteRecord.setEnabled( true );
btnNewRecord.setEnabled( true );
btnSaveRecord.setEnabled( false );
btnCancelNewRecord.setEnabled( false );
String name = jTextField2.getText( );
String address =jTextField3.getText( );
String course = jTextField4.getText( );
String ID =jTextField1.getText();
String semester=jTextField5.getText();
int newID = Integer.parseInt( ID );
try{
rs.moveToInsertRow();
rs.updateInt("ID", newID);
rs.updateString("Name", name);
rs.updateString("Address", address);
rs.updateString("Course", course);
rs.updateString("Semester", semester);
rs.insertRow();
stmt.close();
rs.close();
stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
String sql = "SELECT * FROM students";
rs = stmt.executeQuery(sql);
rs.next( );
int id_col = rs.getInt("ID");
String id=Integer.toString(id_col);
String name1=rs.getString("Name");
String address1=rs.getString("Address");
String course1=rs.getString("Course");
String semester1=rs.getString("Semester");
jTextField1.setText(id);
jTextField2.setText(name1);
jTextField3.setText(address1);
jTextField4.setText(course1);
jTextField5.setText(semester1);
}catch(SQLException err){
System.out.println(err.getMessage());
}// TODO add your handling code here:
}
private void btnUpdateRecordActionPerformed(java.awt.event.ActionEvent evt) {
String name = jTextField2.getText( );
String address =jTextField3.getText( );
String course = jTextField4.getText( );
String ID =jTextField1.getText();
String semester=jTextField5.getText();
int newID = Integer.parseInt( ID );
try {
rs.updateInt( "ID", newID );
rs.updateString( "Name", name );
rs.updateString( "Address", address );
rs.updateString( "Course", course );
rs.updateString("Semester", semester);
rs.updateRow( );
JOptionPane.showMessageDialog(student.this, "Updated");
}
catch (SQLException err) {
System.out.println(err.getMessage() );
}
// TODO add your handling code here:
}
private void btnCancelNewRecordActionPerformed(java.awt.event.ActionEvent evt) {
btnFirst.setEnabled( true );
btnPrevious.setEnabled( true ) ;
btnNext.setEnabled( true );
btnLast.setEnabled( true );
btnUpdateRecord.setEnabled( true );
btnDeleteRecord.setEnabled( true );
btnNewRecord.setEnabled( true );
btnSaveRecord.setEnabled( false );
btnCancelNewRecord.setEnabled( false );
try{
rs.absolute( curRow );
jTextField1.setText(rs.getString("ID"));
jTextField2.setText(rs.getString("Name"));
jTextField3.setText(rs.getString("Address"));
jTextField4.setText(rs.getString("Course"));
jTextField5.setText(rs.getString("Semester"));
}catch(SQLException err){
System.out.println(err.getMessage());
}// TODO add your handling code here:
}
private void btnDeleteRecordActionPerformed(java.awt.event.ActionEvent evt) {
try{
rs.deleteRow();
stmt.close();
rs.close();
stmt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql="SELECT * FROM students";
rs=stmt.executeQuery(sql);
rs.next();
int col_id=rs.getInt("ID");
String id=Integer.toString(col_id);
String name=rs.getString("Name");
String address=rs.getString("Address");
String course=rs.getString("Course");
String semester=rs.getString("Semester");
jTextField1.setText(rs.getString(id));
jTextField2.setText(rs.getString(name));
jTextField3.setText(rs.getString(address));
jTextField4.setText(rs.getString(course));
jTextField5.setText(rs.getString(semester));
}catch(SQLException err)
{
System.out.println(err.getMessage());
}
// TODO add your handling code here:
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new student().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton btnCancelNewRecord;
private javax.swing.JButton btnDeleteRecord;
private javax.swing.JButton btnFirst;
private javax.swing.JButton btnLast;
private javax.swing.JButton btnNewRecord;
private javax.swing.JButton btnNext;
private javax.swing.JButton btnPrevious;
private javax.swing.JButton btnSaveRecord;
private javax.swing.JButton btnUpdateRecord;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
}
最佳答案
您可以使用JApplet为此目的和 embedded it to a page .
关于java - 在网站中部署使用 swing 创建的表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20066082/
我在 *.sql 文件中得到了我的数据库转储(表、函数、触发器等)。此时我正在通过 jenkins 部署它们,通过传递执行 shell 命令: sudo -u postgres psql -d my_
我正在使用网络部署 API 来部署网络包(.zip 文件,由 MSDeploy.exe 创建)以编程方式将包发布到服务器(在发布包之前我们需要做一些其他事情这就是为什么我们不使用 MSDeploy.e
我们正在使用 Web Deploy 3 的(几乎完全未记录的)“公共(public) API”来创建我们网站的 .zip 包,然后将其同步到服务器: DeploymentBaseOptions des
将 clojure 应用程序制作成可执行文件的最简单方法是什么,例如 http://rawr.rubyforge.org/ ruby 吗? (exe 和 app 文件也是) 最佳答案 使用 leini
是否可以下载 Android 源代码并针对任何设备进行编译? 我想做的是尝试 GSM 代码部分并编译操作系统并将其部署到我的摩托罗拉手机上。 谢谢! 最佳答案 是的,但这很难,因为大多数手机不共享驱动
我正在考虑用 c/c++ 编写需要在大多数个人计算机上运行的 nbody 样式模拟。本质上是一个 O(n^2) 粒子模拟器。 因为这需要相当用户友好,所以我希望有 1 个不需要用户安装任何东西的 Wi
需要了解 kubernetes 部署中 kube_deployment_status_replicas 和 kube_deployment_spec_replicas 指标的区别 最佳答案 简而言之,
我正在尝试使用分类器部署 Maven Artifact 。由于我需要源代码和 JAR(我从 GWT 使用它),我想获得 artifact-version-classifier.jar 和 artifa
我设置部署以将我的项目代码与存储我的网站的 FTP 服务器上的项目同步。 但是,每次尝试同步时,我总是必须登录。 我什至检查了记住,但它不起作用! 我正在使用最新的 PhpStorm 2017.1.4
我在 Visual Studio 2008 中开发了一个 ASP.NET 网站。现在我想在其他机器上部署它。我怎样才能做到这一点??就像我们为 Windows 应用程序制作安装包一样,我们可以为 AS
将 QT 框架添加到我的 .app 包中 我正在关注 Qt 站点上关于部署的文档。 我创建了一个名为 HTTPClient.app 的应用程序 我在 Contents 下创建了 Framework 文
这个问题不太可能对任何 future 的访客有帮助;它只与一个小的地理区域、一个特定的时间点或一个非常狭窄的情况相关,通常不适用于互联网的全局受众。如需帮助使这个问题更广泛适用,visit the h
我正在研究改变我目前创建营销网站的策略。目前,我完全用 PHP 从头开始构建网站,使用一个简单的包含系统。所有代码(以及内容)都存储在文件(而不是数据库)中,允许我使用 Subversion 进行
我有一个长期运行的服务(在 while 1 循环中)并通过 GCloud pub/sub 处理有效负载,之后它将结果写入数据库。 该服务不需要监听任何端口。 Kind=Deployment 的声明性
似乎部署已停滞不前。我该如何进一步诊断? kubectl rollout status deployment/wordpress Waiting for rollout to finish: 2 ou
我正在Dart中使用前端的Angular和后端的Shelf构建一个客户端/服务器应用程序。当我执行pub build时,它会按预期生成Dart文件的javascript,但不会替换HTML文件中的Da
我在 Azure 部署中心的下拉列表中看不到我的所有 Github 组织存储库。 Azure 很久以前就已经被授权了,下拉列表正确地显示了所有的存储库,直到上周我在 DevOps 中玩游戏时,不得不再
我认为标题几乎说明了一切...对于 Deployd 来说是全新的,所以任何关于如何最好地实现这一点的指示都值得赞赏。 最佳答案 要获取用户创建的集合中的对象(我假设您使用的是 javascript 库
我有一个试图用于CD服务器的部署脚本,但是在编写bash脚本以完成一些所需的步骤(例如运行npm和迁移命令)时遇到了问题。 我将如何从该脚本进入容器bash,运行下面的命令,然后退出以完成对更改的提取
我想在使用 kubectl 时将参数传递给 Kubernetes 部署命令应用部署文件。 示例:在我的部署 .yaml 中,我有如下参数,我想在使用 kubectl apply - f .yaml 运
我是一名优秀的程序员,十分优秀!