culzonez Posted April 14, 2020 Share Posted April 14, 2020 How do I import an image into the code? I have no clue how to... If you just say import into Onpaint etc im not gonna understand Please if you can answer in code. I want to import just a black image ontop of the chatbox. Quote Link to comment Share on other sites More sharing options...
Naked Posted April 14, 2020 Share Posted April 14, 2020 private final String PAINT_URL = "https://i.imgur.com/something.png"; private BufferedImage PAINT_IMAGE = null; @Override public void onPaint(Graphics2D g) { g.drawImage(PAINT_IMAGE,0,337,null); } public void loadImage(){ try { URL url = new URL(PAINT_URL); PAINT_IMAGE = ImageIO.read(url); }catch(Exception e){} } Quote Link to comment Share on other sites More sharing options...
Chris Posted April 14, 2020 Share Posted April 14, 2020 google it Quote Link to comment Share on other sites More sharing options...
Medusa Posted April 14, 2020 Share Posted April 14, 2020 28 minutes ago, Naked said: private final String PAINT_URL = "https://i.imgur.com/something.png"; private BufferedImage PAINT_IMAGE = null; @Override public void onPaint(Graphics2D g) { g.drawImage(PAINT_IMAGE,0,337,null); } public void loadImage(){ try { URL url = new URL(PAINT_URL); PAINT_IMAGE = ImageIO.read(url); }catch(Exception e){} } y u spooning him Quote Link to comment Share on other sites More sharing options...
Naked Posted April 14, 2020 Share Posted April 14, 2020 7 minutes ago, Medusa said: y u spooning him Sometimes a man needs to spoon another man. 1 Quote Link to comment Share on other sites More sharing options...
Camaro Posted April 14, 2020 Share Posted April 14, 2020 You can do g.fillRect(int x, int y, int width, int height) if you just want to place a black rectangle, where x, y are the coordinates of the upper-left corner of the chatbox Quote Link to comment Share on other sites More sharing options...