private void setupDragMode(JComponent f) {
   JDesktopPane p = getDesktopPane(f);
   Container parent = f.getParent();
   dragMode = DEFAULT_DRAG_MODE;
   if (p != null) {
     String mode = (String) p.getClientProperty("JDesktopPane.dragMode");
     Window window = SwingUtilities.getWindowAncestor(f);
     if (window != null && !AWTUtilities.isWindowOpaque(window)) {
       dragMode = DEFAULT_DRAG_MODE;
     } else if (mode != null && mode.equals("outline")) {
       dragMode = OUTLINE_DRAG_MODE;
     } else if (mode != null
         && mode.equals("faster")
         && f instanceof JInternalFrame
         && ((JInternalFrame) f).isOpaque()
         && (parent == null || parent.isOpaque())) {
       dragMode = FASTER_DRAG_MODE;
     } else {
       if (p.getDragMode() == JDesktopPane.OUTLINE_DRAG_MODE) {
         dragMode = OUTLINE_DRAG_MODE;
       } else if (p.getDragMode() == JDesktopPane.LIVE_DRAG_MODE
           && f instanceof JInternalFrame
           && ((JInternalFrame) f).isOpaque()) {
         dragMode = FASTER_DRAG_MODE;
       } else {
         dragMode = DEFAULT_DRAG_MODE;
       }
     }
   }
 }
Exemplo n.º 2
0
  Timed() throws AWTException {
    // super("Trial by fire");
    setLayout(new FlowLayout());

    label.setFont(
        new Font(
            label.getFont().getName(), label.getFont().getStyle(), label.getFont().getSize() + 6));
    Container content = getContentPane();
    content.add(label, JLabel.CENTER);
    addMouseMotionListener(this);
    addMouseListener(this);

    javax.swing.Timer t = new javax.swing.Timer(1000, this);
    setUndecorated(true);
    com.sun.awt.AWTUtilities.setWindowOpacity(this, 0.6f);

    // system tray
    mItem1.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent e) {
            System.exit(0);
          }
        });

    popup.add(mItem1);
    systray.add(tray);
    tray.setImageAutoSize(true);
    t.start();
  }
Exemplo n.º 3
0
  /** Initializes the settings panel. */
  private void initSettingsPanel() {
    int startX = 30;
    int startY = 30;

    try {
      this.setLocation(startX, startY);
      this.dispose();
    } catch (Exception e) {
    }

    jpSettings = new SettingsPanel();
    MouseMoveListener mml = new MouseMoveListener(jpSettings);
    this.addMouseListener(mml);
    this.addMouseMotionListener(mml);

    this.setAlwaysOnTop(true);
    this.setUndecorated(true);

    try {
      if (!AWTUtilities.isTranslucencyCapable(this.getGraphicsConfiguration())) {
        log("Can not set transparency for settings form");
        this.setBackground(new Color(64, 64, 64, 255));
        this.jpSettings.setBackground(new Color(64, 64, 64, 255));
        this.jpSettings.setOpaque(true);
      } else {
        log("Transparency is set for settings form");
        AWTUtilities.setWindowOpaque(this, false);
      }
    } catch (Exception ex) {
      log(ex);
    }

    this.add(jpSettings);

    // Hack for handling draggable JFrames on Mac OSX
    this.getRootPane().putClientProperty("apple.awt.draggableWindowBackground", Boolean.FALSE);

    this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    this.setLocation(startX, startY);
    this.pack();
    this.setVisible(false);
  }
Exemplo n.º 4
0
 public static void main(String[] args) {
   JFrame frame = new JFrame("Clock by Volkman");
   frame.setContentPane(new Clock().getForm());
   frame.pack();
   Toolkit tk = Toolkit.getDefaultToolkit();
   Dimension dim = tk.getScreenSize();
   AWTUtilities.setWindowOpacity(frame, (float) 0.25);
   frame.setLocation((int) dim.getWidth() - 400, 20);
   frame.removeNotify();
   frame.setUndecorated(true);
   frame.setVisible(true);
   frame.setAlwaysOnTop(true);
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 }
Exemplo n.º 5
0
  protected void initGUI() {
    // set dialog full transparent
    setUndecorated(true);
    AWTUtilities.setWindowOpaque(this, false);
    this.getRootPane().setWindowDecorationStyle(JRootPane.NONE);

    // init gui
    JPanel contentPane = new JPanel();
    contentPane.setLayout(new BorderLayout(0, 0));
    contentPane.setOpaque(false);
    setContentPane(contentPane);

    // others setup
    this.setFocusable(false);
    this.setFocusableWindowState(false);
    //		this.setAlwaysOnTop(true);
    this.setVisible(false);
  }
Exemplo n.º 6
0
  public IMDialog(IMFrame owner) {
    super(owner);
    this.owner = owner;

    i18nService = IMContext.getBean(I18nService.class);
    skinService = IMContext.getBean(SkinService.class);
    resourceService = IMContext.getBean(ResourceService.class);
    eventService = IMContext.getBean(EventService.class);

    setDefaultCloseOperation(WebFrame.DISPOSE_ON_CLOSE);
    getRootPane().setDoubleBuffered(true);
    // 创建wrap,并设置为默认面板(该面板为窗口阴影面板)
    contentWrap = new IMFrameWrap();
    contentWrap.installSkin(getSkinService());
    super.setContentPane(contentWrap);

    // 去了默认边框
    setUndecorated(true);
    // 把窗口设置为透明
    AWTUtilities.setWindowOpaque(this, false);

    UIEventDispatcher uiEventDispatcher = new UIEventDispatcher(this);
    eventService.register(uiEventDispatcher.getEventTypes(), uiEventDispatcher);
  }
Exemplo n.º 7
0
 public void applyProperty(final CPlatformWindow c, final Object value) {
   AWTUtilities.setWindowOpacity(
       c.target, value == null ? 1.0f : Float.parseFloat(value.toString()));
 }
Exemplo n.º 8
0
  public TestPlayer(String[] args) {
    if (RuntimeUtil.isWindows()) {
      // If running on Windows and you want the mouse/keyboard event hack...
      videoSurface = new WindowsCanvas();
    } else {
      videoSurface = new Canvas();
    }

    Logger.debug("videoSurface={}", videoSurface);

    videoSurface.setBackground(Color.black);
    videoSurface.setSize(800, 600); // Only for initial layout

    // Since we're mixing lightweight Swing components and heavyweight AWT
    // components this is probably a good idea
    JPopupMenu.setDefaultLightWeightPopupEnabled(false);

    TestPlayerMouseListener mouseListener = new TestPlayerMouseListener();
    videoSurface.addMouseListener(mouseListener);
    videoSurface.addMouseMotionListener(mouseListener);
    videoSurface.addMouseWheelListener(mouseListener);
    videoSurface.addKeyListener(new TestPlayerKeyListener());

    List<String> vlcArgs = new ArrayList<String>();

    vlcArgs.add("--no-plugins-cache");
    vlcArgs.add("--no-video-title-show");
    vlcArgs.add("--no-snapshot-preview");
    vlcArgs.add("--quiet");
    vlcArgs.add("--quiet-synchro");
    vlcArgs.add("--intf");
    vlcArgs.add("dummy");

    // Special case to help out users on Windows (supposedly this is not actually needed)...
    // if(RuntimeUtil.isWindows()) {
    // vlcArgs.add("--plugin-path=" + WindowsRuntimeUtil.getVlcInstallDir() + "\\plugins");
    // }
    // else {
    // vlcArgs.add("--plugin-path=/home/linux/vlc/lib");
    // }

    // vlcArgs.add("--plugin-path=" + System.getProperty("user.home") + "/.vlcj");

    Logger.debug("vlcArgs={}", vlcArgs);

    mainFrame = new JFrame("VLCJ Test Player");
    mainFrame.setIconImage(
        new ImageIcon(getClass().getResource("/icons/vlcj-logo.png")).getImage());

    FullScreenStrategy fullScreenStrategy = new DefaultFullScreenStrategy(mainFrame);

    mediaPlayerFactory = new MediaPlayerFactory(vlcArgs.toArray(new String[vlcArgs.size()]));
    mediaPlayerFactory.setUserAgent("vlcj test player");

    List<AudioOutput> audioOutputs = mediaPlayerFactory.getAudioOutputs();
    Logger.debug("audioOutputs={}", audioOutputs);

    mediaPlayer = mediaPlayerFactory.newEmbeddedMediaPlayer(fullScreenStrategy);
    mediaPlayer.setVideoSurface(mediaPlayerFactory.newVideoSurface(videoSurface));
    mediaPlayer.setPlaySubItems(true);

    mediaPlayer.setEnableKeyInputHandling(false);
    mediaPlayer.setEnableMouseInputHandling(false);

    controlsPanel = new PlayerControlsPanel(mediaPlayer);
    videoAdjustPanel = new PlayerVideoAdjustPanel(mediaPlayer);

    mainFrame.setLayout(new BorderLayout());
    mainFrame.setBackground(Color.black);
    mainFrame.add(videoSurface, BorderLayout.CENTER);
    mainFrame.add(controlsPanel, BorderLayout.SOUTH);
    mainFrame.add(videoAdjustPanel, BorderLayout.EAST);
    mainFrame.setJMenuBar(buildMenuBar());
    mainFrame.pack();
    mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    mainFrame.addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(WindowEvent evt) {
            Logger.debug("windowClosing(evt={})", evt);

            if (videoSurface instanceof WindowsCanvas) {
              ((WindowsCanvas) videoSurface).release();
            }

            if (mediaPlayer != null) {
              mediaPlayer.release();
              mediaPlayer = null;
            }

            if (mediaPlayerFactory != null) {
              mediaPlayerFactory.release();
              mediaPlayerFactory = null;
            }
          }
        });

    // Global AWT key handler, you're better off using Swing's InputMap and
    // ActionMap with a JFrame - that would solve all sorts of focus issues too
    Toolkit.getDefaultToolkit()
        .addAWTEventListener(
            new AWTEventListener() {
              @Override
              public void eventDispatched(AWTEvent event) {
                if (event instanceof KeyEvent) {
                  KeyEvent keyEvent = (KeyEvent) event;
                  if (keyEvent.getID() == KeyEvent.KEY_PRESSED) {
                    if (keyEvent.getKeyCode() == KeyEvent.VK_F12) {
                      controlsPanel.setVisible(!controlsPanel.isVisible());
                      videoAdjustPanel.setVisible(!videoAdjustPanel.isVisible());
                      mainFrame.getJMenuBar().setVisible(!mainFrame.getJMenuBar().isVisible());
                      mainFrame.invalidate();
                      mainFrame.validate();
                    } else if (keyEvent.getKeyCode() == KeyEvent.VK_A) {
                      mediaPlayer.setAudioDelay(mediaPlayer.getAudioDelay() - 50000);
                    } else if (keyEvent.getKeyCode() == KeyEvent.VK_S) {
                      mediaPlayer.setAudioDelay(mediaPlayer.getAudioDelay() + 50000);
                    }
                    // else if(keyEvent.getKeyCode() == KeyEvent.VK_N) {
                    // mediaPlayer.nextFrame();
                    // }
                    else if (keyEvent.getKeyCode() == KeyEvent.VK_1) {
                      mediaPlayer.setTime(60000 * 1);
                    } else if (keyEvent.getKeyCode() == KeyEvent.VK_2) {
                      mediaPlayer.setTime(60000 * 2);
                    } else if (keyEvent.getKeyCode() == KeyEvent.VK_3) {
                      mediaPlayer.setTime(60000 * 3);
                    } else if (keyEvent.getKeyCode() == KeyEvent.VK_4) {
                      mediaPlayer.setTime(60000 * 4);
                    } else if (keyEvent.getKeyCode() == KeyEvent.VK_5) {
                      mediaPlayer.setTime(60000 * 5);
                    } else if (keyEvent.getKeyCode() == KeyEvent.VK_6) {
                      mediaPlayer.setTime(60000 * 6);
                    } else if (keyEvent.getKeyCode() == KeyEvent.VK_7) {
                      mediaPlayer.setTime(60000 * 7);
                    } else if (keyEvent.getKeyCode() == KeyEvent.VK_8) {
                      mediaPlayer.setTime(60000 * 8);
                    } else if (keyEvent.getKeyCode() == KeyEvent.VK_9) {
                      mediaPlayer.setTime(60000 * 9);
                    }
                  }
                }
              }
            },
            AWTEvent.KEY_EVENT_MASK);

    mainFrame.setVisible(true);

    mediaPlayer.addMediaPlayerEventListener(new TestPlayerMediaPlayerEventListener());

    // Won't work with OpenJDK or JDK1.7, requires a Sun/Oracle JVM (currently)
    boolean transparentWindowsSupport = true;
    try {
      Class.forName("com.sun.awt.AWTUtilities");
    } catch (Exception e) {
      transparentWindowsSupport = false;
    }

    Logger.debug("transparentWindowsSupport={}", transparentWindowsSupport);

    if (transparentWindowsSupport) {
      final Window test =
          new Window(null, WindowUtils.getAlphaCompatibleGraphicsConfiguration()) {
            private static final long serialVersionUID = 1L;

            @Override
            public void paint(Graphics g) {
              Graphics2D g2 = (Graphics2D) g;

              g2.setRenderingHint(
                  RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
              g2.setRenderingHint(
                  RenderingHints.KEY_TEXT_ANTIALIASING,
                  RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);

              g.setColor(Color.white);
              g.fillRoundRect(100, 150, 100, 100, 32, 32);

              g.setFont(new Font("Sans", Font.BOLD, 32));
              g.drawString("Heavyweight overlay test", 100, 300);
            }
          };

      AWTUtilities.setWindowOpaque(test, false); // Doesn't work in full-screen exclusive
      // mode, you would have to use 'simulated'
      // full-screen - requires Sun/Oracle JDK
      test.setBackground(new Color(0, 0, 0, 0)); // This is what you do in JDK7

      // mediaPlayer.setOverlay(test);
      // mediaPlayer.enableOverlay(true);
    }

    // This might be useful
    // enableMousePointer(false);
  }
Exemplo n.º 9
0
 /** Creates new form MainForm */
 public MainForm() {
   initComponents();
   setLocationRelativeTo(null);
   AWTUtilities.setWindowOpaque(this, false);
 }