List of usage examples for javax.swing JScrollPane getSize
public Dimension getSize()
From source file:velocitekProStartAnalyzer.MainWindow.java
private void saveTableAsPng(JScrollPane panel) { btnSaveTableAsPng.addActionListener(new ActionListener() { @Override/*w ww.j a va 2 s . co m*/ public void actionPerformed(ActionEvent e) { fileChooser.setDialogTitle("Specify a file to save"); int userSelection = fileChooser.showSaveDialog(frame); BufferedImage bufImage = new BufferedImage(panel.getSize().width, panel.getSize().height, BufferedImage.TYPE_INT_RGB); panel.paint(bufImage.createGraphics()); if (userSelection == JFileChooser.APPROVE_OPTION) { File fileToSave = new File(fileChooser.getSelectedFile() + ".png"); System.out.println("Save as file: " + fileToSave.getAbsolutePath()); try { fileToSave.createNewFile(); ImageIO.write(bufImage, "png", fileToSave); statusLabel.setText("Table Screenshot Saved as: " + fileToSave.getName()); } catch (Exception ex) { statusLabel.setText("There was an error during saving"); } } } }); btnSaveTableAsPngForChart.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { fileChooser.setDialogTitle("Specify a file to save"); int userSelection = fileChooser.showSaveDialog(frame); BufferedImage bufImage = new BufferedImage(panel.getSize().width, panel.getSize().height, BufferedImage.TYPE_INT_RGB); panel.paint(bufImage.createGraphics()); if (userSelection == JFileChooser.APPROVE_OPTION) { File fileToSave = new File(fileChooser.getSelectedFile() + ".png"); System.out.println("Save as file: " + fileToSave.getAbsolutePath()); try { fileToSave.createNewFile(); ImageIO.write(bufImage, "png", fileToSave); statusLabel.setText("Table Screenshot Saved as: " + fileToSave.getName()); } catch (Exception ex) { statusLabel.setText("There was an error during saving"); } } } }); }
From source file:op.care.nursingprocess.DlgNursingProcess.java
private void jspPlanungComponentResized(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_jspPlanungComponentResized JScrollPane jsp = (JScrollPane) evt.getComponent(); if (tblPlanung.getRowCount() <= 0) { return;// w ww . j ava 2s . c o m } Dimension dim = jsp.getSize(); int textWidth = dim.width - 25; TableColumnModel tcm1 = tblPlanung.getColumnModel(); tcm1.getColumn(0).setPreferredWidth(textWidth); tcm1.getColumn(0).setHeaderValue(SYSTools.xx("nursingrecords.nursingprocess.interventions")); }
From source file:op.care.sysfiles.PnlFiles.java
private void jspFilesComponentResized(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_jspFilesComponentResized JScrollPane jsp = (JScrollPane) evt.getComponent(); Dimension dim = jsp.getSize(); // Gre der Text Spalte im TB ndern. // Summe der fixen Spalten = 210 + ein bisschen int textWidth = dim.width - 250; tblFiles.getColumnModel().getColumn(0).setPreferredWidth(170); tblFiles.getColumnModel().getColumn(1).setPreferredWidth(80); tblFiles.getColumnModel().getColumn(2).setPreferredWidth(textWidth / 3 * 2); tblFiles.getColumnModel().getColumn(3).setPreferredWidth(textWidth / 3); // tblFiles.getColumnModel().getColumn(2).setPreferredWidth(100); // SYSTools.packTable(tblFiles, 0); }