久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<i id='TtK4k'><tr id='TtK4k'><dt id='TtK4k'><q id='TtK4k'><span id='TtK4k'><b id='TtK4k'><form id='TtK4k'><ins id='TtK4k'></ins><ul id='TtK4k'></ul><sub id='TtK4k'></sub></form><legend id='TtK4k'></legend><bdo id='TtK4k'><pre id='TtK4k'><center id='TtK4k'></center></pre></bdo></b><th id='TtK4k'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='TtK4k'><tfoot id='TtK4k'></tfoot><dl id='TtK4k'><fieldset id='TtK4k'></fieldset></dl></div>
      <bdo id='TtK4k'></bdo><ul id='TtK4k'></ul>

      <legend id='TtK4k'><style id='TtK4k'><dir id='TtK4k'><q id='TtK4k'></q></dir></style></legend>

      <small id='TtK4k'></small><noframes id='TtK4k'>

      <tfoot id='TtK4k'></tfoot>

      1. JTable ->表模式監聽器

        JTable -gt; TableModeListener(JTable -表模式監聽器)
            <bdo id='0m4lC'></bdo><ul id='0m4lC'></ul>
              <tbody id='0m4lC'></tbody>
            <legend id='0m4lC'><style id='0m4lC'><dir id='0m4lC'><q id='0m4lC'></q></dir></style></legend>
            <i id='0m4lC'><tr id='0m4lC'><dt id='0m4lC'><q id='0m4lC'><span id='0m4lC'><b id='0m4lC'><form id='0m4lC'><ins id='0m4lC'></ins><ul id='0m4lC'></ul><sub id='0m4lC'></sub></form><legend id='0m4lC'></legend><bdo id='0m4lC'><pre id='0m4lC'><center id='0m4lC'></center></pre></bdo></b><th id='0m4lC'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='0m4lC'><tfoot id='0m4lC'></tfoot><dl id='0m4lC'><fieldset id='0m4lC'></fieldset></dl></div>

                <tfoot id='0m4lC'></tfoot>

                <small id='0m4lC'></small><noframes id='0m4lC'>

                1. 本文介紹了JTable ->表模式監聽器的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我有這個 JTable 有一個 DefaultTableModel 作為它的模型.在桌子上,我有幾個擺動組件,JComboBoxJCheckBox,通過 DefaultCellEditorDefaultCellRenderer 在特定列上設置.TableModelListener 已添加到表中以捕獲可編輯列的更改.其余列將顯示所選組件的詳細信息,即商品代碼 -> 商品價格、商品數量、商品分類等.

                  I have this JTable having a DefaultTableModel as its model. On the table I have several swing component, JComboBox and JCheckBox, set on a particular column via DefaultCellEditor and DefaultCellRenderer. The TableModelListener was added to the table to capture changes on editable columns. The rest of the columns will display details of the selected component, i.e. item code -> item price, item count, item classification,etc.

                  我有這個問題,如果 JComboBox(itemCode) 的 selectedItem 發生變化,其他 JComboBox(itemClassification) 的項目也會發生變化.但隨著其他 JComboBox 的變化,我需要在同一張桌子上顯示商品價格.此更改重新觸發 valueChanged 方法,該方法使 valueChanged 無限循環.

                  I have this problem wherein if the selectedItem of the JComboBox(itemCode) changes, the items of the other JComboBox(itemClassification) changes. But together with the change of the other JComboBox I need to display the item price on the same table. This change refires the valueChanged method which makes an infinite loop of valueChanged.

                  我怎樣才能擺脫無限循環的東西?

                  How can I get rid of the infinite loop thing?

                  推薦答案

                  一種方法是檢查更新事件以查看該事件是針對哪一列并忽略自動更新的列:

                  One way is to check the update event to see what column the event is for and ignore columns that are automatically updated:

                  import java.awt.*;
                  import java.awt.event.*;
                  import javax.swing.*;
                  import javax.swing.event.*;
                  import javax.swing.table.*;
                  
                  public class TableProcessing extends JPanel implements TableModelListener
                  {
                      public TableProcessing()
                      {
                          String[] columnNames = {"Item", "Quantity", "Price", "Cost"};
                          Object[][] data =
                          {
                              {"Bread", new Integer(1), new Double(1.11), new Double(1.11)},
                              {"Milk", new Integer(1), new Double(2.22), new Double(2.22)},
                              {"Tea", new Integer(1), new Double(3.33), new Double(3.33)},
                              {"Cofee", new Integer(1), new Double(4.44), new Double(4.44)}
                          };
                  
                          DefaultTableModel model = new DefaultTableModel(data, columnNames)
                          {
                              //  Returning the Class of each column will allow different
                              //  renderers to be used based on Class
                              @Override
                              public Class getColumnClass(int column)
                              {
                                  return getValueAt(0, column).getClass();
                              }
                  
                              //  The Cost is not editable
                              @Override
                              public boolean isCellEditable(int row, int column)
                              {
                                  return (column == 3) ? false : true;
                              }
                          };
                          model.addTableModelListener( this );
                  
                          JTable table = new JTable( model );
                          table.setPreferredScrollableViewportSize(table.getPreferredSize());
                  
                          JScrollPane scrollPane = new JScrollPane( table );
                          add( scrollPane );
                  
                          String[] items = { "Bread", "Milk", "Tea", "Coffee" };
                          JComboBox<String> editor = new JComboBox<String>( items );
                  
                          DefaultCellEditor dce = new DefaultCellEditor( editor );
                          table.getColumnModel().getColumn(0).setCellEditor(dce);
                      }
                  
                      /*
                       *  The cost is recalculated whenever the quantity or price is changed
                       */
                      public void tableChanged(TableModelEvent e)
                      {
                          if (e.getType() == TableModelEvent.UPDATE)
                          {
                              int row = e.getFirstRow();
                              int column = e.getColumn();
                  
                              if (column == 1 || column == 2)
                              {
                                  TableModel model = (TableModel)e.getSource();
                                  int quantity = ((Integer)model.getValueAt(row, 1)).intValue();
                                  double price = ((Double)model.getValueAt(row, 2)).doubleValue();
                                  Double value = new Double(quantity * price);
                                  model.setValueAt(value, row, 3);
                              }
                          }
                      }
                  
                      private static void createAndShowGUI()
                      {
                          JFrame frame = new JFrame("Table Model Listener");
                          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                          frame.add(new TableProcessing());
                          frame.pack();
                          frame.setLocationByPlatform( true );
                          frame.setVisible( true );
                      }
                  
                      public static void main(String[] args) throws Exception
                      {
                          EventQueue.invokeLater( () -> createAndShowGUI() );
                  /*
                          EventQueue.invokeLater(new Runnable()
                          {
                              public void run()
                              {
                                  createAndShowGUI();
                              }
                          });
                  */
                      }
                  }
                  

                  這篇關于JTable ->表模式監聽器的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  How can I detect integer overflow on 32 bits int?(如何檢測 32 位 int 上的整數溢出?)
                  Local variables before return statements, does it matter?(return 語句之前的局部變量,這有關系嗎?)
                  How to convert Integer to int?(如何將整數轉換為整數?)
                  How do I create an int array with randomly shuffled numbers in a given range(如何在給定范圍內創建一個隨機打亂數字的 int 數組)
                  Inconsistent behavior on java#39;s ==(java的行為不一致==)
                  Why is Java able to store 0xff000000 as an int?(為什么 Java 能夠將 0xff000000 存儲為 int?)

                  1. <small id='aGh6T'></small><noframes id='aGh6T'>

                      <tbody id='aGh6T'></tbody>
                    <legend id='aGh6T'><style id='aGh6T'><dir id='aGh6T'><q id='aGh6T'></q></dir></style></legend>
                    • <bdo id='aGh6T'></bdo><ul id='aGh6T'></ul>
                    • <tfoot id='aGh6T'></tfoot>
                      <i id='aGh6T'><tr id='aGh6T'><dt id='aGh6T'><q id='aGh6T'><span id='aGh6T'><b id='aGh6T'><form id='aGh6T'><ins id='aGh6T'></ins><ul id='aGh6T'></ul><sub id='aGh6T'></sub></form><legend id='aGh6T'></legend><bdo id='aGh6T'><pre id='aGh6T'><center id='aGh6T'></center></pre></bdo></b><th id='aGh6T'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='aGh6T'><tfoot id='aGh6T'></tfoot><dl id='aGh6T'><fieldset id='aGh6T'></fieldset></dl></div>

                            主站蜘蛛池模板: 午夜视频在线 | 国产在线a | 成年人黄色免费视频 | 国产欧美日韩 | 久久久久免费 | 国产一区二区中文字幕 | 国产精品亚洲精品 | 精品日韩一区 | 国产精品免费看 | 日韩视频一区二区三区 | 久久亚洲91 | 日韩高清三区 | 中文字幕在线视频免费观看 | 国产成人av电影 | 在线观看视频91 | 国产成人免费在线 | 一区二区三区国产 | 99精品一区二区 | 韩国av网站在线观看 | 91精品国产91久久久 | 在线观看视频91 | 成人毛片视频在线播放 | 国产高清一区二区三区 | 99国产精品久久久 | 电影91久久久 | 欧美一级欧美一级在线播放 | 91麻豆精品一区二区三区 | 天天射美女 | 激情网五月天 | 一级黄色毛片免费 | 天天人人精品 | 久久999 | av手机在线播放 | 欧美日韩一区在线播放 | 一级片av| 久久久久久网站 | 91视频三区 | 国产福利二区 | 成人在线观看中文字幕 | 精品九九九 | 国产精品不卡视频 |