【问题标题】:how to put Image on JPanel using Netbeans如何使用 Netbeans 将图像放在 JPanel 上
【发布时间】:2011-03-13 03:43:46
【问题描述】:

我如何使用 Netbeans 将图像放在 JPanel 上?

【问题讨论】:

    标签: java swing netbeans imageicon


    【解决方案1】:

    看看这个教程:Handling Images in a Java GUI Application

    同时你也可以编码:

    JPanel panel = new JPanel(); 
    ImageIcon icon = new ImageIcon("image.jpg"); 
    JLabel label = new JLabel(); 
    label.setIcon(icon); 
    panel.add(label); 
    

    【讨论】:

      【解决方案2】:

      您可以使用 ImageIcon 和 JLabel:

      ImageIcon icon = createImageIcon("image.gif", "sample image");
      
      // Label with text and icon
      JLabel label1 = new JLabel("Image and Text", icon, JLabel.CENTER);
      
      // Label with icon only
      JLabel label2 = new JLabel(icon);
      
      // Add to your JPanel
      panel.add(label1);
      panel.add(label2);
      

      【讨论】:

        【解决方案3】:

        1) 首先将图片粘贴到Application文件夹中 2) 给面板添加标签 3)右键标签->属性 4) 选择图标-> 更多选项 5)选择包和文件,然后单击确定 6)你完成了:)

        【讨论】:

          【解决方案4】:

          您必须设置一个 JLabel 并将您的图标属性设置为图片。 有关特定问题的更详细解决方案,请转到

          http://www.netbeanstutorials.com/p/handling-images.html

          甚至还有一个视频如何在您需要时进行操作。

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2015-06-18
            • 1970-01-01
            • 2014-05-07
            • 2014-01-20
            • 1970-01-01
            相关资源
            最近更新 更多