JIDE的Framework程序导出可执行包运行有问题

发布于 2021-11-03 23:43:02 字数 5938 浏览 991 评论 1

我用JIDE写了一个Framework程序,程序在Eclipse中运行没问题,

但是导出可执行包运行时,程序拖动出现重影,getDockingManager().getWorkspace()这个workspace这块貌似透明的。。直接显示桌面了,且菜单栏出不来。。。

很奇怪。。什么原因。。。?

以下是我的代码:

package test;


import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.Icon;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.SwingUtilities;

import com.jidesoft.docking.DefaultDockableHolder;
import com.jidesoft.docking.DockContext;
import com.jidesoft.docking.DockableFrame;
import com.jidesoft.docking.DockingManager;
import com.jidesoft.icons.JideIconsFactory;
import com.jidesoft.plaf.LookAndFeelFactory;
import com.jidesoft.swing.JideMenu;
import com.jidesoft.swing.JideScrollPane;

public class TopoFramework extends DefaultDockableHolder {

 private static TopoFramework frame;
 private static WindowAdapter winListener;
 private static final String PROFILE_NAME = "ttt";

 public TopoFramework(String title) throws HeadlessException {
  super(title);
 }

 public static void main(String[] args) {
  SwingUtilities.invokeLater(new Runnable() {

   public void run() {
    // TODO Auto-generated method stub
    LookAndFeelFactory.installDefaultLookAndFeelAndExtension();
    LookAndFeelFactory.installJideExtension();
    showFramework();
   }

  });
  
 }

 public static void showFramework() {
  frame = new TopoFramework("拓扑管理");
  frame.setIconImage(JideIconsFactory.getImageIcon(JideIconsFactory.JIDE32).getImage());
  frame.getDockingManager().setProfileKey(PROFILE_NAME);
        frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); 
  
  winListener = new WindowAdapter() {
   public void windowClosing(WindowEvent e) {
     int flag = JOptionPane.showConfirmDialog(null, "确定要退出吗?", "退出", JOptionPane.YES_NO_OPTION);
                 if (flag == JOptionPane.YES_OPTION) {
//                  clearUp();
                  System.exit(0);
                 } else {
                  return;
                 }
   }
  };
  
  frame.addWindowListener(winListener);
  frame.getDockingManager().setOutlineMode(DockingManager.FULL_OUTLINE_MODE);
  frame.setJMenuBar(createMenuBar());
  
  
  
  frame.getDockingManager().beginLoadLayoutData();

  frame.getDockingManager().setInitSplitPriority(DockingManager.SPLIT_EAST_WEST_SOUTH_NORTH);

        // add all dockable frames
//  frame.getDockingManager().addFrame(mainTreeView);
  frame.getDockingManager().addFrame(createMainTreeFrame());
//  frame.getDockingManager().addFrame(alarmConsoleView);
  frame.getDockingManager().addFrame(createAlarmConsoleFrame());
  

        frame.getDockingManager().getWorkspace().setAcceptDockableFrame(true);
//        frame.getDockingManager().getWorkspace().setAdjustOpacityOnFly(true);

        frame.getDockingManager().loadLayoutData();
        frame.toFront();
//        return frame;
 }
 
 private static void clearUp() {
  frame.removeWindowListener(winListener);
  winListener = null;

        if (frame.getDockingManager() != null) {
         frame.getDockingManager().saveLayoutData();
        }

        frame.dispose();
        frame = null;
    }
 
 protected static JMenuBar createMenuBar() {
  JMenuBar menu = new JMenuBar();
  JMenu systemMenu = new JideMenu("系统");
  JMenuItem loginItem = new JMenuItem("登陆");
  systemMenu.add(loginItem);
  
  JMenu windowMenu = new JideMenu("窗口");
  JMenuItem resetLayoutItem = new JMenuItem("重置窗口布局");
  resetLayoutItem.addActionListener(new ActionListener() {

   public void actionPerformed(ActionEvent arg0) {
    frame.getDockingManager().resetToDefault();
    
   }
   
  });
  windowMenu.add(resetLayoutItem);
  
  menu.add(systemMenu);
  menu.add(windowMenu);
  
  return menu;
 }
 
 protected static DockableFrame createDockableFrame(String key, Icon icon) {
        DockableFrame frame = new DockableFrame(key, icon);
        frame.setPreferredSize(new Dimension(200, 200));
        return frame;
    }
 
 protected static DockableFrame createMainTreeFrame() {
  DockableFrame frame = createDockableFrame("拓扑", JideIconsFactory.getImageIcon(JideIconsFactory.DockableFrame.FRAME1));
  frame.setAvailableButtons(DockableFrame.BUTTON_AUTOHIDE);
  frame.getContext().setInitMode(DockContext.STATE_FRAMEDOCKED);
        frame.getContext().setInitSide(DockContext.DOCK_SIDE_WEST);
        frame.add(createScrollPane(new JTextArea()));
        return frame;
 }
 
 protected static DockableFrame createGraphFrame(String title) {
  DockableFrame frame = createDockableFrame(title, JideIconsFactory.getImageIcon(JideIconsFactory.DockableFrame.FRAME1));
        frame.getContext().setInitMode(DockContext.STATE_FRAMEDOCKED);
        frame.getContext().setInitSide(DockContext.DOCK_SIDE_CENTER);
        frame.add(createScrollPane(new JTextArea()));
        return frame;
 }
 
 protected static DockableFrame createAlarmConsoleFrame() {
  DockableFrame frame = createDockableFrame("告警控制台", JideIconsFactory.getImageIcon(JideIconsFactory.DockableFrame.FRAME1));
  frame.setAvailableButtons(DockableFrame.BUTTON_AUTOHIDE);
  frame.getContext().setInitMode(DockContext.STATE_FRAMEDOCKED);
        frame.getContext().setInitSide(DockContext.DOCK_SIDE_SOUTH);
        frame.add(createScrollPane(new JTextArea()));
        return frame;
 }
 
 private static JScrollPane createScrollPane(Component component) {
        JScrollPane pane = new JideScrollPane(component);
        pane.setVerticalScrollBarPolicy(JideScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
        return pane;
    }


 public static TopoFramework getFrame() {
  return frame;
 }

 public static void setFrame(TopoFramework frame) {
  TopoFramework.frame = frame;
 }
 
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

裸钻 2021-11-05 01:02:54

您的代码应该没有什么问题,我运行它也都是好的。会不会是您eclipse的java版本和外面的java版本不一样导致那些奇怪的情况?想在java里面实现整个窗口透明还真不是容易的事。

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文