I am trying to write an application in which I want to add different drawings to Jpanel. Everything works fine except for the JPG format, which displays images with very poor quality. This is how I draw the picture:
class draw extends Canvas { Dimension canvasSize = new Dimension(400, 400); String fileName; public void paint(Graphics g) { if(this.fileName!=null) { Toolkit toolkit = Toolkit.getDefaultToolkit(); Image img = toolkit.getImage(fileName); g.drawImage(img, 0, 0, this); } } public void setFileName(String name) { this.fileName=name; } public Dimension getMinimumSize() { return canvasSize; } public Dimension getPreferredSize() { return canvasSize; } }
Is there a way that JPG format is covered?
, , ( ) . JPEG , . , , ( ) . JPEG Image . Sun , .
, OP . , :
a) , JPanel, - Canvas. Swing. , , paintComponent() NOT .
b) , . . , . , Swing , , , AWT Canvas.
c) , super.paint(), super.paintComponent() .
d) , , ( ). ImageIcon JLabel. .
Swing . , , , , , .
Source: https://habr.com/ru/post/1731670/More articles:Should I test the UDP server code, and if so, why and how? - c #ASP.NET user control link button not working - event-handlinghttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1731667/required-registry-location-common-to-all-users-to-avoid-registry-virtualisation-in-vista&usg=ALkJrhgnRCf-h7nQZ0uxuR3Hq2cErWK13ACan I remove OpenGL vertex arrays after calling glDrawArrays? - c ++События jQuery MouseEnter и MouseOut с .toggle() обратными, когда мышь уже находится над элементом onLoad? - jqueryDynamically updating an html table using JSON using jQuery for a complex object - jsonIs it right that part of the business logic remains in the controller? - designRegex соответствует первому файлу в файле архивного файла rar. - c#Regular expression to match only the first file in a set of RAR files - ruby | fooobar.comRegex matches the first file in rar archive file installed in Python - pythonAll Articles