java Programming Glossary: getwidth
Show an animated BG in Swing http://stackoverflow.com/questions/10836832/show-an-animated-bg-in-swing g super.paintComponent g g.drawImage this.image 0 0 getWidth getHeight this public static void main String args throws MalformedURLException..
Java: maintaining aspect ratio of JPanel background image http://stackoverflow.com/questions/11959758/java-maintaining-aspect-ratio-of-jpanel-background-image image super.paintComponent g g.drawImage img 0 0 getWidth getHeight this g.drawImage img 0 0 this EDIT I should mention.. double factor getScaledFactorToFit new Dimension image.getWidth image.getHeight getSize int scaledWidth image.getWidth scale.. image.getHeight getSize int scaledWidth image.getWidth scale int scaledHeight image.getWidth scale This will automatically..
Java Bouncing Ball http://stackoverflow.com/questions/13022754/java-bouncing-ball move repaint public void move if x vx 0 x diameter vx getWidth vx 1 if y vy 0 y diameter vy getHeight vy 1 x vx y vy private.. void run int x int Math.round Math.random getParent .getWidth int y int Math.round Math.random getParent .getHeight setLocation.. int x getX int y getY if x vx 0 x diameter vx getParent .getWidth vx 1 if y vy 0 y diameter vy getParent .getHeight vy 1 x..
Threads with Key Bindings http://stackoverflow.com/questions/13999506/threads-with-key-bindings 500l Entity ballEntity new Entity gp.getWidth 2 gp.getHeight 2 ballEntityImages ballEntityTimings ballEntity.RIGHT.. entityTimings.add 500l Entity player2Entity new Entity gp.getWidth 10 200 entityImages entityTimings gp.addEntity player1Entity.. Color.WHITE break if circular g2.fillRect 0 0 img.getWidth img.getHeight else g2.fillOval 0 0 img.getWidth img.getHeight..
JFormattedTextField is not properly cleared http://stackoverflow.com/questions/4148336/jformattedtextfield-is-not-properly-cleared protected void paintComponent Graphics g int w this.getWidth int h this.getHeight g.setColor this.getBackground int dx1 w.. void actionPerformed ActionEvent e popup.show JDigit.this getWidth width getHeight 2 private class SelectAction extends AbstractAction..
Passing current Date http://stackoverflow.com/questions/8614972/passing-current-date c JComponent con x 0 y 0 w con.getWidth h con.getHeight con con.getParent super.addDirtyRegion.. @Override public void paint Graphics g if img null img.getWidth getWidth img.getHeight getHeight img new BufferedImage getWidth.. public void paint Graphics g if img null img.getWidth getWidth img.getHeight getHeight img new BufferedImage getWidth getHeight..
rotating coordinate plane for data and text in Java http://stackoverflow.com/questions/9371961/rotating-coordinate-plane-for-data-and-text-in-java DataPanel myPP new DataPanel myDiffs this.getHeight this.getWidth this.add myPP this.setVisible true Display the panel. public.. environment and about text int height getHeight int width getWidth ins getInsets Graphics2D g2d Graphics2D g FontMetrics fontMetrics..
Something seems wrong with the layout, JButton showing unexpected behaviour at resize of the window http://stackoverflow.com/questions/9849950/something-seems-wrong-with-the-layout-jbutton-showing-unexpected-behaviour-at-r int getX if x 0 positiveX true else if x drawingArea.getWidth diameter positiveX false return calculateX private int calculateX.. Graphics g g.setColor backgroundColor g.fillRect 0 0 getWidth getHeight g.setColor foregroundColor g.fillOval x y ballDiameter.. int getX if x 0 positiveX true else if x drawingArea.getWidth diameter positiveX false return calculateX private int calculateX..
|