List of usage examples for javax.swing JScrollPane setCorner
public void setCorner(String key, Component corner)
From source file:edu.ucla.stat.SOCR.chart.Chart.java
public void updateEditableHeader(TableColumnModel aColumnModel) { dTableHeader = new EditableHeader(aColumnModel); /*for (int i=0; i<aColumnModel.getColumnCount(); i++){ System.out.println("H "+aColumnModel.getColumn(i).getHeaderValue()); }*///from w w w . j a v a 2s. com dTableHeader.setEditingColumn(-1); dataTable.setTableHeader(dTableHeader); dataTable.validate(); dataPanel.removeAll(); JTableHeader corner = headerTable.getTableHeader(); corner.setReorderingAllowed(false); corner.setResizingAllowed(false); JScrollPane tablePanel = new JScrollPane(dataTable); tablePanel.setRowHeaderView(headerTable); tablePanel.setCorner(JScrollPane.UPPER_LEFT_CORNER, corner); new JScrollPaneAdjuster(tablePanel); new JTableRowHeaderResizer(tablePanel).setEnabled(true); dataPanel.add(tablePanel); JScrollPane st = new JScrollPane(summaryPanel); st.setPreferredSize(new Dimension(CHART_SIZE_X, CHART_SIZE_Y / 3)); dataPanel.add(new JScrollPane(st)); dataPanel.validate(); //System.out.println("table Header updated"); }
From source file:edu.ucla.stat.SOCR.chart.Chart.java
/** * clear data panel/*from w ww .j a v a2 s . co m*/ * */ public void resetTable() { // System.out.println("resetTable get called"); for (int i = 0; i < columnNumber; i++) columnNames[i] = new String(DEFAULT_HEADER + (i + 1)); tModel = new javax.swing.table.DefaultTableModel(dataObject, columnNames); hModel = new DefaultTableModel(0, 1); for (int i = 0; i < tModel.getRowCount(); i++) hModel.addRow(new Object[] { (i + 1) + ":" }); dataTable = new JTable(tModel); /* System.out.println("here2"); dataTable.getTableHeader().addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e) { TableColumnModel colModel = dataTable.getColumnModel(); int columnModelIndex = colModel.getColumnIndexAtX(e.getX()); selectedHeaderColumnIndex = colModel.getColumn(columnModelIndex) .getModelIndex(); System.out.println("mouseClicked haeder "+selectedHeaderColumnIndex); } });*/ /*final JTableHeader heading = dataTable.getTableHeader(); heading.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e) { selectedHeaderColumnIndex = heading.columnAtPoint(e.getPoint()); System.out.println("mouseClicked haeder "+selectedHeaderColumnIndex); } }); */ dataTable.setGridColor(Color.gray); dataTable.setShowGrid(true); dataTable.doLayout(); dataTable.setCellSelectionEnabled(true); dataTable.setColumnSelectionAllowed(true); dataTable.setRowSelectionAllowed(true); columnModel = dataTable.getColumnModel(); dTableHeader = new EditableHeader(columnModel); dataTable.setTableHeader(dTableHeader); listIndex = new int[dataTable.getColumnCount()]; for (int j = 0; j < listIndex.length; j++) listIndex[j] = 1; hookTableAction(); headerTable = new JTable(hModel); headerTable.setCellSelectionEnabled(false); LookAndFeel.installColorsAndFont(headerTable, "TableHeader.background", "TableHeader.foreground", "TableHeader.font"); headerTable.setIntercellSpacing(new Dimension(0, 0)); Dimension d = headerTable.getPreferredScrollableViewportSize(); d.width = headerTable.getPreferredSize().width; headerTable.setPreferredScrollableViewportSize(d); headerTable.setRowHeight(dataTable.getRowHeight()); headerTable.setDefaultRenderer(Object.class, new RowHeaderRenderer()); JTableHeader corner = headerTable.getTableHeader(); corner.setReorderingAllowed(false); corner.setResizingAllowed(false); // summaryPanel.setPreferredSize(new Dimension(CHART_SIZE_X,CHART_SIZE_Y/2)); summaryPanel.removeAll(); dataPanel.removeAll(); JScrollPane tablePanel = new JScrollPane(dataTable); tablePanel.setRowHeaderView(headerTable); tablePanel.setCorner(JScrollPane.UPPER_LEFT_CORNER, corner); new JScrollPaneAdjuster(tablePanel); new JTableRowHeaderResizer(tablePanel).setEnabled(true); dataPanel.add(tablePanel); JScrollPane st = new JScrollPane(summaryPanel); st.setPreferredSize(new Dimension(CHART_SIZE_X, CHART_SIZE_Y / 3)); dataPanel.add(new JScrollPane(st)); dataPanel.validate(); }
From source file:edu.ucla.stat.SOCR.chart.Chart.java
/** * setup GUI layout for the data panel including datatable and summary textArea * *///from w w w. jav a 2 s.com protected void initTable() { tModel = new DefaultTableModel(dataObject, columnNames); hModel = new DefaultTableModel(0, 1); dataTable = new JTable(tModel); /* System.out.println("here"); dataTable.getTableHeader().addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e) { TableColumnModel colModel = dataTable.getColumnModel(); int columnModelIndex = colModel.getColumnIndexAtX(e.getX()); selectedHeaderColumnIndex = colModel.getColumn(columnModelIndex) .getModelIndex(); System.out.println("mouseClicked haeder "+selectedHeaderColumnIndex); } });*/ /*final JTableHeader heading = dataTable.getTableHeader(); dataTable.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e) { selectedHeaderColumnIndex = heading.columnAtPoint(e.getPoint()); System.out.println("mouseClicked haeder "+selectedHeaderColumnIndex); } }); */ dataTable.addKeyListener(this); dataTable.setGridColor(Color.gray); dataTable.setShowGrid(true); for (int i = 0; i < tModel.getRowCount(); i++) hModel.addRow(new Object[] { (i + 1) + ":" }); headerTable = new JTable(hModel); headerTable.setCellSelectionEnabled(false); headerTable.setEnabled(false); headerTable.setGridColor(Color.gray); headerTable.setShowGrid(true); LookAndFeel.installColorsAndFont(headerTable, "TableHeader.background", "TableHeader.foreground", "TableHeader.font"); headerTable.setIntercellSpacing(new Dimension(0, 0)); Dimension d = headerTable.getPreferredScrollableViewportSize(); d.width = headerTable.getPreferredSize().width; headerTable.setPreferredScrollableViewportSize(d); headerTable.setRowHeight(dataTable.getRowHeight()); headerTable.setDefaultRenderer(Object.class, new RowHeaderRenderer()); JTableHeader corner = headerTable.getTableHeader(); corner.setReorderingAllowed(false); corner.setResizingAllowed(false); // this is a fix for the BAD SGI Java VM - not up to date as of dec. 22, 2003 try { dataTable.setDragEnabled(true); } catch (Exception e) { } columnModel = dataTable.getColumnModel(); dTableHeader = new EditableHeader(columnModel); dataTable.setTableHeader(dTableHeader); dataTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); dataTable.setCellSelectionEnabled(true); dataTable.setColumnSelectionAllowed(true); dataTable.setRowSelectionAllowed(true); hookTableAction(); dataPanel = new JPanel(); summaryPanel = new JTextArea(); // summaryPanel.setPreferredSize(new Dimension(CHART_SIZE_X,CHART_SIZE_Y/2)); Color bg = dataPanel.getBackground(); summaryPanel.setBackground(bg); summaryPanel.setEditable(false); summaryPanel.setForeground(Color.BLACK); dataPanel.setLayout(new BoxLayout(dataPanel, BoxLayout.Y_AXIS)); JScrollPane tablePanel = new JScrollPane(dataTable); tablePanel.setRowHeaderView(headerTable); tablePanel.setCorner(JScrollPane.UPPER_LEFT_CORNER, corner); new JScrollPaneAdjuster(tablePanel); new JTableRowHeaderResizer(tablePanel).setEnabled(true); dataPanel.add(tablePanel); JScrollPane st = new JScrollPane(summaryPanel); st.setPreferredSize(new Dimension(CHART_SIZE_X, CHART_SIZE_Y / 3)); dataPanel.add(new JScrollPane(st)); dataPanel.validate(); }
From source file:app.RunApp.java
/** * Fill the table with Chi and Phi coefficients * //from w ww . j a v a 2 s . c o m * @param dataset Multi-label dataset */ private void fillTableChiPhiCoefficients(MultiLabelInstances dataset) { chiPhiCoefficients = ChartUtils.getChiPhiCoefficients(dataset); data = new Object[chiPhiCoefficients.length][chiPhiCoefficients.length + 1]; column = new Object[data.length + 1]; for (int i = 0; i < chiPhiCoefficients.length; i++) { data[i] = Utils.getValuesByRow(i, chiPhiCoefficients, dataset.getLabelNames()[i]); } for (int i = 0; i < column.length; i++) { if (i == 0) { column[i] = "Labels"; } else { column[i] = (dataset.getLabelNames()[i - 1]); } } AbstractTableModel1 fixedModel = new AbstractTableModel1(data, column); AbstractTableModel2 model = new AbstractTableModel2(data, column); fixedTableChiPhi.setModel(fixedModel); jTableChiPhi.setModel(model); JScrollPane scroll = new JScrollPane(jTableChiPhi); JViewport viewport = new JViewport(); viewport.setView(fixedTableChiPhi); viewport.setPreferredSize(fixedTableChiPhi.getPreferredSize()); scroll.setRowHeaderView(viewport); scroll.setBounds(20, 20, 780, 390); scroll.setCorner(JScrollPane.UPPER_LEFT_CORNER, fixedTableChiPhi.getTableHeader()); jTableChiPhi.setBorder(BorderFactory.createLineBorder(Color.black)); if (firstTimeChi) { panelChiPhi.add(scroll, BorderLayout.CENTER, 0); firstTimeChi = false; return; } panelChiPhi.remove(0); panelChiPhi.add(scroll, BorderLayout.CENTER, 0); }
From source file:app.RunApp.java
/** * Fill the table with coefficient values * /* w w w . j a v a 2 s .c o m*/ * @param dataset * @param pairs * @param type */ private void fillTableCoefficients(MultiLabelInstances dataset, String type) { double[][] pairLabelValues; //coocurrence values table if (type.equals("coocurrence")) { pairLabelValues = ChartUtils.getCoocurrences(dataset); coocurrenceCoefficients = pairLabelValues; } //heatmap values table else { pairLabelValues = getHeatMapCoefficients(); heatmapCoefficients = pairLabelValues.clone(); } /** **/ data = new Object[pairLabelValues.length][pairLabelValues.length + 1]; column = new Object[data.length + 1]; if (type.equals("coocurrence")) { for (int i = 0; i < pairLabelValues.length; i++) { for (int j = 0; j < pairLabelValues.length; j++) { if (j == 0) { data[i][j] = dataset.getLabelNames()[i]; } else if (i == (j - 1)) { data[i][j] = ""; } else if (j > i) { data[i][j] = ""; } else { if (pairLabelValues[j - 1][i] <= 0.0) { data[i][j] = ""; } else { data[i][j] = (int) pairLabelValues[j - 1][i]; } } } } } else { for (int i = 0; i < pairLabelValues.length; i++) { for (int j = 0; j < pairLabelValues.length + 1; j++) { if (j == 0) { data[i][j] = dataset.getLabelNames()[i]; } else { if (pairLabelValues[j - 1][i] <= 0.0) { data[i][j] = ""; } else { NumberFormat formatter = new DecimalFormat("#0.000"); data[i][j] = formatter.format(pairLabelValues[j - 1][i]).replace(",", "."); } } } } } for (int i = 0; i < column.length; i++) { if (i == 0) { column[i] = "Labels"; } else { column[i] = (dataset.getLabelNames()[i - 1]); } } AbstractTableModel1 fixedModel = new AbstractTableModel1(data, column); AbstractTableModel2 model = new AbstractTableModel2(data, column); JTable temp, fixedTable_temp; JPanel jpanel_temp; if (type.equals("coocurrence")) { temp = jTableCoocurrences; jpanel_temp = panelCoOcurrenceValues; fixedTable_temp = fixedTableCoocurrences; } else { temp = jTableHeatmap; jpanel_temp = panelHeatmapValues; fixedTable_temp = fixedTableHeatmap; } fixedTable_temp.setModel(fixedModel); temp.setModel(model); JScrollPane scroll = new JScrollPane(temp); JViewport viewport = new JViewport(); viewport.setView(fixedTable_temp); viewport.setPreferredSize(fixedTable_temp.getPreferredSize()); scroll.setRowHeaderView(viewport); scroll.setBounds(20, 20, 780, 390); scroll.setCorner(JScrollPane.UPPER_LEFT_CORNER, fixedTable_temp.getTableHeader()); temp.setBorder(BorderFactory.createLineBorder(Color.black)); jpanel_temp.remove(0); jpanel_temp.add(scroll, BorderLayout.CENTER, 0); }