题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2024-04-29 01:15:44

[填空题]本题的功能是展示4种不同的对话框。窗口中有4个按钮:“消息”、“输入”、“确定”和“选择”,单击任意一个按钮,就能弹出一个对应的对话框。其中,消息对话框只有一个提示信息和一个“确定”按钮,输入对话框有一个供输入的文本框及“确定”和“撤销”两个按钮;确定对话框中有一个提示信息和三个按钮“是”、“否”和“撤销”;而选择对话框中有一个提示信息和两个按钮“确定”和“取消”。
import javax. swing. * ;
import java. awt. event. * ;
import java. awt. * ;
public class java3 extends JFrame implements ButtonSelecte ActionListener
JButton btnMessage=new JButton("消息");
JButton btnlnput=new JButton("输入");
JButton btnConfirm=new JButton("确认");
JButton btnOption=new JButton("选择");
public java3 ( )

super("java3");
btnMessage. addActionListener(this);
btnInput. addActionListener(this);
btnConfirm. addActionListener(this);
btnOption. addActionListener(this);
getContentPane( ). setLayout (new FlowLayout ( ));
getContentPane( ). add(btnMessage);
getContentPane( ). add(btnlnput);
getContentPane( ). add(btnConfirm);
getContentPane( ). add(btnOption);
addWindowListener(new WindowAdapt

更多"本题的功能是展示4种不同的对话框。窗口中有4个按钮:“消息”、“输入”"的相关试题:

[简答题]本题的功能是展示4种不同的对话框。窗口中有4个按钮:“消息”、“输入”、“确定”和“选择”,单击任意一个按钮,就能弹出一个对应的对话框。其中,消息对话框只有一个提示信息和一个“确定”按钮,输入对话框有一个供输入的文本框及“确定”和“撤销”两个按钮;确定对话框中有一个提示信息和三个按钮“是”、“否”和“撤销”;而选择对话框中有一个提示信息和两个按钮“确定”和“取消”。
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class java3 extends JFrame implements ButtonSelecteActionListener

JButton btnMessage=new JButton("消息");
JButton btnInput=new JButton("输入");
JButton btnConfirm=new JButton("确认");
JButton btnOption=new JButton("选择");
public java3( )

super("java3");
btnMessage.addActionListener(this);
btnInput.addActionListener(this);
btnConfirm.addActionListener(this);
btnOption.addActionListener(this);
getContentPane( ).setLayout(new FlowLayout( ));
getContentPane( ).add(btnMessage);
getContentPane( ).add(btnInput);
getContentPane( ).add(btnConfirm);
getContentPane( ).add(btnOption);
addWindowListener(new WindowAdapter( )
public
[简答题]本题中,主窗口有一个按钮“打开对话框”和一个文本域,单击按钮“打开对话框”后会弹出一个对话框,对话框上有两个按钮“Yes”和“No”,单击对话框上的“Yes”和“No”按钮后返回主窗口,并在右侧文本域中显示刚才所单击的按钮信息。
import java.awt.event.*;
import java.awt.*;
class MyDialog______implements ActionListener
static final int YES=1,NO=0;
int message=-1;Button yes,no;
MyDialog(Frame f,String s,boolean b)
super(f,s,b);
yes=new Button("Yes");yes.addActionListener(this);
no=new Button("No");no.addActionListener(this);
setLayout(new FlowLayout( ));
add(yes);add(no);
setBounds(60,60,100,100);
addWindowListener(new WindowAdapter( )
public void windowClosing(WindowEvent e)
message=-1;setVisible(false);
);

public void actionPerformed(ActionEvent e)
if(e.getSource( )==yes)
message=YES;
setVisible(false);

else if(e.getSource( )==no)
message=NO;
setVisible(false);


public int getMessage( )
return message;


class Dwindow extends Frame implem
[简答题]本题中,主窗口有一个按钮“显示Dialog”,单击该按钮后显示一个对话框,对话框的标题是“Dialog”,其上有一个文字标签“欢迎学习Java.”,此时仍允许对原来窗口进行操作,当关闭新生成的对话框时退出程序。
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class java2 extends Frame implements ActionListener
public static void main(String args[])
java2 f=new java2("java2");
Panel pan=new Panel( );
f.init( );

public java2(String str)
super(str);

public void init( )
addWindowListener(new WindowAdapter( )
public void windowClosing(WindowEvent e)
System.exit(0);

);
setSize(200,200);
setLayout(new FlowLayout( ));
but=new Button("显示Dialog");
add(but);
but.addActionListener(this);
dlg=new Dialog(this,"Dialog",______);
dlg.setSize(100,50);
dlg.addWindowListener(new WindowAdapter( )
public void windowClosing(WindowEvent e)
______;

);
dlg.add("Center",new Label("欢迎学习Java."));
setVisible(true);

public
[简答题]本题中,主窗口有一个按钮“显示Dial09”,单击该按钮后显示一个对话框,对话框的标题是“Dial09”,其上有一个文字标签“欢迎学习Java.”,此时仍允许对原来窗口进行操作,当关闭新生成的对话框时退出程序。   import java.awt.*;   import java.awt.event.*;   import javax.swing.*;   public class java2 extends Frame implements ActionLis-   tener{   public static void main(String args[]){   java2 f=new java2("java2");   Panel pan=new Panel( );   f.init( );   }   public java2(String str){   super(str);   }   public void init( ){   addWindowListener(new WindowAdapter( ){   public void windowClosing(WindowEvent e){   System.exit(0);   }   });   setSize(200,200);   setLayout(new FlowLayout( ));   but=new Button("显示Dialog");   add(but);   but.addActionListener(this);   dig=new Dialog(this,"Dialog", );   dig.setSize(100,50);   dig.addWindowListener(new WindowAdapter( ){   public void windowClosing(WindowEvent e){    ;
[简答题]本题中,通过菜单“Connect”显示一个对话框,单击“ok”按钮后,所填写的内容就会传回到主窗口并显示出来。
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class java3 extends JFrame implements ActionListener
public java3( )
setTitle("java3");
setSize(300,300);
addWindowListener(new WindowAdapter( )
public void windowClosing(WindowEvent e)
System.exit(0);

);
JMenuBar mbar=new JMenuBar( );
setJMenuBar(bar);
JMenu fileMenu=new JMenu("File");
mbar.add(fileMenu);
connectItem=new JMenuItem("Connect");
connectItem.addActionListener(this);
fileMenu.add(connectItem);
exitItem=new JMenuItem("Exit");
exitItem.addActionListener(this);
fileMenu.add(exitItem);

public void actionPerformed(ActionEvent evt)
Object source=evt.getSource( );
if(source==connectItem)
ConnectInfo transfer=new ConnectInfo("yourname","pw");
if(dialog==null)
dialog=new ConnectDialog(this);
if(dial
[简答题]本题是一个Applet,页面上有一个按钮“请单击”,单击该按钮后弹出一个对话框,对话框上有三个按钮“橙色”、“蓝色”和“红色”,单击其中任意一个按钮,则可以将对话框的背景色设置为按钮名称所对应的颜色。
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class java2 extends JApplet

private JFrame frame;
______( )

frame=new JFrame( );
frame.setTitle("java2");
frame.setSize(300,200);
frame.getContentPane( ).add(new ButtonPanel( ));
JButton PopButton=new JButton("请单击");
getContentPane( ).add(PopButton);
PopButton.addActionListener(new ActionListener( )

public void actionPerformed(ActionEvent evt)

if(frame.isVisible( ))frame.setVisible(false);
else______;

);


class ButtonPanel extends JPanel

private class ColorAction implements ActionListener

private Color backgroundColor;
public void actionPerformed(ActionEvent actionevent)

setBackground(backgrOundColor);
repaint( );

public ColorAction(
[填空题]本题的功能是获得系统剪贴板中的内容。窗口中有一个菜单“Edit”和一个文本域,“Edit”中有菜单项“Cut”、“Copy”和“Paste”,在文本域中输入内容,可以通过菜单进行剪切、复制和粘贴操作,如果系统剪贴板为空,又做粘贴操作的话,则设置文本域中背景颜色为红色,并显示错误信息。
import java. awt. * ;
import java. io. * ;
import java. awt. datatransfer. * ;
import java. awt. event. * ;
class java3 extends Frame implements ActionListener,
ClipboardOwner
TextArea textArea=new TextArea( );
java3( )
super("java3");
addWindowListener(new WindowAdapter( )
public void windowClosing(WindowEvent e)
System. exit(0);
/);
MenuBar mb=new MenuBar( );
Menu m=new Menu("Edit");
setLayout(new BorderLayout( ));
add("Center", textArea);
m. add("Cut");
m. add("Copy");
m. add("Paste");
mb. add(m);
setMenuBar(this);
for (int i=0; i<m. getItemCount( ); i++)
m. item(i). addActionListener(this);
setSize(300,300);
show( );

public void actionPerformed(ActionEvent evt)
if ("Paste". equals(ev
[多项选择]本题的功能是在文本域面板中添加一个带有行数的面板。窗口中有一个文本域,在文本域的左侧有一个带有数字的面板,该面板上的数字指示着文本域中的行数。
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
public class java3 extends JFrame

public static JTextPane textPane;
public static JScrollPane scrollPane;
JPanel panel;
public java3( )

super("java3( )");
panel=new JPanel( );
panel.setLayout(new BorderLayout( ));
panel.setBorder(BorderFactory.createEmptyBorder(20,20,20,20));
textPane=new JTextPane( );
textPane.setFont(new Font("monospaced",Font.PLAIN,12));
scrollPane=new JScrollPane(textPane);
panel.add(scrollPane);
scrollPane.setPreferredsize(new Dimension(300,250));
setContentPane(panel);
setCloseOperation(JFrame.EXIT_ON_CLOSE);
LineNumber lineNumber=new LineNumber( );
scrollPane.setRowHeaderView(lineNumber);

public static void main(String[]args)

java3 ttp=new java3( );
ttp.pack( );
[简答题]本题程序的功能是:主窗口中有两个按钮“Start”和“Close”,单击按钮“Start”后会在窗口左上角生成一个黑色实心小球,小球做斜线运动,碰到面板边缘后反弹几次后停止运动,再次单击按钮“Start”后又会生成一个小球做同样的运动。程序中存在若干错误,请找出并改正(注意:不得改动程序的结构,不得增行或删行)。
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import java.util.*;
import javax.swing.*;
public class advance

public static void main (String[] args)

JFrame frame = new BounceFrame( );
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
frame.show( );

class BounceFrame extends JFrame

public BounceFrame( )

setSize(WIDTH,HEIGHT);
setTitle("advance");
Container contentPane = getContentPane( );
Canvas = new BallCanvas( );
contentPane.add(canvas,BorderLayout.CENTER);
JPanel buttonPanel = new JPanel( );
addButton(buttonPanel,"Start",new ActionListener( )
public void actionPerformed(ActionEvent evt)

addBall( );

);
addButton(buttonPanel,"Close",new ActionListener
[填空题]本题的功能是通过按钮来选择窗口显示的风格。窗口中有三个按钮:“Metal”、“Motif和“WindoWS“,单击任何一个按钮,就能将窗口的风格改变为按钮名称所对应的风格。
import java.awt*;
import java.awt.event.*;
import javax.swing.*;
class PlafPanel extends JPanel implements Actionlis-tener
public______( )
metalButton=new JButton("Metal");
motifButton=new JButton("Motif");
windowsButton=new JButton("Windows");
add(metalButton);
add(motifButton);
add(windowsButton);
metalButlon.addActionListener(this);
motifButton.addActionListener(this);
windowsButton.addActionListener(this);

public void actionPerformed(ActionEvent evt)
Object source=evt.getSource( );
string plaf="";
if(source==metaIButton)
pIaF="javax.swing.plaf.metal.MetalLookAncl-Feel";
else if(source==motifButton)
plaf="com.sun.java.swing.plaf.motif.Moti-fLookAndFeel";
else if(source==windowsButton)
plaf="com.sun.java.swing.plaf.windows.windowsLookAndFeel";
try
UIManager.setLookAndF
[简答题]本题的功能是通过按钮来选择窗口显示的风格。窗口中有三个按钮:“Metal”、“Motif”和“Windows”,单击任何一个按钮,就能将窗口的风格改变为按钮名称所对应的风格。
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class PlafPanel extends JPanei implements ActionListener
public______( )
metalButton=new JButton("Metal");
motifButton=new JButton("Motif");
windowsButton=new JButton("Windows");
add(metalButton);
add(motifButton);
add(windowsButton);
metalButton.addActionListener(this);
motifButton.addActionListener(this);
windowsButton.addActionListener(this);

public void actionPerformed(ActionEvent evt)
Object source=evt.getSource( );
String plaf="";
if(source==metalButton)
plaf="javax.swing.plaf.metal.MetalLookAndFeel";
else if(source==motifButton)
plaf="com.sun.java.swing.plaf.motif.MotifLookAndFeel";
else if(source==windowsButton)
plaf="com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
try
UIManager.setLookAndFeel
[简答题]下面是一个Applet程序,其功能是统计输入字符串中的每个字符在该串中出现的次数。要求,窗口中有一个文本框作为输入,一个按钮,点击则进行统计,统计结果以图形方式输出。请改正程序中的错误(有下画线的语句),使程序能输出正确的结果。 注意:不改动程序的结构,不得增行或删行。 import java.awt.*; import java.applet.*; import java.1ang*; public class exl3_3 extends Applet{ private TextField tf; private Button btn; public void init( ){ tf=new TextField(25); add(tf); btn=new Bunon("统计"); add(btn); resize(250,200); } pubhc void paint(Graphics g){ Stling str=tf.genText( ); shon cnt[]=new shon[65536]; int i; int n = 50; for(i=0;i<65536;i++) cat[i]=0; for(i=0;i<str.length( );i++) cnt[i]++; for(i=0;i<65536;i++)//对数组Cnt[]进行初始化 if(cnt[i]>=0){ g.drawString(i+"出现"+cnt[i]+"次",50,n); n+=20; } } public boolean action(Eyent e,Object o){ if(o=="统计"){ repaint( ); return true; } else return false;
[判断题]F3功能键在不同的软件中有不同的规定。( )
[单项选择]某家电企业生产3种不同型号的电冰箱、6种不同型号的洗衣机、4种不同型号的空调、5种不同型号的电视机。该企业产品组合的宽度是()
A. 1
B. 3
C. 4
D. 18
[填空题]本题的功能是用按钮来控制文本框中文本的颜色。窗口中有两个带有文字标题的面板“Sample text”和“Text color control”,窗口的底部还有一个复选按钮“Disable changes”。在“Sample text”面板中有一个带有字符串的文本框,而在“Text color control”面板中有三个按钮“Black”、“Red”和“Green”,并且每个按钮上都有一个对应颜色的圆。单击任意按钮,文本框的文本变成对应的颜色,如果选中“Disable changes”复选框,则三个颜色按钮变为不可用,如果取消选中复选框,则三个按钮变为可用。
import javax. swing. * ;
import java. awt. * ;
import java. awt. event. * ;
public class java3 extends JFrame
private JPanel upper, middle, lower;
private JTextField text;
private JButton black, red, green;
private JCheckBox disable;
public java3 (String titleText)
super (titleText);
addWindowListener (new WindowAdapter( )
public void
windowClosing (WindowEvent e)
System. exit(0);

);
upper=new JPanel( );
upper. setBorder (BorderFactory. createTitledBorder("Sample text"));
Upper. setlayout(new BorderLayout( ));
text=new JTextField ("Change the color of this text");
upper. add (text, BorderLayout.

我来回答:

购买搜题卡查看答案
[会员特权] 开通VIP, 查看 全部题目答案
[会员特权] 享免全部广告特权
推荐91天
¥36.8
¥80元
31天
¥20.8
¥40元
365天
¥88.8
¥188元
请选择支付方式
  • 微信支付
  • 支付宝支付
点击支付即表示同意并接受了《购买须知》
立即支付 系统将自动为您注册账号
请使用微信扫码支付

订单号:

请不要关闭本页面,支付完成后请点击【支付完成】按钮
恭喜您,购买搜题卡成功
重要提示:请拍照或截图保存账号密码!
我要搜题网官网:https://www.woyaosouti.com
我已记住账号密码