esoe
3 years ago
12 changed files with 115 additions and 7 deletions
@ -0,0 +1,34 @@
@@ -0,0 +1,34 @@
|
||||
package ru.egspt; |
||||
|
||||
import java.awt.Dimension; |
||||
import java.awt.Color; |
||||
|
||||
import javax.swing.JButton; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.JScrollPane; |
||||
import javax.swing.JTable; |
||||
import javax.swing.border.LineBorder; |
||||
import javax.swing.border.TitledBorder; |
||||
|
||||
public class ReportPane extends JPanel{ |
||||
JPanel controlPane = new JPanel();//панель кнопок - пока не надо
|
||||
JButton generateXLSXButton = new JButton("create xlsx"); |
||||
JButton generateTXTButton = new JButton("create txt"); |
||||
JPanel tabPane = new JPanel();//панель таблицы
|
||||
public ReportPane(){ |
||||
controlPane.add(generateXLSXButton); |
||||
controlPane.add(generateTXTButton); |
||||
this.add(controlPane); |
||||
this.add(tabPane); |
||||
TitledBorder border = new TitledBorder(new LineBorder(Color.black), "report", TitledBorder.CENTER, TitledBorder.CENTER); |
||||
this.setBorder(border); |
||||
this.setVisible(true); |
||||
} |
||||
public void setData(Data data){ |
||||
JTable table = new JTable(new ReportTableModel(data)); |
||||
table.setPreferredScrollableViewportSize(new Dimension(500, 70)); |
||||
table.setFillsViewportHeight(true); |
||||
JScrollPane scrollPane = new JScrollPane(table); |
||||
tabPane.add(scrollPane); |
||||
} |
||||
} |
@ -0,0 +1,58 @@
@@ -0,0 +1,58 @@
|
||||
package ru.egspt; |
||||
|
||||
import javax.swing.table.AbstractTableModel; |
||||
|
||||
public class ReportTableModel extends AbstractTableModel{ |
||||
private String[] header = {"id", "login", "mail"}; |
||||
private Object[][] data; |
||||
public ReportTableModel(Data data){ |
||||
//заполняем модель данными
|
||||
int i = 0; |
||||
while (i < data.getUsers().size()){ |
||||
this.data[0][i] = data.getUsers().get(i).getId(); |
||||
this.data[1][i] = data.getUsers().get(i).getLogin(); |
||||
this.data[2][i] = data.getUsers().get(i).getMail(); |
||||
i++; |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public int getRowCount() { |
||||
return getData().length; |
||||
} |
||||
|
||||
@Override |
||||
public int getColumnCount() { |
||||
return getHeader().length; |
||||
} |
||||
|
||||
@Override |
||||
public Object getValueAt(int rowIndex, int columnIndex) { |
||||
return getData()[rowIndex][columnIndex]; |
||||
} |
||||
/** |
||||
* @return the data |
||||
*/ |
||||
public Object[][] getData() { |
||||
return data; |
||||
} |
||||
/** |
||||
* @param data the data to set |
||||
*/ |
||||
public void setData(Object[][] data) { |
||||
this.data = data; |
||||
} |
||||
/** |
||||
* @return the header |
||||
*/ |
||||
public String[] getHeader() { |
||||
return header; |
||||
} |
||||
/** |
||||
* @param header the header to set |
||||
*/ |
||||
public void setHeader(String[] header) { |
||||
this.header = header; |
||||
} |
||||
|
||||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in new issue