jtable

Filter dynamically jTable by column value

自闭症网瘾萝莉.ら 提交于 2020-08-25 03:59:17
问题 I need to dynamically filter my JTable by a value from a specific column. So if i have 2 columns, for example "Country" and "Capital", i want to filter only by column Country. I found part of the solution of my problem by implementing this code: import java.awt.BorderLayout; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.JTextField; import javax.swing

Filter dynamically jTable by column value

倾然丶 夕夏残阳落幕 提交于 2020-08-25 03:58:57
问题 I need to dynamically filter my JTable by a value from a specific column. So if i have 2 columns, for example "Country" and "Capital", i want to filter only by column Country. I found part of the solution of my problem by implementing this code: import java.awt.BorderLayout; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.JTextField; import javax.swing

Java图形用户界面swing假死卡死问题和JTable动态刷新问题的解决方案

心不动则不痛 提交于 2020-08-12 15:29:56
发现问题 JTable动态刷新直到最后一次才刷新出来 swing界面在刷新过程中被卡住无法点击 所在项目 进程调度模拟 问题代码 点击“开始”后执行 private void button2ActionPerformed ( ActionEvent e ) { // TODO add your code here //执行进程 select = comboBox1 . getSelectedIndex ( ) ; renewThread . start ( ) ; switch ( select ) { case 0 : { processScheduling . FCFS ( ) ; break ; } case 1 : { processScheduling . SPF ( ) ; break ; } } } 刷新一次(取出数据放入JTable) public void renewJTable4 ( ) { //取出正在动态变化中的数据 List < PCB > list = processScheduling . getFCFSPcb ( ) ; //更新表格 DefaultTableModel tableModel = ( ( DefaultTableModel ) table4 . getModel ( ) ) ; tableModel . getDataVector (

Color a distinct field in a Jtable While Data is inserted from SQL

怎甘沉沦 提交于 2020-08-09 09:03:45
问题 i have Jtable in Java that inserting data from SQL What i need to do if the Field Nummber 3 is = to 0 i need to set the backround of it to be Red and others is Not Any Help ? NoSelect: WithSelect: Edit : Try to use a different method to change the color using TableCellRenderer RederColer = (JTable table, Object value, boolean isSelected, boolean hasFocus, int row1, int column) -> { if (table.getModel().getValueAt(row, 2).equals("0")) { setForeground(Color.RED); } else { setForeground(Color

Color a distinct field in a Jtable While Data is inserted from SQL

一笑奈何 提交于 2020-08-09 09:03:20
问题 i have Jtable in Java that inserting data from SQL What i need to do if the Field Nummber 3 is = to 0 i need to set the backround of it to be Red and others is Not Any Help ? NoSelect: WithSelect: Edit : Try to use a different method to change the color using TableCellRenderer RederColer = (JTable table, Object value, boolean isSelected, boolean hasFocus, int row1, int column) -> { if (table.getModel().getValueAt(row, 2).equals("0")) { setForeground(Color.RED); } else { setForeground(Color

paging in java swing with jtable and database

不想你离开。 提交于 2020-07-31 04:17:48
问题 I am new to java and I am working on Jtable with database.i fill up my jtable by data from database ,now I need to use paging and I don't know how to implement this in my code,i used DbUtils to fill up the jtable,every think is ok but the problem is that i don't know how to use pagination, thank you in advance for any sharing of information and help public class FenetrePers extends JFrame { private JTextField rechNomField; private JTextField rechPrenField; private JTextField rechemailField;

Exception in thread “AWT-EventQueue-0” java.lang.ClassCastException: class java.lang.Integer cannot be cast to class java.lang.String

十年热恋 提交于 2020-06-28 06:12:29
问题 I writing JTable data into CSV file using OpenCSV jar. Everything works fine unless it comes to read data from the table data. Whenever I am choosing the first row it works perfectly. But when I am choosing the more than one row it gives the exception which is mentioned in the title. Below is the code: DefaultTableModel tableModel = (DefaultTableModel) jTable1.getModel(); int rows = Integer.parseInt((String)jTextField8.getText()); String fileName = jTextField11.getText()+".csv"; File file =