爱问知识人 爱问教育 医院库

如何点击单选按扭输出相应的话?

首页

如何点击单选按扭输出相应的话?

如上。
比如我打算点一下单选按扭然后输出一句话。一共4个按扭,比如按下a键输出“你好”,按下b键输出“再见”等等。应该如何弄?

提交回答
好评回答
  • 2007-07-25 09:45:20
    用vb 或 delphi吧
    太简单了
    1、建个工程
    2、建个窗体或表单
    3、拉上几个按钮,分别命名
    4、双击各个按钮,并生成的函数段中加入代码:
    以 vb为例。
    private sub command1_click()
         textbox1.text = "哈哈,文字输出其不意"   ' 输出到文本框
         debug.print "哈哈,文字输出"   ' 输出到调试栏
         ? " 哈哈"  ' 输出到窗体表单
    end sub
    5、其它类推。
    够明白了吧。

    x***

    2007-07-25 09:45:20

其他答案

    2007-07-30 15:34:19
  • 将下列内容保存成.html文件,打开浏览器看看:
    
    
    test
    
    
    a
    b
    c
    d
    function hello(){ var or=document.getElementsByName("ra1"); for(var i=0;i

    l***

    2007-07-30 15:34:19

  • 2007-07-16 09:32:13
  •   package test;
    import  t。BorderLayout;
    import javax。swing。JPanel;
    import javax。swing。JFrame;
    import javax。swing。JRadioButton;
    import javax。
      swing。JDesktopPane; import t。Rectangle; import t。event。ActionListener; import javax。swing。JLabel; public class Test2 extends JFrame { private static final long serialVersionUID = 1L; private JPanel jContentPane = null; private JRadioButton[] jRadioButton = null; private JDesktopPane jDesktopPane = null; private JLabel jLabel = null; private int selectRadio = -1; public Test2() { super(); initialize(); } private void initialize() { tSize(300, 200); tContentPane(getJContentPane()); tTitle("JFrame"); } private JPanel getJContentPane() { if (jContentPane == null) { jContentPane = new JPanel(); tLayout(new BorderLayout()); d(getJDesktopPane(), BorderLayout。
      CENTER); } return jContentPane; } private JRadioButton[] getJRadioButton() { if (jRadioButton == null) { ActionListener listener = new MyListener(); jRadioButton = new JRadioButton[4]; for(int i = 0; i < 4; i++) jRadioButton[i] = new JRadioButton(); jRadioButton[0]。
      setBounds(new Rectangle(30, 30, 50, 25)); jRadioButton[0]。setText("a"); jRadioButton[1]。setBounds(new Rectangle(100, 30, 50, 25)); jRadioButton[1]。
      setText("b"); jRadioButton[2]。setBounds(new Rectangle(30, 100, 50, 25)); jRadioButton[2]。setText("c"); jRadioButton[3]。
      setBounds(new Rectangle(100, 100, 50, 25)); jRadioButton[3]。setText("d"); for(int i = 0; i < 4; i++) jRadioButton[i]。
      addActionListener(listener); } return jRadioButton; } private JDesktopPane getJDesktopPane() { if (jDesktopPane == null) { jLabel = new JLabel(); tBounds(new Rectangle(198, 63, 79, 40)); tText(""); jDesktopPane = new JDesktopPane(); d(jLabel, null); for(int i = 0; i < 4; i++) d(getJRadioButton()[i], null); } return jDesktopPane; } class MyListener implements ActionListener{ public void actionPerformed( t。
      event。ActionEvent e) { if(selectRadio != -1) jRadioButton[selectRadio]。setSelected(false); for(int i = 0; i < 4; i++){ if(jRadioButton[i]。
      isSelected()){ selectRadio = i; break; } } tText(jRadioButton[selectRadio]。getText()); } } public static void main(String[] args){ (new Test2())。
      setVisible(true); } }。

    p***

    2007-07-16 09:32:13

类似问题

换一换
  • JAVA相关 相关知识

  • 电脑网络技术
  • 电脑网络

相关推荐

正在加载...
最新资料 推荐信息 热点推荐
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200

热点检索

  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 180-199
返回
顶部
帮助 意见
反馈

确定举报此问题

举报原因(必选):