2:如果要对jtable中某一列进行求和或者求平均值应该怎么做,谢谢源代码:
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.GridLayout;
import java.awt.Color;
import java.awt.ComponentOrientation;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.*;import javax.print.attribute.standard.JobName;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.SwingConstants;
import javax.swing.RootPaneContainer;
import javax.swing.border.EtchedBorder;
import javax.swing.border.TitledBorder;
import javax.swing.*;public class swingtest extends JFrame { private JFrame frame; /**
 * Launch the application
 * @param args
 */
public static void main(String args[]) {
try {
swingtest window = new swingtest();
window.frame.setVisible(true);
window.initialize();
} catch (Exception e) {
e.printStackTrace();
}
} /**
 * Create the application
 */
public swingtest() {
initialize();
} /**
 * Initialize the contents of the frame
 */
private void initialize() {




frame = new JFrame();
frame.setBackground(new Color(255, 255, 0));
frame.setSize(new Dimension(1024, 800));
frame.setAlwaysOnTop(true);
frame.getContentPane().setBackground(new Color(255, 255, 0));
frame.setBounds(200, 200, 500, 375);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

final JLabel label = new JLabel();
label.setFont(new Font("宋体", Font.PLAIN, 16));
label.setForeground(new Color(0, 128, 0));
label.setBackground(new Color(255, 255, 0));
label.setHorizontalAlignment(SwingConstants.CENTER);
label.setText("欢迎来到学生成绩信息系统");
frame.getContentPane().add(label, BorderLayout.NORTH); final JPanel panel = new JPanel();
panel.setBackground(new Color(255, 255, 0));
frame.getContentPane().add(panel, BorderLayout.CENTER); final JButton button = new JButton();
button.setVerticalTextPosition(SwingConstants.BOTTOM);
button.setInheritsPopupMenu(true);
button.setHorizontalTextPosition(SwingConstants.LEFT);
panel.add(button);
button.setBorder(new TitledBorder(null, "", TitledBorder.LEFT, TitledBorder.DEFAULT_POSITION, null, null));
button.setVerticalAlignment(SwingConstants.BOTTOM);
button.setText("显示信息");
button.addActionListener(new ActionListener() {
     
public void actionPerformed(final ActionEvent e) {

swingdisplay display=new swingdisplay();
display.main(null);

    
}
});

}} class swingdisplay extends JFrame { private JFrame frame; /**
 * Launch the application
 * @param args
 */
public static void main(String args[]) {
try {
swingdisplay window = new swingdisplay();
window.frame.setVisible(true);

} catch (Exception e) {
e.printStackTrace();
}
} /**
 * Create the application
 */
public swingdisplay() {
initialize();
} /**
 * Initialize the contents of the frame
 */
private void initialize() {




frame = new JFrame();
frame.setBackground(new Color(255, 255, 0));
frame.setSize(new Dimension(800, 600));
frame.setAlwaysOnTop(true);
frame.getContentPane().setBackground(new Color(255, 255, 0));
frame.setBounds(100, 100, 500, 375);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

final JLabel label = new JLabel();
label.setFont(new Font("宋体", Font.PLAIN, 16));
label.setForeground(new Color(0, 128, 0));
label.setBackground(new Color(255, 255, 0));
label.setHorizontalAlignment(SwingConstants.CENTER);
label.setText("欢迎来到学生成绩信息系统");
frame.getContentPane().add(label, BorderLayout.NORTH);
final JPanel panel = new JPanel();
panel.setBackground(new Color(255, 255, 0));
frame.getContentPane().add(panel, BorderLayout.CENTER);

final JButton button_1 = new JButton();
button_1.setBorder(new TitledBorder(null, "", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
button_1.setText("查询");
panel.add(button_1);
button_1.addActionListener(new ActionListener() {
     
public void actionPerformed(final ActionEvent e) {



    
}
}); final JButton button_2 = new JButton();
button_2.setText("添加");
panel.add(button_2);
button_2.addActionListener(new ActionListener() {
     
public void actionPerformed(final ActionEvent e) {

swingadd add=new swingadd();
add.main(null);

    
}
});

frame.add(panel,BorderLayout.SOUTH);


String[] columnname=
{
"id","name","infograde","elcmgrade","ecmgrade"
};
Object info[][]={{"001","lilei",new Integer(88),new Integer(85),new Integer(75),Boolean.FALSE,Color.cyan},
{"002","xujingfeng",new Integer(88),new Integer(85),new Integer(75),Boolean.FALSE,Color.cyan},
{"003","fengsiliang",new Integer(88),new Integer(85),new Integer(75),Boolean.FALSE,Color.cyan},
{"004","haoling",new Integer(88),new Integer(85),new Integer(75),Boolean.FALSE,Color.cyan},
{"005","qiuli",new Integer(88),new Integer(85),new Integer(75),Boolean.FALSE,Color.cyan}
};
JTable table=new JTable(info,columnname);
frame.getContentPane().add(new JScrollPane(table),BorderLayout.CENTER);
} }
 
 class swingadd extends JFrame { private JFrame frame; /**
 * Launch the application
 * @param args
 */
public static void main(String args[]) {
try {
swingadd window = new swingadd();
window.frame.setVisible(true);

} catch (Exception e) {
e.printStackTrace();
}
} /**
 * Create the application
 */
public swingadd() {
initialize();
} /**
 * Initialize the contents of the frame
 */
private void initialize() {


Container contentpane=getContentPane();



frame = new JFrame();
frame.setBackground(new Color(255, 255, 0));
frame.setSize(new Dimension(1024, 800));
frame.setAlwaysOnTop(true);
frame.getContentPane().setBackground(new Color(255, 255, 0));
frame.setBounds(200, 200, 500, 375);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

final JLabel label = new JLabel();
label.setFont(new Font("宋体", Font.PLAIN, 16));
label.setForeground(new Color(0, 128, 0));
label.setBackground(new Color(255, 255, 0));
label.setHorizontalAlignment(SwingConstants.CENTER);
label.setText("欢迎来到学生成绩信息系统");
frame.getContentPane().add(label, BorderLayout.NORTH); final JPanel panel = new JPanel();
panel.setBackground(new Color(255, 255, 0));
frame.getContentPane().add(panel, BorderLayout.CENTER);
final JButton button_1 = new JButton();
button_1.setBorder(new TitledBorder(null, "", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
button_1.setText("查询");
panel.add(button_1);
button_1.addActionListener(new ActionListener() {
     
public void actionPerformed(final ActionEvent e) {



    
}
}); final JButton button_2 = new JButton();
button_2.setText("添加");
panel.add(button_2);
button_2.addActionListener(new ActionListener() {
     
public void actionPerformed(final ActionEvent e) {

swingadd add=new swingadd();
add.main(null);

    
}
});

frame.add(panel,BorderLayout.SOUTH);
contentpane.add(panel,BorderLayout.SOUTH);


} }