package org.jljc.frame;
class MyReader implements ActionListener{ //监听 a等于字符串aaa
private GsgL container;
public MyReader(GsgL container){
this.container=container;}
public void actionPerformed(ActionEvent e)
{ String a="aaa";}
}
public class GsgL extends JFrame{
private MyReader myReader;
public GsgL(String title) {
super(title);
init();}
public void init(){
table=new JTable(13,2);
table.setValueAt("检测时间",0,0);
//如何把监听得到的a="aaa"值赋到table表格的
table.setValueAt(a,0,1);}
}
class MyReader implements ActionListener{ //监听 a等于字符串aaa
private GsgL container;
public MyReader(GsgL container){
this.container=container;}
public void actionPerformed(ActionEvent e)
{ String a="aaa";}
}
public class GsgL extends JFrame{
private MyReader myReader;
public GsgL(String title) {
super(title);
init();}
public void init(){
table=new JTable(13,2);
table.setValueAt("检测时间",0,0);
//如何把监听得到的a="aaa"值赋到table表格的
table.setValueAt(a,0,1);}
}
解决方案 »
- 前些天比较了Vector和ArrayList的区别,今天找到了更详细的叫:分析Vector、ArrayList、Hashtable、HashMap数据结分享一下
- 关于clone的问题
- 如何查看jdk的版本是32位还是64位
- 100分求救JAVA难题!
- 怎么样得到context ?
- 请问eclipse的多国语言包怎么用?
- 如何注册JTest4.1和InstallAnywhere 4.X ?
- socket之间的数据传送
- 有谁会JAVA3D,大家来讨论一下
- leetcode刷题的时候碰到的一个问题,所有积分都给出去了
- java如何打开doc\txt\ppt\pdt\xls等文件
- JAVA 如何把监听得到的值赋到主类JTable表格里
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;class MyReader implements ActionListener { // 监听 a等于字符串aaa
private GsgL frame; public MyReader(GsgL frame) {
this.frame = frame;
} public void actionPerformed(ActionEvent e) {
String a = "aaa";
frame.fireTableChanged(a);
}
}public class GsgL extends JFrame {
private MyReader myReader;
private JButton button;
private JTable table; public GsgL(String title) {
super(title);
init();
} public void init() {
table = new JTable(13, 2);
((DefaultTableModel) table.getModel())
.setColumnIdentifiers(new String[] { "1", "2" });
getContentPane().add(new JScrollPane(table)); button = new JButton("Test");
myReader = new MyReader(this);
button.addActionListener(myReader);
getContentPane().add(button, BorderLayout.SOUTH);
} public void fireTableChanged(String cont) {
table.setValueAt("检测时间", 0, 0);
table.setValueAt(cont, 0, 1);
((DefaultTableModel) table.getModel()).fireTableRowsUpdated(0, 0);
} public static void main(String[] args) {
GsgL frame = new GsgL("Test");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(200, 150);
frame.setVisible(true);
}
}