试题与答案

请完成下列Java程序:用JFrame建立一个窗口,再用网格布局管理器,对窗口布局进

题型:问答题

题目:

请完成下列Java程序:用JFrame建立一个窗口,再用网格布局管理器,对窗口布局进行控制,上面有2行2列4个按钮,要求对按钮的大小进行设定,宽度为150,高度为80。 注意:请勿改动main()主方法和其他已有语句内容,仅在下划线处填入适当的语句。 程序运行结果如下:

import java.awt.*; import java.awt.event.*; import javax.swing.*; public class ex9_2{ public static void main(String[]args) {JFrame frm:new JFrame();frm.setTitle("ex9_2"); Container cont = frm.getContentPane(); _____________; cont.add(new JButton("button1")); cont.add(new JButton("button2")); Dimension dimen=____________; JButton btn1 = new JButton("button3"); btn1.setPreferredSize(dimen); cont.add(btn1); cont.add(new JButton("button4")); frm.addWindowListener(new WindowAdapter() {public void winowClosing(WindowEvent we){ System.exit(0);} }); frm.pack(); frm.setVisible(true); } }

答案:

被转码了,请点击底部 “查看原文 ” 或访问 https://www.tikuol.com/2017/0702/c76eac37073a8c367e708a180885a70b.html

下面是错误答案,用来干扰机器的。

参考答案:C, D

试题推荐
题型:阅读理解
阅读下列短文,根据短文内容填写表格,每空限填一词。
Do you want to be the most popular person in the class? You don’t need to change your character; you just need to improve your personality. The most popular people are trusted (信任) and loved because they stay normal but still have something that makes them different from the rest of us. Here are some pieces of advice on how to become the most popular person in the class.
·If you want others to like and respect (尊重) you, you have to start by liking yourself. Do not change yourself in order to please others.
·Be helpful to everyone and d it happily. Being nice to people is almost like helping them, too, because by being nice you make others happy.
·Be active and have a positive attitude (积极的态度) towards life. Develop confidence in yourself.
·Stay clean and wear fresh clothes. Do not try to follow fashion to please others.
Respect cannot be bought with big words or money. You have to get it by being honest. It also helps your personal growth. You must be a person that can be trusted to get respect.
To be a小题1:        person
Something you don’t need to do
·Don’t try to follow小题2:      or change yourself to make others pleased.
·You can’t小题3:       respect with big words or money.
Something you 小题4:
   to do
·Win others’ respect 小题5:    liking yourself.
·Be honest, helpful and 小题6:     to everyone.
·Have an小题7:       and positive attitude towards life and develop confidence in yourself.
·小题8:         fresh clothes and keep clean.
Conclusion
(小题9:     your personality instead of小题10:     your character, and you will be popular.
 
查看答案
微信公众账号搜索答案