下列叙述中错误的是( )。
本题中使用了选项卡,窗口中有一个选项卡,总共有“系统”、“声卡”、“显卡”、“网卡”和“帮助”5项选项面。单击各个选项的文字标签后,所选中的选项将为当前选项。“系统”选项上有3个复选按钮,分别控制“声卡”、“显卡”和“网卡”三个选项,选中某个按钮后,它所指示的选项就可用,否则不可用。
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class java3 extends JFrame{
JTabbedPane config=new JTabbedPane:
public java3{
super("java3");
setSize(500,300);
setDefaultCloseoperation(EXIT_ON_CLOSE);
JPanel configPane=new JPanel;
configPane.setLayout(new BoxLayout(config-
Pane,BoxLayout.Y_AXIS));
JTextArea question=new JTextArea("下面的哪
个选项\n"+"你想设置?");
question.setEditable(false);
question.setMaximumSize(new Dimension(300,
50));
question.setAlignmentX(0.Of);
question.setBackground(configPane.getBack-
ground);
JCheckBox audioCB=new JCheckBox ("声卡",
true);
JCheckBox nicCB=new JCheckBox("网卡",
true);
JCheckBox tvCB=new JCheckBox("显示卡",
false);
configPane.add(Box.createVerticalGlue);
configPane.add(question);
configPane.add(audioCB);
configPane.add(nicCB);
configPane.add(tvCB);
configPane.add(Box.ereateVerticalGlue);
JLabel audioPane=new JLabel("声卡页面");
JLabel niePane=new JLabel("网卡页面");
JLabel tvPane=new JLabel("显示卡页面");
JLabel helpPane=new JLabel("帮助信息");
audioCB.addItemListener(new TabManager(au-
dioPane));
nicCB.addItemListener(new TabManager
(nicPane));
tvCB.addItemListener(new TabManager
(tvPane)):
config.addTab("系统",null,configPane,"
Choose Installed Options”);
config.addTab("声卡",null,audioPane,"Audio
system configuration”);
config.addTab("网卡",null,nicPane;"Netwot-
king configuration");
config.addTab("显示卡",null,tvPane,"Video
system configuration");
config.addTab("帮助",null,helpPane,"How
Do I…");
getContentPane.add(config,BorderLayout.
CENTER);
}
class TabManger implements ActionListener{
Component tab;
public TabManager(Component tabToManage){
tab=tabToManage;
}
public void ItemStateChanged(ItemEvent ie){
int index=config.indexOfComponent(tab);
if(index!=-l){
config.setEnabledAt(index,ie.getStateChange
= =ItemEvent.SELECTED);
}
this.repaint;
}
}
public static void main(String args[]){
java3 SC=new java3;
se.setVisible(true);
}
}
本题的功能是通过按钮来选择窗口显示的风格。窗口
中有三个按钮:“Metal”、“Motif”和“Windows”,单击任何一
个按钮,就能将窗口的风格改变为按钮名称所对应的风格。
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class PlafPanel extends JPanel implements ActionLis-
tener
{public
{metaIButton=new JButton("Metal");
motifButtOn=new J Button("Motif");
windowsButton=new JButton("Windows");
add(metalButton);
add(motifButton);
add(windowsButton);
metalButton.addActionListener(this);
motifButton.addActionListener(this);
windowsButton.addActionListener(this);
}
Dublic void actionPerformed(ActionEvent evt)
{Object source=evt.getSource;
String plaf="":
if(source= =metalButton)
plaf="javax.swing.plaf.metal.MetalLookAnd-
Feel";
else if(source= =motifButton)
plaf="com.sun.java.swing.plaf.motif.Moti-
fLookAndFeel";
else if(source= =windowsButton)
Dlaf="com.sun.java.swing.plaf.windows.Win-
dowsLookAndFeel";
try
{UIManager.setLookAndFeel( );
SwingUtilities.updateComponentTreeUI(this);
}
catch(Exception e){)
}
private JButton metalButton;
private JButton motifButton;
private JButton windowsButton;
}
class PlafFrame. extends JFrame
{public PlafFrame
{ setTitle("simple");
setSize(300,200);
addWindowListener(new WindowAdapter
{public void windowClosing(WindowEvent e)
{System.exit(O);
}
});
Container contentPane=getContentPane;
contentPane.add(new PlafPanel);
}
}
public class java2
{public static void main(String[]args)
f JFrame. frame=new PlafFrame;
frame.show;
}
本题定义了一个长度为l0的boolean型数组,并给数组元素赋值,要求如果数组元素下标为奇数,则数组元素值
为false,否则为true。
public class javal{
pubhc static void main(String[]args){
boolean b[]= ;
for(int i=0;i<10;i++){
if( )
b[i]=false;
else
;
}
for(int i=0;i<10;i++)
System.Out.print("bE"+i+"]="+b[i]+",");
}
}
下列程序片段中,能通过编译的是( )。
下列叙述中错误的是( )。
下列关于Applet的安全限制的叙述中,错误的是( )。
JDK中用于存放Java类库文件的文件夹是( )。
下面程序段的输出结果为( )。
public class Test
{
public static void main(String args[])
{
booleana,b,C;
下列代表十六进制整数的是( )。
java.io包的File类是( )。
高级经济师考试试题精选练习(1)
高级经济师考试模拟练习题之单选题(1
高级经济师考试试题精选练习(2)
高级经济师考试试题精选练习(3)
高级经济师考试试题:经济法案例试题精
高级经济师考试模拟试题及答案
高级经济师考试试题及答案:单选练习题
高级经济师考试试题:经济法案例试题精
高级经济师考试模拟题及答案练习(1)
高级经济师考试模拟题及答案练习(2)