public void guitest4()
{错了,构造函数不能有返回值!
{错了,构造函数不能有返回值!
解决方案 »
- continue 标号; 的不理解
- 求JAVA高手
- 请教一下Boolean类中的getClass()方法主要有什么作用??在实际的开发环境中?
- 我现在正学java 不知道着重点在哪
- 大家给个思路吧
- 用Applet 做程序,服务器端怎么配置,需要连接数据库????????????
- Java,我有一个外网IP比如7.7.7.7:port的server,想和一内网192.168.0.13client通信,server端求个java小例子
- 请问蔡学镛的java入门教程在哪里可以得到?
- JAVA程序应该如何调试?
- Python3编码问题
- ~~请问生成的JFrame对象怎样让它销毁,再立刻重新加载一次~~
- 谁有javadoc详细的使用方法?
public class guitest4 extends Frame
{
public guitest4()
{
setTitle("this is a test");
setLayout(new FlowLayout());
add(new Button("Yellow"));
add(new Button("red"));
}
public boolean handleEvent(Event evt)
{
if(evt.id==Event.WINDOW_DESTROY)System.exit(0);
return super.handleEvent(evt);
}
public static void main(String[] args)
{
guitest4 f=new UnicodeTest();
f.resize(600,500);
f.show();
}
public boolean action(Event evt,Object arg)
{
if(arg.equals("Yellow"))setBackground(Color.yellow);
else if(arg.equals("red"))setBackground(Color.red);
repaint();
return true;
}
}//这个是正确的代码
import java.awt.event.*;import javax.swing.*;public class guitest4 extends JFrame
{
JButton btnYellow = null;
JButton btnRed = null;
JPanel pneMain = null;
public guitest4()
{
init ();
}
private void init ()
{
setTitle("this is a test");
getPane ();
}
private JPanel getPane ()
{
if (pneMain == null)
{
pneMain = (JPanel)getContentPane ();
getContentPane().setLayout(new FlowLayout());
pneMain.add (getBtnYellow ());
pneMain.add (getBtnRed ());
}
return (pneMain);
}
private JButton getBtnYellow ()
{
if (btnYellow == null)
{
btnYellow = new JButton ("Yellow");
btnYellow.addActionListener (new ActionListener ()
{
public void actionPerformed (ActionEvent arg0)
{
setBack (Color.YELLOW);
}
});
}
return (btnYellow);
}
private JButton getBtnRed ()
{
if (btnRed == null)
{
btnRed = new JButton ("Red");
btnRed.addActionListener (new ActionListener ()
{
public void actionPerformed (ActionEvent arg0)
{
setBack (Color.RED);
}
});
}
return (btnRed);
}
private void setBack (Color aColor)
{
pneMain.setBackground(aColor);
}
public static void main (String [] args)
{
guitest4 f= new guitest4();
f.setSize (600,500);
f.show();
}
}
public class guitest4 extends Frame
{
public guitest4()
{
setTitle("this is a test");
setLayout(new FlowLayout());
add(new Button("Yellow"));
add(new Button("red"));
}
public boolean handleEvent(Event evt)
{
if(evt.id==Event.WINDOW_DESTROY)System.exit(0);
return super.handleEvent(evt);
}
public static void main(String[] args)
{
guitest4 f=new guitest4();
f.resize(600,500);
f.show();
}
public boolean action(Event evt,Object arg)
{
if(arg.equals("Yellow"))setBackground(Color.yellow);
else if(arg.equals("red"))setBackground(Color.red);
repaint();
return true;
}
}
import java.awt.*;
public class guitest4 extends Frame
{
public guitest4()
{
setTitle("this is a test");
setLayout(new FlowLayout());
add(new Button("Yellow"));
add(new Button("red"));
}
public boolean handleEvent(Event evt)
{
if(evt.id==Event.WINDOW_DESTROY)System.exit(0);
return super.handleEvent(evt);
}
public static void main(String[] args)
{
guitest4 f=new guitest4();
f.resize(600,500);
f.show();
}
public boolean action(Event evt,Object arg)
{
if(arg.equals("Yellow"))setBackground(Color.yellow);
else if(arg.equals("red"))setBackground(Color.red);
repaint();
return true;
}
}