Javafx中tabeview怎么添加radio button按钮

Javafx中tabeview怎么添加radio button按钮,第1张

你的listview填充的时候有个bean吧。里面加一个标志位,表示要显示radioButton

or

button;在adapter里面getview的代码根据这个变量控制不同的显示按钮,当然布局里面是要放两个的,通过隐藏和显示来达到效果;当软件的下载状态或者安装状态改变的时候,你的bean里面的这个标志位也就改变了,然后调用adapter的.notifyDataSetChanged()

重新显示一遍UI就可以了

如果你要求的 字符 不参与运算 ,那就如下

选中A 列--右键---设置单元格格式--自定义右边输入"K"@

或者 B1 输入="K"&A1

鼠标移到B1 右下角变实心十字下拉

选中B列---复制--右键--选择性粘贴---值---- 删除A列

按照你的要求添加两个按钮的Java程序如下:

package com.sunshine.customer

 import java.awt.*

import java.awt.event.*

import javax.swing.* 

import javax.swing.table.DefaultTableModel

public class JTableDemo extends JFrame implements ActionListener{    

 private JPanel topPanel    

 private JTable table

 private JButton addRoom=new JButton("添加房间")

 private JButton removeRoom=new JButton("删除房间")

 private DefaultTableModel dtm

 public JTableDemo(){        

  setTitle( "Simple JTable Application" )        

  setSize(560, 400 )        

  setBackground( Color.gray )         

  topPanel = new JPanel()

  topPanel.setLayout( new BorderLayout() )        

  getContentPane().add( topPanel )         

  String cols[] = {"房间号","是否预定","房间价格","房间类型","房间状态","卫生情况","剩余时间"}        

  String rowData[][] = {{ "", "", "","","","",""},

    { "", "", "","","","",""},{ "", "", "","","","",""},{ "", "", "","","","",""},

    { "", "", "","","","",""},{ "", "", "","","","",""},{ "", "", "","","","",""},            

    { "", "", "","","","",""},{ "", "", "","","","",""},{ "", "", "","","","",""},

    { "", "", "","","","",""},{ "", "", "","","","",""},{ "", "", "","","","",""},}

  dtm=new DefaultTableModel()

  dtm.setDataVector(rowData, cols)

  table = new JTable(dtm)        

  JScrollPane scrollPane = new JScrollPane(table)        

  topPanel.add( scrollPane, BorderLayout.CENTER )

  addRoom.addActionListener(this)

  removeRoom.addActionListener(this)

  JPanel p=new JPanel()

  p.add(addRoom)

  p.add(removeRoom)

  topPanel.add( p,BorderLayout.SOUTH )

 }     

 public static void main( String args[] ) {        

  JTableDemo mainFrame = new JTableDemo()        

  mainFrame.setVisible( true )    

 }

 @Override

 public void actionPerformed(ActionEvent ae) {

  if(ae.getSource()==addRoom){

   String row[]={ "", "", "","","","",""}

   dtm.addRow(row)

  }

  if(ae.getSource()==removeRoom){

   dtm.removeRow(table.getSelectedRow())

  }

 }

}


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/bake/11876189.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-19
下一篇 2023-05-19

发表评论

登录后才能评论

评论列表(0条)

保存