相关考题

判断题 互联网保险要遵循安全性、内控性和稳定性原则,加强风险管理,完善内控系统,确保交易安全,信息安全和资金安全。( )

判断题 自愿原则是指公民、法人或者其他组织有权根据自己的意愿决定参不参加民事活动,参加何种民事活动,根据自己的意愿依法处分自己的财产和权利。( )

问答题 本题的功能是用按钮来控制文字的颜色。窗口中有三个按钮“Yellow”、“Blue”和“Red”,它们分别对应文字标签中文本的颜色为黄色、蓝色和红色,单击任意一个按钮,文字标签中的文本就变成按钮对应的颜色。 import java.awt.*; import java.awt.event.*; import javflx.swing.*; class ButtonPanel extends JPanel implements ActionL- istener{ public ButtonPanel(){ yellowButton=new J Button("Yellow"); blueButton=new JButton("Blue"); redButton=new JButton("Red"); j1=new JLabel("I am from China!"); add(yellowButton); add(blueButton); add(redButton); add(j1); yellowButtofl.addActionListener(this); blueButton.addActionListener(this); redButton.addActionListener(this); } public void actionPerformed(ActionEvent evt){ 0bject source=evt.getSource(); Color color=getForeground(); if(source= =yellowButton)color=Color. yellow; else if(source= =blueButton)color=Color. blue; else if(source= =redButton)color= Color.red; ; ; } private JButton yellowButton; private JButton blueButton; private JButton redButton; private JLabel jl; } class ButtonFrame extends JFrame{ public ButtonFrame(){ setTitle("exam l6"); setSize(300,200); addWindowListener(new WindowAdapter(){ public void windowClosing(WindowEvent e){ System.exit(O); } }); Container contentPane=getContentPane(); contentPane.add(new ButtonPanel()); } } public class java2{ public static void main(String[]args){ JFrame frame=new ButtonFrame(); frame.show(); } }