Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 始终在顶部窗口,即使在显示全屏flash视频时也保持在顶部_Java_Linux_Swing_User Interface_Ubuntu - Fatal编程技术网

Java 始终在顶部窗口,即使在显示全屏flash视频时也保持在顶部

Java 始终在顶部窗口,即使在显示全屏flash视频时也保持在顶部,java,linux,swing,user-interface,ubuntu,Java,Linux,Swing,User Interface,Ubuntu,我正在尝试为Ubuntu 12.04编写一个简单的字幕播放器应用程序,它即使在全屏播放flash视频时也能保持在最上面。此应用程序将类似于在Windows中运行良好的应用程序 我的问题是我如何做到这一点?我试着用Java编写一个代码片段(如下所列,我从中获得了它,并修改为包含setAlwaysOnTop()),它使JFrame保持在顶部,但在flash视频全屏显示时不会。我的代码: import java.awt.*; //Graphics2D, LinearGradientPaint, Poi

我正在尝试为Ubuntu 12.04编写一个简单的
字幕播放器应用程序
,它即使在全屏播放flash视频时也能保持在最上面。此应用程序将类似于在Windows中运行良好的应用程序

我的问题是我如何做到这一点?我试着用Java编写一个代码片段(如下所列,我从中获得了它,并修改为包含
setAlwaysOnTop()
),它使JFrame保持在顶部,但在flash视频全屏显示时不会。我的代码:

import java.awt.*; //Graphics2D, LinearGradientPaint, Point, Window, Window.Type;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;

/**
 * From JavaMagazine May/June 2012
 * @author josh
 */
public class ShapedAboutWindowDemo {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        //switch to the right thread
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                JFrame frame = new JFrame("About box");
                //turn of window decorations
                frame.setUndecorated(true);
                frame.setAlwaysOnTop(true);
                //turn off the background
                frame.setBackground(new Color(0,0,0,0));
                frame.setContentPane(new AboutComponent());
                frame.pack();
                //size the window
                frame.setSize(500, 200);
                frame.setVisible(true);
                //center on screen
                frame.setLocationRelativeTo(null);
            }
        }
        );
    }

    private static class AboutComponent extends JComponent {
        public void paintComponent(Graphics graphics) {
            Graphics2D g = (Graphics2D) graphics;

            //create a translucent gradient
            Color[] colors = new Color[]{
                           new Color(0,0,0,0)
                            ,new Color(0.3f,0.3f,0.3f,1f)
                            ,new Color(0.3f,0.3f,0.3f,1f)
                            ,new Color(0,0,0,0)};
            float[] stops = new float[]{0,0.2f,0.8f,1f};
            LinearGradientPaint paint = new LinearGradientPaint(
                                        new Point(0,0), new Point(500,0),
                                        stops,colors);
            //fill a rect then paint with text
            g.setPaint(paint);
            g.fillRect(0, 0, 500, 200);
            g.setPaint(Color.WHITE);
            g.drawString("My Killer App", 200, 100);
        }
    }
}

请告诉我这在Ubuntu/Linux中是否可行,如果可以,如何实现。如果不可能使用Java,我愿意切换到任何其他语言。

使用本机Java,我认为您不可能。您可能需要通过JNA/JNI直接访问操作系统。您面临的问题通常是当应用程序是全屏时,它通常具有对屏幕的独占控制