【问题标题】:JInternalFrame adding an icon to the title barJInternalFrame 向标题栏添加图标
【发布时间】:2011-10-21 06:38:50
【问题描述】:

我想添加一个ImageIcon 或类似JInternalFrame 的标题栏,这样[x] 图标位于最东端,可图标图标位于最东端第二位,自定义图标位于第三位最东端。这可行吗?

【问题讨论】:

  • 没有简单的方法可以做到这一点。这是 LAF 的责任。
  • @camickr 是正确的,但如果您想以其他方式使用它们,图标是there

标签: java swing icons jinternalframe


【解决方案1】:
JInternalFrame jInternalFrame1 = new JInternalFrame("Test Internal Frame",false,false,false,false);

try {
  URL url = new URL("images/icon.gif");
  ImageIcon icon = new ImageIcon(url);
  jInternalFrame1.setFrameIcon(icon);
} 
catch (MalformedURLException ex) 
{
   //whatever you want to put here
}

【讨论】:

  • 这会改变默认的左上角图标,而不是添加一个额外的?是吗?
【解决方案2】:

这对我有用:

ImageIcon icon = new ImageIcon(ClassLoader.getSystemResource("Iconos/icono.png"));
this.setFrameIcon(icon);

【讨论】:

    【解决方案3】:

    获取父框架: // parent 是容器 jDesktopPane -> parent = new JFrame ()

    this.setFrameIcon(new javax.swing.ImageIcon(this.parent.getIconImage()));
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-09-03
      • 1970-01-01
      • 1970-01-01
      • 2012-08-27
      • 2020-10-10
      • 1970-01-01
      • 2014-06-12
      • 1970-01-01
      相关资源
      最近更新 更多