public BufferedImage createImage(JPanel panel) { int w = panel.getWidth(); int h = panel.getHeight(); BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); Graphics2D g = bi.createGraphics(); panel.paint(g); return bi; }
JScrollPane scroll = new JScrollPane(table); JPanel p = new JPanel(new BorderLayout()); p.add(scroll, BorderLayout.CENTER); JOptionPane.showMessageDialog(null, p); table.addNotify(); p.doLayout(); BufferedImage bi = new BufferedImage(p.getWidth() + 100, p.getHeight() + 100, BufferedImage.TYPE_INT_RGB); Graphics g = bi.createGraphics(); p.paint(g); g.dispose();
private void btnStateFinishedActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnStateFinishedActionPerformed if (this.btnStateFinished.isSelected()) { this.jSplitPaneTables.setDividerLocation(-1); } else { this.jSplitPaneTables.setDividerLocation(this.jPanelTables.getHeight()); } this.startTasks(); }//GEN-LAST:event_btnStateFinishedActionPerformed
JPanel dPanel; ... public void save() { BufferedImage bImg = new BufferedImage(dPanel.getWidth(), dPanel.getHeight(), BufferedImage.TYPE_INT_RGB); Graphics2D cg = bImg.createGraphics(); dPanel.paintAll(cg); try { if (ImageIO.write(bImg, "png", new File("./output_image.png"))) { System.out.println("-- saved"); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
Image image = ImageHelper.getImageFromResources(path); Rectangle r = new Rectangle(jPanel.getWidth() - 5, jPanel.getHeight() - 5); BufferedImage bufferedImage; if (!locked) {
int size = cardWidth > WIDTH_LIMIT ? 40 : 20; minusCounterLabel.setLocation(counterPanel.getWidth() - size, counterPanel.getHeight() - size * 2); minusCounterLabel.setSize(size, size); plusCounterLabel.setLocation(5, counterPanel.getHeight() - size * 2); plusCounterLabel.setSize(size, size); loyaltyCounterLabel.setLocation(counterPanel.getWidth() - size, counterPanel.getHeight() - size); loyaltyCounterLabel.setSize(size, size); otherCounterLabel.setLocation(5, counterPanel.getHeight() - size); otherCounterLabel.setSize(size, size);
@ScriptFunction(jsDoc = HEIGHT_JSDOC) @Override public int getHeight() { return super.getHeight(); }
@ScriptFunction(jsDoc = HEIGHT_JSDOC) @Override public int getHeight() { return super.getHeight(); }
@ScriptFunction(jsDoc = HEIGHT_JSDOC) @Override public int getHeight() { return super.getHeight(); }
@ScriptFunction(jsDoc = HEIGHT_JSDOC) @Override public int getHeight() { return super.getHeight(); }
private boolean check(MouseEvent e) { int y = getInnerTitlePanel().getY() - titleMargin; int max = getInnerTitlePanel().getY() + getInnerTitlePanel().getHeight() + titleMargin; if (e.getPoint().y > y && e.getPoint().y < max) { return true; } return false; }
protected Dimension getSketchDimensions() { int width = sketchPanel.getWidth(); int height = sketchPanel.getHeight(); if (width > 1 && height > 1) { if (isRetina()) { width = (int) (width * 2.0); height = (int) (height * 2.0); } return new Dimension(width, height); } return new Dimension(1, 1); }
public BufferedImage createBlurredImage(JPanel panel) { System.out.println("Blurring image"); int w = panel.getWidth(); int h = panel.getHeight(); BufferedImage sourceImage = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); Graphics2D g = sourceImage.createGraphics(); panel.paint(g); return createBlurredImage(sourceImage); }
@Override public void mousePressed(MouseEvent e) { Point p = e.getPoint(); double percent = p.y / ((double) panel.getHeight()); int range = slider.getMaximum() - slider.getMinimum(); double newVal = range * percent; int result = (int) (slider.getMaximum() - newVal); slider.setValue(result); } });
private void initButtonsPane() { final int padding = 24; // bottom padding for buttons final int buttonHeight = 36; buttonsPanel = new BackgroundPanel("welcome/welcome-screen-left-bg.jpg"); int openButtonY = buttonsPanel.getHeight() - padding - buttonHeight; // buttons layout from bottom int newButtonY = openButtonY - 10 - buttonHeight; // 10px - space between buttons initButton("open", openButtonY, OpenProjectAction.class); initButton("new", newButtonY, NewProjectAction.class); mainPanel.add(buttonsPanel); }
@Override public void mouseDragged(MouseEvent e) { JPanel source = (JPanel) e.getSource(); Point frameLocation = getLocation(); setSize(new Dimension(getWidth(), e.getLocationOnScreen().y - frameLocation.y + source.getHeight())); } }
public void componentResized(ComponentEvent event) { Insets insetsFrame = frame.getInsets(); windowWidth = frame.getWidth() - insetsFrame.left - insetsFrame.right - settingsPanel2.getWidth(); windowHeight = frame.getHeight() - insetsFrame.bottom - insetsFrame.top - settingsPanel1.getHeight(); if (windowHeight>0 && windowWidth > 0) resizeImagePanel(windowWidth, windowHeight); frame.pack(); } });
public void stateChanged(ChangeEvent e) { if( null != searchField && searchField.isVisible() ) { if( null != prevViewPosition ) repaint( 0, prevViewPosition.y, getWidth(), searchpanel.getHeight() ); assert getParent() instanceof JViewport; prevViewPosition = new Point( ((JViewport)getParent()).getViewPosition() ); } } };
private void show() { frame.getLayeredPane().add(backgroundPanel, JLayeredPane.PALETTE_LAYER); imagePanel.setLocation(((frame.getLayeredPane().getWidth() - imagePanel.getWidth()) / 2), (frame.getLayeredPane().getHeight() - imagePanel.getHeight()) / 2); frame.getLayeredPane().add(imagePanel, JLayeredPane.POPUP_LAYER); }