http://zhidao.baidu.com/question/69304216.html
解决方案 »
- Form中接受不到数据
- ssh结合的时候遇到org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session
- aop拦截器的问题
- 一个简单的问题,一时转不过弯来.
- JAVA 里面有没有集合运算的方法啊
- 菜鸟问题:为什么不能通过编译呢?
- J2EE程序的调试与运行的问题
- 请问如何将字符串附成变量名
- 高分求教!!
- 版主大哥:Jbuilder7 & Weblogic7 启动server时出错。头大!哪位大哥拉兄弟一把!
- 关于 oracle自增长列和hibernate自增长列的区别
- 急需技术人员!
2、创建一个显示“工具”的菜单对象MM,并在MM中加入一条分割线
3、创建一个Dialog对象D,它的父窗框使当前Frame对象,标题是“我的对话框”,它是一个无模式的对话框
4、设sb是一个滚动条对象,把它注册给AdjustmentEvent类所代表的滚动条调整事件对应的监听者接口
5、书写一个空的静态初始化器
6、创建类CLASS1的一个对象object1,定义这个类的一个引用ref1,把对象object1赋给引用ref1 改错
1、public class myapplet extends applet
{
label mylabel;
public void init(string args[])
{
mylabel=new label(“你好”);
add(mylabel);
}
}
2、
public class use vector
{
public static void main(string args[])
{
vector myv;
for(int i=0;i<10;i++) myv.addelement(i);
}
}
jf.setLayout(new FlowLayout(FlowLayout.CENTER));2: JMenu mm = new JMenu();
mm.addSeparator();5: private static final NEWINSTANCE = new instacne();
private Class(){
}
public Class getInstance(){
return NEWINSTANCE;
}
6: Object o = Class.forName("Class1").newInstance();
Class1 ref1 = (Class1) o;其他的我再想想。
Dialog d = new Dialog(this,"我的对话框",false);
难点是swing我以前专门看过,不过好久没搞就忘记了
感觉又像是学生的作业题,上来要答案了。
public class use vector //这里应该是写成继承,use extends vector
{
public static void main(string args[])
{
vector myv; //只定义了对象,并没有为其指定内存空间
for(int i=0;i <10;i++) myv.addelement(i); //这里myv为空,会抛空指针异常
}
}
JButton b = new JButton();
b.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent arg0) {
JDialog d = new JDialog();
d.setSize(100,100);
d.setVisible(true);
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
d.dispose();
}
});
frame.add(b);
frame.setVisible(true);
frame.setSize(400,400);
}
我的理解阿
static{
//操作
}
1、public class myapplet extends applet //关键字都必须大写Applet
{
label mylabel; //Label
public void init(string args[]) //String
{
mylabel=new label(“你好”); //Label //字符串"" 应该是英文的引号
add(mylabel);
}
}
2.Vector myv=new Vector();需要构造对象。
init方法是可以传参数的,这样写虽然下面的方法体中没有用到传过来的参数,但是也没有错误的。
init
public void init()由浏览器或 applet viewer 调用,通知此 applet 它已经被加载到系统中。它经常在第一次调用 start 方法前被调用。
如果 Applet 的子类要执行初始化,则应该重写此方法。例如,使用线程的 applet 将用 init 方法创建线程,用 destroy 方法销毁它们。 Applet 类提供的此方法实现不执行任何操作。
import java.awt.Label;public class tt extends Applet {
public void init(String args[]) {
System.out.println("***********************");
}
public static void main(String[] a){
tt t = new tt();
t.init(a);
}
}用java applet来执行有错误,但是上面的程序用java application来运行就ok了。
不过,也很感谢楼上的大哥的点评,我做swing搞了两年,但是没怎么用过applet,呵呵,受教了。
thank you!
import java.awt.Label;public class tt extends Applet {
public void init(String args[]) {
System.out.println("***********************");
}
public static void main(String[] a){
tt t = new tt();
t.init(a);
}
}用java applet来执行有错误,但是上面的程序用java application来运行就ok了。
不过,也很感谢楼上的大哥的点评,我做swing搞了两年,但是没怎么用过applet,呵呵,受教了。
thank you!