得到textfield的textdocument,控制里面的几个接口方法。
不过你的正整数是个位数吗?
不过你的正整数是个位数吗?
解决方案 »
- 有没有哪位高手能帮我讲解一下Hash算法,多谢
- System.in问题
- 谁帮我分析一下这个递归程序啊
- 急救:救急:急急救:java.io.IOException: 远程主机强迫关闭了一个现有的连接。是服务器端的问题呢?还是客户端的问题呢?
- 怎么样设计自己的Java命令?
- ava程序在调用new Socket(localIP,port)抛ConnectException,哪位高手能帮忙解决一下,急谢先
- Java中怎么访问内存中的其它进程???
- 菜鸟提问(请忽笑):谁能清楚的解释一下接口
- JBuilder应用程序打包后乱码
- [求助]找一份数据库连接池的代码(要求内详)
- 希望各位前辈不要因为是菜问题就不 赐教!谢谢!
- 在java里面怎样得到当前路径?
{
public FrameTest()
{}
public static void main(String args[])
{
}
}
{
JButton button;
JTextField field; public Frame1()
{
super();
button = new JButton("Close");
button.addActionListener(this);
field = new JTextField(); this.getContentPane().setLayout(new FlowLayout());
this.getContentPane().add(button);
this.getContentPane().add(field);
this.setSize(400, 300);
this.setVisible(true);
} public void actionPerformed(ActionEvent event)
{
if(event.getSource() == button)
{
if(field.getText() != null)
{
try
{
int num = Integer.parseInt(field.getText());
dispose();
new Frame2(num);
}catch(NumberFormatException nfe) { }
}
}
}
}
public class Frame2 extends JFrame
{
int num;
public Frame2(int num)
{
this.num = num; this.getContentPane().setLayout(new FlowLayout());
JLabel labels[] = new JLabel[num];
for(int i=0; i<labels.length; i++)
{
this.getContentPane().add(labels[i]);
}
this.setSize(400, 300);
this.setVisible(true);
}
}
mercury1231原代码写的有水平
public class Frame1 extends JFrame implements ActionListener
{
JButton button;
JTextField field; public Frame1()
{
super();
button = new JButton("Close");
button.addActionListener(this);
field = new JTextField(); this.getContentPane().setLayout(new FlowLayout());
this.getContentPane().add(button);
this.getContentPane().add(field);
this.setSize(400, 300);
this.setVisible(true);
} public void actionPerformed(ActionEvent event)
{
if(event.getSource() == button)
{
if(field.getText() != null)
{
try
{
int num = Integer.parseInt(field.getText());
dispose();
new Frame2(num);
}catch(NumberFormatException nfe) { }
}
}
}
}
public class Frame2 extends JFrame
{
int num;
public Frame2(int num)
{
this.num = num; this.getContentPane().setLayout(new FlowLayout());
JLabel labels[] = new JLabel[num];
for(int i=0; i<labels.length; i++)
{
labels[i]=new JLabel("fd");//要加一句
this.getContentPane().add(labels[i]);
}
this.setSize(400, 300);
this.setVisible(true);
}
}