java中borderlayout布局显示
importjava.awt.*;importjava.awt.event.*;publicclassBorderLayoutDemoextendsFrame{publi...
import java.awt.*;
import java.awt.event.*;
public class BorderLayoutDemo extends Frame{
public void BorderLayoutDemo(){
this.add(new Button("1"),BorderLayout.EAST);
this.add(new Button("2"),BorderLayout.CENTER);
this.add(new Button("3"),BorderLayout.NORTH);
this.add(new Button("4"),BorderLayout.WEST);
add(new Label("this is a borderlayout"),BorderLayout.SOUTH);
}
public static void main(String args[]){
BorderLayoutDemo blyd=new BorderLayoutDemo();
blyd.setTitle("this is a borderlayout");
blyd.setVisible(true);
blyd.pack();
blyd.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
}
public Dimension getPerferredSzie(){
return new Dimension(400,200);
}
}
为什么运行的时候,框架里什么也没有呢
请各位高手帮忙一下... 展开
import java.awt.event.*;
public class BorderLayoutDemo extends Frame{
public void BorderLayoutDemo(){
this.add(new Button("1"),BorderLayout.EAST);
this.add(new Button("2"),BorderLayout.CENTER);
this.add(new Button("3"),BorderLayout.NORTH);
this.add(new Button("4"),BorderLayout.WEST);
add(new Label("this is a borderlayout"),BorderLayout.SOUTH);
}
public static void main(String args[]){
BorderLayoutDemo blyd=new BorderLayoutDemo();
blyd.setTitle("this is a borderlayout");
blyd.setVisible(true);
blyd.pack();
blyd.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
}
public Dimension getPerferredSzie(){
return new Dimension(400,200);
}
}
为什么运行的时候,框架里什么也没有呢
请各位高手帮忙一下... 展开
1个回答
展开全部
就差了一句话!呵呵……修改后如下:
import java.awt.*;
import java.awt.event.*;
public class BorderLayoutDemo extends Frame{
public void BorderLayoutDemo(){
this.add(new Button("1"),BorderLayout.EAST);
this.add(new Button("2"),BorderLayout.CENTER);
this.add(new Button("3"),BorderLayout.NORTH);
this.add(new Button("4"),BorderLayout.WEST);
add(new Label("this is a borderlayout"),BorderLayout.SOUTH);
}
public static void main(String args[]){
BorderLayoutDemo blyd=new BorderLayoutDemo();
blyd.setTitle("this is a borderlayout");
blyd.setVisible(true);
///就多加这么一句就OK啦~~!呵呵……你忘记执行那个添加控件的方法了!
blyd.BorderLayoutDemo();
blyd.pack();
blyd.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
}
public Dimension getPerferredSzie(){
return new Dimension(400,200);
}
}
还不明白的话问我!^_^
import java.awt.*;
import java.awt.event.*;
public class BorderLayoutDemo extends Frame{
public void BorderLayoutDemo(){
this.add(new Button("1"),BorderLayout.EAST);
this.add(new Button("2"),BorderLayout.CENTER);
this.add(new Button("3"),BorderLayout.NORTH);
this.add(new Button("4"),BorderLayout.WEST);
add(new Label("this is a borderlayout"),BorderLayout.SOUTH);
}
public static void main(String args[]){
BorderLayoutDemo blyd=new BorderLayoutDemo();
blyd.setTitle("this is a borderlayout");
blyd.setVisible(true);
///就多加这么一句就OK啦~~!呵呵……你忘记执行那个添加控件的方法了!
blyd.BorderLayoutDemo();
blyd.pack();
blyd.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
}
public Dimension getPerferredSzie(){
return new Dimension(400,200);
}
}
还不明白的话问我!^_^
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |