question one:
***Table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);question two:
表格要添加事件侦听器,然后getSelectedIndex...question three:
是要改变按钮上的文字还是功能?
文字:JButton.setText("***");
功能:remove actionListener;
      再 add actionListener;

解决方案 »

  1.   

    I think this is the best solution.
      

  2.   

    2 table.getSelectionModel().addListSelectionListener(
          new ListSelectionListener() {
            public void valueChanged(ListSelectionEvent e) {
              if (!e.getValueIsAdjusting()) {
                dosomething();
              }
            }
          }
        );1.3建议去看看jdk demo中的SwingSet2
      

  3.   

    第一个我明白//20分已解决,此问题无须再回第三个是不是要在actionPerformed里面写?
    至于第二个,能不能说得明白些?
    最好给点代码?随便从表中取一个字段就行
    表格要添加事件侦听器,然后getSelectedIndex...
      

  4.   

    to Apocalypse(逍遥思辨):
    你写的这个,能不能再详细些,老实说我真的没看懂……
    鼠标选中一条记录,此时
    比如我想将选中的第一个字段放入jTextField1里面,该如何处理?
    (页面的其它部分不变)
      

  5.   

    table.getSelectionModel().addListSelectionListener(
          new ListSelectionListener() {
            public void valueChanged(ListSelectionEvent e) {
              if (!e.getValueIsAdjusting()) {
                int row = table.getSelectedRow();
                jTextField1.setText((String)table.getValueAt(row, 0));
              }
            }
          }
        );
      

  6.   

    table.getSelectionModel().addListSelectionListener(
          new ListSelectionListener() {
            public void valueChanged(ListSelectionEvent e) {
              if (!e.getValueIsAdjusting()) {
                String value = (String)table.getValueAt(table.getSelectedRow(), 0) //选中行的第一个字段
                jTextField1.setText(value);
              }
            }
          }
        );过滤e.getValueIsAdjusting()是因为对JTable的一些操作也会触发ListSelectionEvent(比如调整单元格大小等),而这样的操作是不需要响应的
      

  7.   

    to 逍遥思辨!
    你给的代码我添加进去了,但是不行,说需要返回成员数据。
    Error #: 215 : invalid method declaration; return type required at line 28, column 26
      

  8.   

    问题3:
    当一个JButton(按钮)被按下后,怎么将它换成另外一个JButton(按钮)?
    这个问题你可以如下处理:
    比如JButton1 -->JButton2
    设计的时候可以将这两个JButton放在同一个位置,先将JButton2.setVisible(false);//隐藏此按钮
    然后在JButton1的按钮事件里面添加
    void jBChange_actionPerformed(ActionEvent e) {
        JButton1.setVisible(false);
        JButton2.setVisible(true);//隐藏JButton1,显示JButton2
        ……
        其它处理
    }
    这个不就行了?