
java 编程 高手帮我看下有什么不妥的地方 程序能正常运行 5
importjava.awt.FlowLayout;importjavax.swing.*;importjava.awt.event.*;importjavax.swin...
import java.awt.FlowLayout;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.table.DefaultTableModel;
public class ct2 extends JFrame{
JMenuItem ji;
JDesktopPane jdp;
JInternalFrame nct1=new nct();
ct2(){
super("主窗口");
JMenu jm=new JMenu("文件");
ji=new JMenuItem("打开");
ji.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
jiaction(e);
}
});
jm.add(ji);
JMenuBar jb=new JMenuBar();
jb.add(jm);
setJMenuBar(jb);
jdp=new JDesktopPane();
getContentPane().add(jdp);
}
public void jiaction(ActionEvent e){
if(nct1.isVisible())
{nct1.pack();}
else
{
jdp.add(nct1);
nct1.setVisible(true);
nct1.pack();
}
}
}
class nct extends JInternalFrame{
JTable b;
JScrollPane js;
JButton jbutton;
nct(){
super("窗口",true,true,true,true);
String[] bt={"列1","列2","列3"};
final Object[][] sj={{},{},{},{}};
DefaultTableModel mod=new DefaultTableModel(sj,bt);
b=new JTable(mod);
js=new JScrollPane(b);
getContentPane().add(js);
jbutton=new JButton("提交");
jbutton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
jbuttonaction(e);
}
});
getContentPane().add(jbutton);
getContentPane().setLayout(new FlowLayout());
getContentPane().setVisible(true);
}
public void jbuttonaction(ActionEvent e){
b.setRowHeight(20);
}
}
谁能帮我指点一下我的这段代码有什么 不妥胡地方谢谢!!!!!! 展开
import javax.swing.*;
import java.awt.event.*;
import javax.swing.table.DefaultTableModel;
public class ct2 extends JFrame{
JMenuItem ji;
JDesktopPane jdp;
JInternalFrame nct1=new nct();
ct2(){
super("主窗口");
JMenu jm=new JMenu("文件");
ji=new JMenuItem("打开");
ji.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
jiaction(e);
}
});
jm.add(ji);
JMenuBar jb=new JMenuBar();
jb.add(jm);
setJMenuBar(jb);
jdp=new JDesktopPane();
getContentPane().add(jdp);
}
public void jiaction(ActionEvent e){
if(nct1.isVisible())
{nct1.pack();}
else
{
jdp.add(nct1);
nct1.setVisible(true);
nct1.pack();
}
}
}
class nct extends JInternalFrame{
JTable b;
JScrollPane js;
JButton jbutton;
nct(){
super("窗口",true,true,true,true);
String[] bt={"列1","列2","列3"};
final Object[][] sj={{},{},{},{}};
DefaultTableModel mod=new DefaultTableModel(sj,bt);
b=new JTable(mod);
js=new JScrollPane(b);
getContentPane().add(js);
jbutton=new JButton("提交");
jbutton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
jbuttonaction(e);
}
});
getContentPane().add(jbutton);
getContentPane().setLayout(new FlowLayout());
getContentPane().setVisible(true);
}
public void jbuttonaction(ActionEvent e){
b.setRowHeight(20);
}
}
谁能帮我指点一下我的这段代码有什么 不妥胡地方谢谢!!!!!! 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询