我想实现按某JButton后,程序读取若干个JTextField上的字串进行操作,我想这个应该可以用类内部的方法实现,应该怎样写呢?已经写的相关代码附在下面,编译的结果是“找不到符号”
text[0] = new JTextField(5);
text[1] = new JTextField(5);
text[2] = new JTextField(5); ColourButton = new JButton("Show Me The Colour");
ColourButton.addActionListener(
new ActionListener()
{
public void actionPerformed( ActionEvent e )
{
drawpic();
}
}
);
protected void drawpic()
{
Graphics g;
int red,green,blue;
red = Integer.parseInt(text[0].getText);
green = Integer.parseInt(text[1].getText);
blue = Integer.parseInt(text[2].getText); Color c = new Color(red,green,blue);
drawpanel.paintComponent(g);
g.setColor(c);
g.fillrect(20,20,40,40);
}
text[0] = new JTextField(5);
text[1] = new JTextField(5);
text[2] = new JTextField(5); ColourButton = new JButton("Show Me The Colour");
ColourButton.addActionListener(
new ActionListener()
{
public void actionPerformed( ActionEvent e )
{
drawpic();
}
}
);
protected void drawpic()
{
Graphics g;
int red,green,blue;
red = Integer.parseInt(text[0].getText);
green = Integer.parseInt(text[1].getText);
blue = Integer.parseInt(text[2].getText); Color c = new Color(red,green,blue);
drawpanel.paintComponent(g);
g.setColor(c);
g.fillrect(20,20,40,40);
}
getText后面没有加括号……
给大家添麻烦了……