这是个排序的测试类,其余的就不复上来了
public class JTest extends JFrame implements ActionListener
{
public static int i;
public static int fan;
public String args[];
public JRadioButton[] r={new JRadioButton("冒泡排序"),new JRadioButton("快速排序"),new JRadioButton("插入排序")};
public JTextArea t=new JTextArea("",8,25);
public JButton b=new JButton("开始排序");
public JTest()
{
super("排序窗口");
Container c=getContentPane();
c.setLayout(new FlowLayout());
ButtonGroup rg=new ButtonGroup();
for(i=0;i<r.length;i++)
{
c.add(r[i]);
rg.add(r[i]);
r[i].addActionListener(this);
}
c.add(b);
b.addActionListener(this);
JScrollPane st=new JScrollPane(t);
c.add(st);
}
@Override
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==b)
{
if(r[0].isSelected())
{
Bubblesort B=new Bubblesort(args);
t.setText(B.Sort());
}
else
{
if(r[1].isSelected())
{
Quicksort Q=new Quicksort(args);
t.setText(Q.Sort());
}
else
{
if(r[2].isSelected())
{
Insertsort I=new Insertsort(args);
t.setText(I.Sort());
}
}
}
}
}
public static void main(String args[])throws IOException
{
try (BufferedReader fin = new BufferedReader(new FileReader("testdata.txt")))
{
int m=Integer.parseInt(fin.readLine());
args=new String[m];
for(i=0;i<m;i++)
{
args[i]=fin.readLine();
}
}
JTest T=new JTest();
T.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
T.setSize(400,250);
T.setVisible(true);
}
}
有啊!
追答你给出的代码有很多错,我注掉那些,点你的按钮,让文本域中显示点内容,是可以的.
要不你就留下QQ,远程帮你看一下.,
这样是猜不出你的问题在那了.