List of usage examples for javax.swing JViewport getWidth
@BeanProperty(bound = false) public int getWidth()
From source file:ireport_5_6_0.view.JRViewer.java
/** * *///ww w .j a va2 s . c o m public void gotoHyperlink(JRPrintHyperlink hyperlink) { switch (hyperlink.getHyperlinkTypeValue()) { case REFERENCE: { if (isOnlyHyperlinkListener()) { System.out.println("Hyperlink reference : " + hyperlink.getHyperlinkReference()); System.out.println("Implement your own JRHyperlinkListener to manage this type of event."); } break; } case LOCAL_ANCHOR: { if (hyperlink.getHyperlinkAnchor() != null) { Map<String, JRPrintAnchorIndex> anchorIndexes = jasperPrint.getAnchorIndexes(); JRPrintAnchorIndex anchorIndex = anchorIndexes.get(hyperlink.getHyperlinkAnchor()); if (anchorIndex.getPageIndex() != pageIndex) { setPageIndex(anchorIndex.getPageIndex()); refreshPage(); } Container container = pnlInScroll.getParent(); if (container instanceof JViewport) { JViewport viewport = (JViewport) container; int newX = (int) (anchorIndex.getElementAbsoluteX() * realZoom); int newY = (int) (anchorIndex.getElementAbsoluteY() * realZoom); int maxX = pnlInScroll.getWidth() - viewport.getWidth(); int maxY = pnlInScroll.getHeight() - viewport.getHeight(); if (newX < 0) { newX = 0; } if (newX > maxX) { newX = maxX; } if (newY < 0) { newY = 0; } if (newY > maxY) { newY = maxY; } viewport.setViewPosition(new Point(newX, newY)); } } break; } case LOCAL_PAGE: { int page = pageIndex + 1; if (hyperlink.getHyperlinkPage() != null) { page = hyperlink.getHyperlinkPage().intValue(); } if (page >= 1 && page <= jasperPrint.getPages().size() && page != pageIndex + 1) { setPageIndex(page - 1); refreshPage(); Container container = pnlInScroll.getParent(); if (container instanceof JViewport) { JViewport viewport = (JViewport) container; viewport.setViewPosition(new Point(0, 0)); } } break; } case REMOTE_ANCHOR: { if (isOnlyHyperlinkListener()) { System.out.println("Hyperlink reference : " + hyperlink.getHyperlinkReference()); System.out.println("Hyperlink anchor : " + hyperlink.getHyperlinkAnchor()); System.out.println("Implement your own JRHyperlinkListener to manage this type of event."); } break; } case REMOTE_PAGE: { if (isOnlyHyperlinkListener()) { System.out.println("Hyperlink reference : " + hyperlink.getHyperlinkReference()); System.out.println("Hyperlink page : " + hyperlink.getHyperlinkPage()); System.out.println("Implement your own JRHyperlinkListener to manage this type of event."); } break; } case CUSTOM: { if (isOnlyHyperlinkListener()) { System.out.println("Hyperlink of type " + hyperlink.getLinkType()); System.out.println("Implement your own JRHyperlinkListener to manage this type of event."); } break; } case NONE: default: { break; } } }
From source file:com.att.aro.diagnostics.GraphPanel.java
/** * Returns buffered image of current viewport in provided JScrollPane. * /* w w w . java2 s . c om*/ * @param pane * @return Graph image. */ private BufferedImage createImage(JScrollPane pane) { JViewport jVPort = pane.getViewport(); jVPort.getWidth(); int w = jVPort.getWidth(); int h = jVPort.getHeight(); BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); Graphics2D g = bi.createGraphics(); jVPort.paint(g); return bi; }
From source file:org.intermine.install.swing.source.SourcePropertiesPanel.java
/** * Indicates whether this panel resizes horizontally as the viewport resizes. * The panel will resize with the viewport until a minimum width is reached, * at which point the horizontal scroll bar will appear. * /*from w w w. j av a 2 s .c om*/ * @return <code>true</code> until the minimum size is reached, <code>false</code> * when under that size. * * @see Scrollable#getScrollableTracksViewportWidth */ @Override public boolean getScrollableTracksViewportWidth() { if (getParent() instanceof JViewport) { JViewport parent = (JViewport) getParent(); return parent.getWidth() >= getMinimumSize().width + MIN_SIZE_MARGIN; } return true; }
From source file:vista.promocion.DiagPromocion.java
private void configurarTabla(JTable tbl) { JViewport scroll = (JViewport) tbl.getParent(); int ancho = scroll.getWidth(); int anchoColumna = 0; TableColumnModel modeloColumna = tbl.getColumnModel(); TableColumn columnaTabla;/*w w w . jav a2s.c o m*/ for (int i = 0; i < tbl.getColumnCount(); i++) { columnaTabla = modeloColumna.getColumn(i); switch (i) { case 0: anchoColumna = (1 * ancho) / 100; break; case 1: anchoColumna = (20 * ancho) / 100; break; case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 11: case 12: anchoColumna = (5 * ancho) / 100; break; } columnaTabla.setPreferredWidth(anchoColumna); tbl.setColumnModel(modeloColumna); } tbl.getTableHeader().setFont(new java.awt.Font("Dialog", java.awt.Font.PLAIN, 10)); tbl.getTableHeader().setBackground(java.awt.Color.WHITE); tbl.getTableHeader().setForeground(Color.BLACK); //Si le queremos cambiar el tamao a la tablita tbl.setFont(new java.awt.Font("Dialog", java.awt.Font.PLAIN, 10)); }
From source file:vista.ventas.DiagOrdenesDeCompra.java
private void configurarTabla(JTable tbl) { JViewport scroll = (JViewport) tbl.getParent(); int ancho = scroll.getWidth(); int anchoColumna = 0; TableColumnModel modeloColumna = tbl.getColumnModel(); TableColumn columnaTabla;/* w w w . j av a 2s.c o m*/ for (int i = 0; i < tbl.getColumnCount(); i++) { columnaTabla = modeloColumna.getColumn(i); switch (i) { case 0: anchoColumna = (1 * ancho) / 100; break; case 1: anchoColumna = (20 * ancho) / 100; break; case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 11: case 12: anchoColumna = (5 * ancho) / 100; break; } columnaTabla.setPreferredWidth(anchoColumna); tbl.setColumnModel(modeloColumna); } tbl.getTableHeader().setFont(new java.awt.Font("Dialog", java.awt.Font.PLAIN, 10)); tbl.getTableHeader().setBackground(java.awt.Color.WHITE); tbl.getTableHeader().setForeground(Color.BLACK); tbl.getTableHeader().setFont(new java.awt.Font("Dialog", java.awt.Font.PLAIN, 18)); //Si le queremos cambiar el tamao a la tablita tbl.setFont(new java.awt.Font("Dialog", java.awt.Font.PLAIN, 18)); }
From source file:vista.ventas.DialogEntregas.java
private void configurarTabla(JTable tbl) { JViewport scroll = (JViewport) tbl.getParent(); int ancho = scroll.getWidth(); int anchoColumna = 0; TableColumnModel modeloColumna = tbl.getColumnModel(); TableColumn columnaTabla;// ww w . j a va2 s . c o m for (int i = 0; i < tbl.getColumnCount(); i++) { columnaTabla = modeloColumna.getColumn(i); switch (i) { case 0: anchoColumna = 1 / 100; break; case 1: anchoColumna = (20 * ancho) / 100; break; case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 11: case 12: anchoColumna = (5 * ancho) / 100; break; } columnaTabla.setPreferredWidth(anchoColumna); tbl.setColumnModel(modeloColumna); } tbl.getTableHeader().setBackground(java.awt.Color.WHITE); tbl.getTableHeader().setForeground(Color.BLACK); tbl.getTableHeader().setFont(new java.awt.Font("Dialog", java.awt.Font.PLAIN, 14)); //Si le queremos cambiar el tamao a la tablita tbl.setFont(new java.awt.Font("Dialog", java.awt.Font.PLAIN, 14)); }