java语言。编写一个学生成绩管理应用程序,在数据库中建立3张表:Student(id,name,

java语言。编写一个学生成绩管理应用程序,在数据库中建立3张表:Student(id,name,,第1张

给你参考一下我们专业老师写过的程序 如果不懂可以加 裙哦

java语言 /

@author ougaoyan ,date:2008-9-28

学生登录主界面

/

package comsystemjiemian;import javaawtBorderLayout;

import javaawtColor;

import javaawteventActionEvent;

import javaawteventActionListener;import javaxswingImageIcon;

import javaxswingJButton;

import javaxswingJDesktopPane;

import javaxswingJFrame;

import javaxswingJInternalFrame;

import javaxswingJMenu;

import javaxswingJMenuBar;

import javaxswingJMenuItem;

import javaxswingJToolBar;

import javaxswingWindowConstants;

import javaxswingborderBevelBorder;public class StudentMainFrame extends JFrame{

private static final long serialVersionUID = 1696099952059929396L;

private static final JDesktopPane DESKTOP_PANE = new JDesktopPane();

public StudentMainFrame() {

super();

setDefaultCloseOperation(WindowConstantsEXIT_ON_CLOSE); //设置窗口的关闭模式

setLocationByPlatform(true);

setSize(800, 600);

setTitle("学生成绩管理系统");

JMenuBar menuBar = createMenu(); // 调用创建菜单栏的方法

setJMenuBar(menuBar); //将菜单栏加入窗口

JToolBar toolBar = createToolBar(); // 调用创建工具栏的方法

getContentPane()add(toolBar, BorderLayoutNORTH); //将工具栏按固定布局加入窗口

DESKTOP_PANEsetBackground(ColorDARK_GRAY); //设置DESKTOP_PANE的背景色

getContentPane()add(DESKTOP_PANE ); //将DESKTOP_PANE加入窗口

setVisible(true);

}

/

创建工具栏

@return JToolBar

/

private JToolBar createToolBar() { // 创建工具栏的方法

JToolBar toolBar = new JToolBar();

toolBarsetFloatable(false);

toolBarsetBorder(new BevelBorder(BevelBorderRAISED));

JButton infomationManageButton=new JButton("个人信息管理"); //个人信息管理按钮

ImageIcon icon=new ImageIcon("res/gongjulan5jpg");//创建图标方法

infomationManageButtonsetIcon(icon);

infomationManageButtonsetHideActionText(true);

infomationManageButtonaddActionListener(new ActionListener(){ //为学年个人信息管理工具按钮添加监听器

public void actionPerformed(ActionEvent arg0) {

StudentMainFrameaddIFame(new StudentQueryInfoIFrame());

}});

toolBaradd(infomationManageButton);

JButton queryScoresByYearButton=new JButton("学年成绩查询"); //学年成绩查询按钮

ImageIcon queryScoresIcon1=new ImageIcon("res/gongjulan1jpg");//创建图标方法

queryScoresByYearButtonsetIcon(queryScoresIcon1);

queryScoresByYearButtonsetHideActionText(true);

queryScoresByYearButtonaddActionListener(new ActionListener(){ //为学年成绩查询工具按钮添加监听器

public void actionPerformed(ActionEvent arg0) {

StudentMainFrameaddIFame(new QueryScoreByYearIFrame());

}});

toolBaradd(queryScoresByYearButton);

JButton queryScoresByTermButton=new JButton("学期成绩查询"); //学期成绩查询按钮

ImageIcon queryScoresIcon2=new ImageIcon("res/gongjulan3jpg");//创建图标方法

queryScoresByTermButtonsetIcon(queryScoresIcon2);

queryScoresByTermButtonsetHideActionText(true);

queryScoresByTermButtonaddActionListener(new ActionListener(){ //为学期成绩查询工具按钮添加监听器

public void actionPerformed(ActionEvent arg0) {

StudentMainFrameaddIFame(new QueryScoreByTermIFrame());

}});

toolBaradd(queryScoresByTermButton);

JButton queryScoresByAllButton=new JButton("综合成绩查询"); //总成绩查询按钮

ImageIcon queryScoresIcon3=new ImageIcon("res/gongjulan2jpg");//创建图标方法

queryScoresByAllButtonsetIcon(queryScoresIcon3);

queryScoresByAllButtonsetHideActionText(true);

queryScoresByAllButtonaddActionListener(new ActionListener(){

public void actionPerformed(ActionEvent arg0) {

StudentMainFrameaddIFame(new QueryScoreByAllIFrame());

}});

toolBaradd( queryScoresByAllButton);

return toolBar;

}/Method createToolBar/

/

创建菜单栏

/

private JMenuBar createMenu() { // 创建菜单栏的方法

JMenuBar menuBar = new JMenuBar();

JMenu jibenxinxiMenu = new JMenu();// 初始化基本信息菜单

jibenxinxiMenusetIcon(new ImageIcon("res/jibenxinxijpg"));

{

JMenuItem queryInfoMenuItem = new JMenuItem("个人信息查询");

其实每次遇到不会的都来求助是很不方便的 如果你想了解和学习更多的JAVA编程,成为一名真正的JAVA高手,你可以来这个裙,前面三个数是四二六 中间是三九六 后面是二八四 把这串数字连起来就可以了,这是一个高手的学习裙,在这里你可以学习到书上学不到的知识,还有大牛相互讨论并指导你解答哦!

queryInfoMenuItemaddActionListener(new ActionListener(){ //为学年个人信息查询菜单项按钮添加监听器

public void actionPerformed(ActionEvent arg0) {

StudentMainFrameaddIFame(new StudentQueryInfoIFrame());

}}); JMenuItem modifyInfoMenuItem = new JMenuItem ("个人信息维护");

modifyInfoMenuItemaddActionListener(new ActionListener(){ //为学年个人信息修改菜单项添加监听器

public void actionPerformed(ActionEvent arg0) {

StudentMainFrameaddIFame(new StudentModifyInfoIFrame());

}});

JMenuItem modifiPasswordMenuItem = new JMenuItem ("修改密码");

modifiPasswordMenuItemaddActionListener(new ActionListener(){ //为密码修改菜单项添加监听器

public void actionPerformed(ActionEvent arg0) {

StudentMainFrameaddIFame(new StudentModifyPasswordIFrame());

}});

jibenxinxiMenuadd(queryInfoMenuItem);

jibenxinxiMenuadd(modifyInfoMenuItem);

jibenxinxiMenuadd(modifiPasswordMenuItem);

jibenxinxiMenuaddSeparator();

}

JMenu queryScoreMenu = new JMenu(); // 初始化成绩查询菜单

queryScoreMenusetIcon(new ImageIcon("res/chengjichaxunjpg"));

{

JMenuItem queryByYearMItem = new JMenuItem("学年成绩查询");

queryByYearMItemaddActionListener(new ActionListener(){ //为学年成绩查询菜单项添加监听器

public void actionPerformed(ActionEvent arg0) {

StudentMainFrameaddIFame(new QueryScoreByYearIFrame());

}});

JMenuItem queryByTermMItem = new JMenuItem("学期成绩查询");

queryByTermMItemaddActionListener(new ActionListener(){ //为学期成绩查询菜单项添加监听器

public void actionPerformed(ActionEvent arg0) {

StudentMainFrameaddIFame(new QueryScoreByTermIFrame());

}});

JMenuItem queryByAllMItem = new JMenuItem("综合成绩查询");

queryByAllMItemaddActionListener(new ActionListener(){ //为综合成绩查询菜单项添加监听器

public void actionPerformed(ActionEvent arg0) {

StudentMainFrameaddIFame(new QueryScoreByAllIFrame());

}});

queryScoreMenuadd(queryByYearMItem);

queryScoreMenuadd(queryByTermMItem);

queryScoreMenuadd(queryByAllMItem);

queryScoreMenuaddSeparator();

menuBaradd(jibenxinxiMenu); // 添加基本信息菜单到菜单栏

menuBaradd(queryScoreMenu); // 添加成绩管理菜单到菜单栏

return menuBar;

}

}/Method createMenu/

public static void addIFame(JInternalFrame iframe) { // 添加子窗体的方法

DESKTOP_PANEadd(iframe);

}

}

想学习的童鞋秒懂

public class T extends JFrame {

private static final long serialVersionUID = 1L;

private JPanel jPanel = null;

private JTextField jTextField = null;

private JTextField jTextField1 = null;

private JButton jButton = null;

private JButton jButton1 = null;

private JButton jButton2 = null;

private JTable jTable = null;

private DefaultTableModel tableModel = null;

private JPanel getJPanel() {

if (jPanel == null) {

JLabel jLabel1 = new JLabel();

jLabel1setBounds(new Rectangle(30, 50, 80, 25));

jLabel1setText("请输入ISBN:");

JLabel jLabel = new JLabel();

jLabelsetBounds(new Rectangle(30, 20, 80, 25));

jLabelsetText("请输入书名:");

jPanel = new JPanel();

jPanelsetLayout(null);

jPanelsetPreferredSize(new Dimension(1, 120));

jPaneladd(jLabel);

jPaneladd(jLabel1);

jPaneladd(getJTextField());

jPaneladd(getJTextField1());

jPaneladd(getJButton());

jPaneladd(getJButton1());

jPaneladd(getJButton2());

}

return jPanel;

}

private JTextField getJTextField() {

if (jTextField == null) {

jTextField = new JTextField();

jTextFieldsetBounds(new Rectangle(120, 20, 140, 25));

}

return jTextField;

}

private JTextField getJTextField1() {

if (jTextField1 == null) {

jTextField1 = new JTextField();

jTextField1setBounds(new Rectangle(120, 50, 140, 25));

}

return jTextField1;

}

private JButton getJButton() {

if (jButton == null) {

jButton = new JButton();

jButtonsetBounds(new Rectangle(270, 20, 60, 25));

jButtonsetText("显示");

jButtonaddActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

/ 修改处 /

}

});

}

return jButton;

}

private JButton getJButton1() {

if (jButton1 == null) {

jButton1 = new JButton();

jButton1setBounds(new Rectangle(270, 50, 60, 25));

jButton1setText("显示");

jButton1addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

/ 修改处 /

}

});

}

return jButton1;

}

private JButton getJButton2() {

if (jButton2 == null) {

jButton2 = new JButton();

jButton2setBounds(new Rectangle(240, 80, 90, 30));

jButton2setText("显示全部");

jButton2addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

/

修改处此处只要改下面一行,换成从数据库读就行

应该在DAO层加一个查询全部的方法

public List<Titles> getAll();具体实现自己写。

把114行的代码改成:List<Titles> lists = new TitleDaoImpl()getAll();

/

List<Titles> lists = Titleslist();

// 将表行数设为0行,防止异常

tableModelsetRowCount(0);

for (int i = 0; i < listssize(); i++) { // 当每有一个Titles对象就添加一行

tableModeladdRow(new Object[] {});

}

Titles instance = null;

Object obj = null;

Object name = null;

for (int i = 0; i < tableModelgetRowCount(); i++) { // 行循环

instance = listsget(i); // 为当前Titles对象赋值

for (int j = 0; j < tableModelgetColumnCount(); j++) {

name = tableModelgetColumnName(j);

if (nameequals("ISBN")) {

obj = instancegetISBN();

} else if (nameequals("title")) {

obj = instancegetTitle();

} else if (nameequals("publisher")) {

obj = instancegetPublisher();

} else if (nameequals("date")) {

obj = instancegetDate();

} else if (nameequals("price")) {

obj = instancegetPrice();

} else {

obj = "";

}

tableModelsetValueAt(obj, i, j);

}

}

}

});

}

return jButton2;

}

private JPanel getJPanel1() {

JScrollPane jScrollPane = new JScrollPane();

jScrollPanesetViewportView(getJTable());

JPanel panel = new JPanel(new BorderLayout());

paneladd(jScrollPane, BorderLayoutCENTER);

return panel;

}

private JTable getJTable() {

if (jTable == null) {

// 获得Titles类里的字段,一个字段在JTable中应该表现为一列

Field[] fields = TitlesclassgetDeclaredFields();

// 将字段名保存为列名数组为DefaultTableModel所用

Object[] columnNames = new Object[fieldslength];

for (int i = 0; i < fieldslength; i++) {

columnNames[i] = fields[i]getName();

}

tableModel = new DefaultTableModel(columnNames, 0);

jTable = new JTable(tableModel);

}

return jTable;

}

public static void main(String[] args) {

SwingUtilitiesinvokeLater(new Runnable() {

public void run() {

T thisClass = new T();

thisClasssetDefaultCloseOperation(JFrameEXIT_ON_CLOSE);

thisClasssetVisible(true);

}

});

}

public T() {

super();

setSize(580, 475);

getContentPane()add(getJPanel(), BorderLayoutSOUTH);

getContentPane()add(getJPanel1(), BorderLayoutCENTER);

}

}

首先你要明白一个问题javaswing给你提供了一个可视化的界面,这个界面可以使你在后端接受到界面互动产生的数据行为。

然后,写入数据库这个 *** 作,你只要知道你写一个jdbc的连接,写sql语句。

你把这两步分开做第一步是打印点按钮打印你的对话框里的内容。第二部,你写个main方法写入数据库最后把这两步合并起来。

以上就是关于java语言。编写一个学生成绩管理应用程序,在数据库中建立3张表:Student(id,name,全部的内容,包括:java语言。编写一个学生成绩管理应用程序,在数据库中建立3张表:Student(id,name,、我用JAVA的swing创建了一个窗口程序,拖了一个jTable控件在窗体上,怎样把数据库中的内容显示在Table上、javaswing怎么向数据库中添加数据等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/sjk/9693948.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-01
下一篇 2023-05-01

发表评论

登录后才能评论

评论列表(0条)

保存