更新的话,可以使用自身的validate方法;
成都创新互联公司服务项目包括惠安网站建设、惠安网站制作、惠安网页制作以及惠安网络营销策划等。多年来,我们专注于互联网行业,利用自身积累的技术优势、行业经验、深度合作伙伴关系等,向广大中小型企业、政府机构等提供互联网行业的解决方案,惠安网站推广取得了明显的社会效益与经济效益。目前,我们服务的客户以成都为中心已经辐射到惠安省份的部分城市,未来相信会继续扩大服务区域并继续获得客户的支持与信任!
也可以使用SwingUtiltis.updateComponentUI等方法解决。
示例代码如下:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class LookAndFeelDemo2 extends JFrame {
private JRadioButton radio1 = new JRadioButton("Metal");
private JRadioButton radio2 = new JRadioButton("Windows");
private JRadioButton radio3 = new JRadioButton("Motif");
private JPanel panelNorth = new JPanel();
private JPanel panelSouth = new JPanel();
private JTextArea area = new JTextArea(6, 20);
private JButton btn = new JButton("button");
private JCheckBox chk = new JCheckBox("checkBox");
private JComboBox cmbLookAndFeel = new JComboBox(new String[] { "Metal",
"Widows", "Motif", "GTK" });
public LookAndFeelDemo2(String title) {
super(title);
Container contentPane = this.getContentPane();
ButtonGroup group = new ButtonGroup();
group.add(radio1);
group.add(radio2);
group.add(radio3);
panelNorth.add(radio1);
panelNorth.add(radio2);
panelNorth.add(radio3);
panelSouth.add(btn);
panelSouth.add(chk);
panelSouth.add(cmbLookAndFeel);
contentPane.add(panelNorth, BorderLayout.NORTH);
contentPane.add(area, BorderLayout.CENTER);
contentPane.add(panelSouth, BorderLayout.SOUTH);
pack();
setVisible(true);
setSize(300, 400);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// 监听Item事件
radio1.addItemListener(new MyItemListener());
radio2.addItemListener(new MyItemListener());
radio3.addItemListener(new MyItemListener());
}
private class MyItemListener implements ItemListener {
public void itemStateChanged(ItemEvent e) {
// 取得点击按钮的名字
String itemName = ((JRadioButton) e.getSource()).getText();
changeLookAndFeel(itemName);
}
}
// 设置外观的private类型方法
private void changeLookAndFeel(String name) {
String lookAndFeel = "";
if (name.equals("Metal")) {
lookAndFeel = "javax.swing.plaf.metal.MetalLookAndFeel";
} else if (name.equals("Windows")) {
lookAndFeel = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
} else if (name.equals("Motif")) {
lookAndFeel = "com.sun.java.swing.plaf.motif.MotifLookAndFeel";
}else{
//取得默认的metal外观
lookAndFeel = "javax.swing.plaf.metal.MetalLookAndFeel";
}
try {
UIManager.setLookAndFeel(lookAndFeel);
// 运行时指定LookAndFeel,需要SwingUtilities.updateComponentTreeUI(Component
// c)实现动态的更新
SwingUtilities.updateComponentTreeUI(this);
area.setText("当前外观类名:\n" + lookAndFeel);
} catch (Exception ex) {
ex.printStackTrace();
}
}
public static void main(String[] args) {
new LookAndFeelDemo2("LookAndFeel");
}
}
感觉你的语句后面的"""是不是有点多,你最好分开写;
String sqlUpdate = "UPDATE EmployeeTable " +
" SET givenName = '" + givenName + "', " +
" familyName = '" + familyName + "', " +
" WHERE employeeNumber = '" + empNum + "'";
改成:
String sqlUpdate = "UPDATE EmployeeTable " +
" SET givenName = '" + givenName + "'
", familyName = '" + familyName + "'+
" WHERE employeeNumber = '" + empNum + "';
access数据库我也曾经用过,也知道和普通sql有一些不同,不过感觉和你写的也差距太大了点,你可以再试试,我感觉是sql的问题。
DefaultTableModel d = new DefaultTableModel();
不要在function里边申明,
分开写,DefaultTableModel d;(java开始)
function里边实例, d = new DefaultTableModel();
试试看可不可以。