import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class PanelTest extends JApplet
{
JPanel panelObj; //声明JFrame类对象
public PanelTest() //创建构造函数
{
panelObj=new JPanel(); //创建JPane类对象
panelObj.setBackground(Color.white); //设置面板颜色
getContentPane().add(panelObj); //将面板添加到窗体
}
}
class ButtonTest extends PanelTest
{
JButton buttonObj1;
JButton buttonObj2;
public ButtonTest()
{
buttonObj1.setText("击我");
buttonObj2=new JButton("按钮2");
buttonObj1.setEnabled(true);
buttonObj2.setEnabled(false);
panelObj.add( buttonObj1);
panelObj.add( buttonObj2);
}
}
class FlowLayoutTest extends ButtonTest
{
FlowLayout layoutObj;
public FlowLayoutTest()
{
layoutObj=new FlowLayout(FlowLayout.CENTER,10,10); //创建布局对象layoutObj
getContentPane().setLayout(layoutObj);//getContentPane()调用setLayout()方法设置布局
}
}
class EventTest extends FlowLayoutTest
{
ButtonEvent1 bEObj1;
ButtonEvent2 bEObj2;
public EventTest()
{
bEObj1=new ButtonEvent1();
bEObj2=new ButtonEvent2();
buttonObj1.addMouseListener(bEObj1);
buttonObj2.addMouseListener(bEObj2);
}
class ButtonEvent1 implements MouseAdapter
{
public void mouseClicked(MouseEvent e)
{
buttonObj1.setEnabled(false);
buttonObj1.setText("按钮1");
buttonObj2.setEnabled(true);
buttonObj2.setText("击我");
}
}
class ButtonEvent2 implements MouseAdapter
{
public void mouseClicked(MouseEvent e)
{
buttonObj2.setEnabled(false);
buttonObj2.setText("按钮2");
buttonObj1.setEnabled(true);
buttonObj1.setText("击我");
}
}
}
public class j10_Applet
{
public void init()
{
new EventTest();
}
}
这个程序是编译通过了但是为什么我在web浏览是为什么就是显示不出来呢?
是程序出错了吗?
还是别的什么问题呢?
拜托,拜托了各位高手们啊!!
import java.awt.*;
import java.awt.event.*;
class PanelTest extends JApplet
{
JPanel panelObj; //声明JFrame类对象
public PanelTest() //创建构造函数
{
panelObj=new JPanel(); //创建JPane类对象
panelObj.setBackground(Color.white); //设置面板颜色
getContentPane().add(panelObj); //将面板添加到窗体
}
}
class ButtonTest extends PanelTest
{
JButton buttonObj1;
JButton buttonObj2;
public ButtonTest()
{
buttonObj1.setText("击我");
buttonObj2=new JButton("按钮2");
buttonObj1.setEnabled(true);
buttonObj2.setEnabled(false);
panelObj.add( buttonObj1);
panelObj.add( buttonObj2);
}
}
class FlowLayoutTest extends ButtonTest
{
FlowLayout layoutObj;
public FlowLayoutTest()
{
layoutObj=new FlowLayout(FlowLayout.CENTER,10,10); //创建布局对象layoutObj
getContentPane().setLayout(layoutObj);//getContentPane()调用setLayout()方法设置布局
}
}
class EventTest extends FlowLayoutTest
{
ButtonEvent1 bEObj1;
ButtonEvent2 bEObj2;
public EventTest()
{
bEObj1=new ButtonEvent1();
bEObj2=new ButtonEvent2();
buttonObj1.addMouseListener(bEObj1);
buttonObj2.addMouseListener(bEObj2);
}
class ButtonEvent1 implements MouseAdapter
{
public void mouseClicked(MouseEvent e)
{
buttonObj1.setEnabled(false);
buttonObj1.setText("按钮1");
buttonObj2.setEnabled(true);
buttonObj2.setText("击我");
}
}
class ButtonEvent2 implements MouseAdapter
{
public void mouseClicked(MouseEvent e)
{
buttonObj2.setEnabled(false);
buttonObj2.setText("按钮2");
buttonObj1.setEnabled(true);
buttonObj1.setText("击我");
}
}
}
public class j10_Applet
{
public void init()
{
new EventTest();
}
}
这个程序是编译通过了但是为什么我在web浏览是为什么就是显示不出来呢?
是程序出错了吗?
还是别的什么问题呢?
拜托,拜托了各位高手们啊!!
解决方案 »
- 请教,怎样按条件复制CSV文件内容到另一个CSV文件
- 请教\u字符串的问题
- 还是数据库连接后,如何类间传递Statement对象的问题,跪求代码实现,谢谢。
- eclipse 快捷键。
- 请问如何实现删除文件里的一行记录?
- 一个和数据库相关的小问题!
- 请问如何把对象定义在接口上
- 在使用ms sql 的时候你们用 ms的jdbc api吗?
- faint!又有问题了!!高手帮忙!!!
- 请问JB7中要如何才能在Database Pliot中连接DB2和SQLServer?急
- 如何用代码自动修改abc.war下面的一个*.properties文件谢谢,或者怎么拷贝个一个文件夹下面的所有文件,为什么f.renameTo(File filepath)
- 怎么判断从数据库中查到的结果集为空??
import java.awt.*;
import java.awt.event.*;
class PanelTest extends JApplet
{
JPanel panelObj; //声明JFrame类对象
public PanelTest() //创建构造函数
{
panelObj=new JPanel(); //创建JPane类对象
panelObj.setBackground(Color.white); //设置面板颜色
getContentPane().add(panelObj); //将面板添加到窗体
}
}
class ButtonTest extends PanelTest
{
JButton buttonObj1;
JButton buttonObj2;
//JButton buttonObj3;
//Button buttonObj4;
public ButtonTest()
{
buttonObj1=new JButton("按钮1");
buttonObj2=new JButton("按钮2");
//buttonObj3=new JButton("按钮3");
//buttonObj4=new Button("按钮4");
buttonObj1.setEnabled(true);
buttonObj2.setEnabled(false);
panelObj.add( buttonObj1);
panelObj.add( buttonObj2);
//panelObj.add( buttonObj3);
//panelObj.add( buttonObj4);
}
}
class FlowLayoutTest extends ButtonTest
{
public FlowLayoutTest()
{
FlowLayout layoutObj=new FlowLayout(FlowLayout.CENTER,10,10); //创建布局对象layoutObj
panelObj.setLayout(layoutObj);//getContentPane()调用setLayout()方法设置布局
}
}
class EventTest extends FlowLayoutTest
{
public EventTest()
{
ButtonEvent bEObj=new ButtonEvent();
buttonObj1.addMouseListener(bEObj);
buttonObj2.addMouseListener(bEObj);
}
class ButtonEvent implements MouseListener
{
public void mouseClicked(MouseEvent e)
{
Object obj=e.getSource();
if(obj==buttonObj1)
{
buttonObj1.setEnabled(false);
buttonObj1.setText("按钮1");
buttonObj2.setEnabled(true);
buttonObj2.setText("击我");
}
if (obj==buttonObj2)
{
buttonObj2.setEnabled(false);
buttonObj2.setText("按钮2");
buttonObj1.setEnabled(true);
buttonObj1.setText("击我");
}
}
public void mousePressed(MouseEvent e){}
public void mouseReleased(MouseEvent e){}
public void mouseEntered(MouseEvent e){}
public void mouseExited(MouseEvent e){}
}
}
public class j09_MouseEvent
{
public void init()
{
new EventTest();
}
}
还有这个程序也是一样的问题啊!
我真的不知道怎么办才好啊!
有两个按钮点击按钮1后按钮1会变成不使能(变灰)
而按钮2就变成使能的
现在我的问题就是我在把这个小应用程序插入web中,可是没有显示内容啊。
你的这个类是JApplet类型的,而这类型是没有构造函数的,而需要的是init()函数.你试下,,,
小程序是没有构造函数的