Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Initializes the scrollpane on which the spreadsheet is placed.
- * @return the scrollpane.
- */
- public JScrollPane getJScrollPane()
- {
- if (jScrollPane == null)
- {
- jScrollPane = new JScrollPane();
- jScrollPane.addComponentListener(new java.awt.event.
- ComponentAdapter()
- {
- public void componentResized(
- java.awt.event.ComponentEvent e)
- {
- repainttable();
- if (getSelectedColumnCount() == 0 &&
- getSelectedRowCount() == 0)
- {
- if ((getColumnCount() > 1) && (getRowCount() > 1))
- {
- setColumnSelectionInterval(0, 0);
- setRowSelectionInterval(0, 0);
- }
- }
- }
- });
- jScrollPane.getHorizontalScrollBar().addAdjustmentListener(
- new SSScrollAdjListener(this));
- jScrollPane.getVerticalScrollBar().addAdjustmentListener(new
- SSScrollAdjListener(this));
- jScrollPane.setRowHeaderView(getViewPort());
- jScrollPane.setCorner(ScrollPaneConstants.UPPER_LEFT_CORNER,
- getRowHeader().getTableHeader());
- jScrollPane.setViewportView(this);
- }
- return jScrollPane;
- }
- /**
- * Routine for AdjustmentListener of ScrollPane which is used for
- * supporting isCellVisible mode
- * @param isVerticalScrollbar VerticalScrollBar involved set true
- * or HorizontalScrollBar invloved set false
- */
- public void scrollpaneRoutine(boolean isVerticalScrollbar)
- {
- if (isCellVisible)
- {
- if (isVerticalScrollbar)
- {
- int dif = jScrollPane.getVerticalScrollBar().getMaximum() -
- jScrollPane.getVerticalScrollBar().getValue() -
- jScrollPane.getVerticalScrollBar().getHeight();
- if (dif == 0)
- {
- this.addRow();
- }
- else if (Vindex > jScrollPane.getVerticalScrollBar().getValue())
- {
- int i = rowAtPoint(SwingUtilities.convertPoint(jScrollPane,
- 100, jScrollPane.getHeight(), this));
- int lastrow = 0;
- int[] rows = getSelectedRows();
- lastrow = (rows.length > 0) ? rows[rows.length - 1] :
- lastrow;
- i = (i < lastrow) ? lastrow : i;
- if (i > 0)
- {
- while (getRowCount() > i + 1)
- {
- if (checkRowDataExist(getRowCount() - 1) == false)
- {
- model.removeRow(this, getRowCount() - 1);
- }
- else
- {
- break;
- }
- }
- }
- }
- }
- else
- {
- int dif = jScrollPane.getHorizontalScrollBar().getMaximum() -
- jScrollPane.getHorizontalScrollBar().getValue() -
- jScrollPane.getHorizontalScrollBar().getWidth();
- if (dif == 0)
- {
- int c[] = getSelectedColumns();
- int r[] = getSelectedRows();
- addColumn();
- addSelectionInterval(r, c);
- getTableHeader().repaint();
- }
- else if (Hindex >
- jScrollPane.getHorizontalScrollBar().getValue())
- {
- int i = columnAtPoint(SwingUtilities.convertPoint(
- jScrollPane,
- jScrollPane.getWidth(), 50, this));
- int lastcol = 0;
- int[] cols = getSelectedColumns();
- lastcol = (cols.length > 0) ? cols[cols.length - 1] :
- lastcol;
- i = (i < lastcol) ? lastcol : i;
- if (i > 0)
- {
- while (getColumnCount() > i + 1)
- {
- if (checkColumnDataExist(getColumnCount() - 1) ==
- false)
- {
- model.removeColumn(this, getColumnCount() - 1);
- }
- else
- {
- break;
- }
- }
- }
- }
- }
- Hindex = jScrollPane.getHorizontalScrollBar().getValue();
- Vindex = jScrollPane.getVerticalScrollBar().getValue();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement