JAVA新手求教图形界面
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class sfskjaf {
public static class T110022022A extends JFrame implements ActionListener{
private static final long serialVersionUID = 1L;
private JTextField T1;
JButton jbutton;
public T110022022A()
{
super("判断一个整数是否为素数");
T1=new JTextField(5);
jbutton=new JButton("判断素数");
setLayout(new FlowLayout());
add(T1);
boolean x=isS(T1);
T1.addActionListener(this);
setSize(400,400);
setVisible(true);
}
public boolean isS(JTextField t12)//素数判断函数
{
double b=Math.sqrt((double)t12);
int i=2;
for(;i<=b;i++)
{
if(t12%i==0) return false;
}
return true;
}
//判断素数跳出来的对话框
public class Jdialog extends JDialog(boolean x){
public Jdialog(){
super(new jframe(),"是否为素数",ture);
Container container=getContentPane();
if(x==ture)
container.add(new JLabel("是素数"));
else
container.add(new JLabel("不是素数"));
setSize(200,200);
setVisible(true);
}
}
}
class CChange implements ActionListener{
public void actionPerformed(ActionEvent e){
//点击按钮跳出对话框
}
}
public void actionPerformed(ActionEvent e){
String u1=T1.getText();
int i =Integer.parseInt(u1);
int s;
}
public static void main(String args[])
{
new T110022022A();
}
}
我想弄一个图形界面的判断素数的程序,输入一个输,按下按钮,跳出对话框告诉你是不是素数。。但好多错误啊,改了个半天,反而越改越乱。。JAVA新手,求指导
[解决办法]
先把语法弄好了再说吧,孩子