Unable to add two buttons in a single cell in a JTable

后端 未结 3 2076
南旧
南旧 2021-01-14 00:52

I am trying to make a dynamic table that fetches data from a database and adds those data in separate rows..I want to add an extra cell with each row(dynamically) th

3条回答
  •  灰色年华
    2021-01-14 01:00

    • cell cann't nest two JComponents because default JComponent/JLabel (returns by Renderer) haven't implemented any LayoutManager in API (in compare with JFrame/JDialog... or JPanel), have to set proper LayoutManager (Grid/BoxLayout) and important is to override PrederredSize, don't do that, road to troubles

    • there are three ways

      1. add JPanel with two JButtons as Renderer and Editor too (search here for RollOver effect for JButtons Component as renderers components)

      2. use JCheckBox (built_in Boolean support for Renderer and Editor too)

      3. use two JRadioButtons in ButtonGroup

        • with JRadioButton as Renderer and Editor too

        • (better, nicer, easier) with JRadioButtons in ButtonGroup as Renderer and JComboBox as Editor

提交回复
热议问题