JAVA使用awt显示图片
作者:互联网
public static void main(String[] args) throws IOException { JFrame frame = new JFrame("demo"); JPanel panel = new JPanel(); JLabel label = new JLabel(); label.setIcon(new ImageIcon("D:\\Deeplearn\\data\\nv.jpg")); panel.add(label); //多图多label JLabel label1 = new JLabel(); label1.setIcon(new ImageIcon("D:\\Deeplearn\\data\\nv.jpg")); panel.add(label1); frame.add(panel); //自适应窗口? frame.pack(); //设置窗口可见,构造初始化是不可见的 frame.setVisible(true); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }
效果:
标签:JFrame,JAVA,frame,awt,label,new,JLabel,panel,图片 来源: https://www.cnblogs.com/davenzeng/p/15034935.html