更多"bar为一JScrollBar组件,阅读下面程序段,请在程序中的画线处"的相关试题:
[填空题]bar为一JScrollBar组件,阅读下面程序段,请在程序中的画线处填入正确的语句使程序能够正确运行。
...
public WellAdjusted( )
super("Well Adjusted");
setSize(350,100);
bar.addAdjustmentListener(this);
value.setHorizontalAlignment(SwingConstants.CENTER);
value.setEditable(false);
JPanel pane = new JPane( );
pane.setLayout(new BorderLayout( ));
pane.add(value,"Center"):
pane.add(bar,"South");
setContentPane(pane);
public void adjustmentValueChanged(AdjustmentEvent evt)
【12】
if(source ==bar)
int newValue bar.getValue( );
value.setText(""+newValue);
repaint( );
[填空题]bar为一JSerollBar组件,阅读下面程序段,请在程序中的画线处填入正确的语句使程序能够正确运行。
…
public WellAdjusted( )
super("Well Adjusted");
setSize(350,100);
bar.addAdjustmentListener(this);
value.setHorizontalAlignment(SwingConstants.CENTER);
value.setEditable(false);
JPanel pane=new JPane( );
pane.setLayout(new BorderLayout( ));
pane.add(value,"Center"):
pane.add(bar,"South");
setContentPane(pane);
public void adjustmentValueChanged(AdjustmentEvent evt)
【12】
if(source==bar)
int newValue bar.getValue( );
value.setText(""+newValue);
repaint( );
…
[填空题]阅读下面程序段,SelectItem应用程序显示从文本域的组合框中进行选择,请在程序中的画线处添上正确的语句使得程序能够正确运行。
...
JTextField result = new JTextField( );
JComboBox pick = new JComboBox ( );
public SelectItem( )
{
super ("Select Item");
pick.addItemListener(this);
pick.addItem("Navigtor");
pick.addItem("Internet Explorer");
pick.addItem("Opera");
pick.setEditable(false);
result.setHorizontalAlignment(SwingConstants.CENTER);
result, setEditable (false);
pane.setLayout(new BorderLayout( ));
【12】
pane.add(pick,"Center");
pane.add(result,"South");
setContentPane(pane);
}
public void itemStateChanged(ItemEvent evt)
{
Object source = evt.getSource( );
if(source == pick)
{
Object newPick = evt.getItem( );
result .setText(newPick.toString( )+" is the selection. ");
}
repaint( );
}
[填空题]下面的应用程序中有一个组,组内有4个单选按钮,请在画线处填入正确的语句使程序能正确运行。
import javax.swing.*;
public class OneTeam extends JFrame
JRadioButten[] teams = new JRadioButten[3];
public OneTeam( )
super("One Team");
setSize (140,160);
setDefaultCloseOperatien(JFrame.EXlT ON CLOSE);
JPanel pane = new JPanel( );
teams[0] = new JRadioButton("red choose");
teams[1] = new JRadieButton("blue choose");
teams[2] = new JRadieButten("green choose");
______;
for (int i = 0i < teams.length;i++)
group.add(teams[i]);
pane.add(teams[i]);
setContentPane(pane);
public static void main(String arguments[])
OneTeam ot= new OneTeam( );
ot.show( );
[填空题]下面的应用程序中有一个组,组内有4个单选按钮,请在画线处填入正确的语句使程序能正确运行。
import javax.swing.*;
public class OneTeam extends JFrame
{
JRadioButten[] teams = new JRadioButten[3];
public OneTeam( )
{
super("One Team");
setSize (140,160);
setDefaultCloseOperatien(JFrame.EXlT ON CLOSE);
JPanel pane = new JPanel( );
teams[0] = new JRadioButton("red choose");
teams[1] = new JRadieButton("blue choose");
teams[2] = new JRadieButten("green choose");
【11】 ;
for (int i = 0i < teams.length;i++)
{
group.add(teams[i]);
pane.add(teams[i]);
}
setContentPane(pane);
}
public static void main(String arguments[])
{
OneTeam ot= new OneTeam( );
ot.show( );
}
}
[单项选择]阅读下面的程序段: public class Sun { public static void main(String args[ ]) { int a=0 for(int i=1;i<=3;i++) { for(int j=1;j<-i;j++) { for(int k=j;k<=3;k++) { a=a+1; } } } System.out.println(A) 我; }}执行上面的3重循环后,a的值为( )。
A. 3
B. 9
C. 14
D. 21
[单项选择]阅读下面的程序段:
publiC class Sun
public static void main (String args[ ])
int a=0;
for(int i=1;i<=3;i++)
for(int j=1;j<=i;j++)
for(int k=j;k<=3;k++)
a=a+1;
System.out.println(
A. ;
B. 9
C. 14
D. 21
[单项选择]在下面的定义语句中,画线处应填入的内容是
class Fred
public:
void print( )cout<<data<<endl;
void setData(double D) data=d;
static int count;
private:
double data;
;
______count=0;//静态数据成员的定义
A. int
B. static int
C. int Fred::
D. static int Fred::
[填空题]通过实现Runnable接口创建线程,请在画线处加入正确的代码完成此程序 【9】 。
public class ThreadTest
public static void main(String args[ ]
Thread t1 = new Thread(new Hello( )
Thread t2 = new Thread(new Hello( )
___________;
t2.start( );
class Hello implements Runnable
int i;
public void run( )
while (true)
System.out.println("Hello"+i++
if(i==5) break;
[填空题]通过实现Runnable接口创建线程,请在画线处加入正确的代码完成此程序 【9】 。
public class ThreadTest
{
public static void main(String args[ ]
{
Thread t1 = new Thread(new Hello( )
Thread t2 = new Thread(new Hello( )
___________;
t2.start( );
}
}
class Hello implements Runnable
{
int i;
public void run( )
{
while (true)
{
System.out.println("Hello"+i++
if(i==5) break;
}
}
}
[填空题]下面程序构造了一个Swing Applet,在下画线处填入正确的代码。
import javax.swing.*;
import java.awt.*;
public class SwingApplet extends ______ {
JLabel 1=new JLabel("This is a Swing Applet.");
public void init( ) {
Container contentPane=getContentPane( );
contentPane.add(1);
}
}