Drawing a simple line graph in Java

Problems with your code and suggestions: Again you need to change the preferredSize of the component (here the Graph JPanel), not the size Don’t set the JFrame’s bounds. Call pack() on your JFrame after adding components to it and before calling setVisible(true) Your foreach loop won’t work since the size of your ArrayList is 0 … Read more

Using Graphics2D to overlay text on a BufferedImage and return a BufferedImage

The method drawString() uses x and y for the leftmost character’s baseline. Numbers typically have no descenders; if the same is true of text, a string drawn at position (0,0) will be rendered entirely outside the image. See this example. Addendum: You may be having trouble with an incompatible color model in your image. One … Read more

Problems with newline in Graphics2D.drawString

The drawString method does not handle new-lines. You’ll have to split the string on new-line characters yourself and draw the lines one by one with a proper vertical offset: void drawString(Graphics g, String text, int x, int y) { for (String line : text.split(“\n”)) g.drawString(line, x, y += g.getFontMetrics().getHeight()); } Here is a complete example … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)