L形java应用程序窗口

发布于 2024-08-09 01:52:58 字数 151 浏览 1 评论 0原文

我想创建一个“L”形状的java应用程序,以便该应用程序仅占据屏幕的左侧和底部边框。我也不希望顶部有正常的边框和标题栏。我见过其他人创建圆形和其他类似的形状,但没有复杂的形状。这是针对 Windows XP 计算机的,绝不会在任何其他操作系统上使用。

那么,我该怎么做呢?

I want to create a java application that is the shape of an "L" so that the application only occupies the left and bottom borders of the screen. I also do not want the normal borders and title bar at the top. I've seen other people creating circles and other shapes like that, but no complex shapes. This is for a windows xp computer and will never be on any other os.

So, how would I do this?

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

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

发布评论

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

评论(3

粉红×色少女 2024-08-16 01:52:58

java.awt.Window/javax.swing.JWindowjava.awt.Frame/javax.swing.JFrame > 使用 setUndecorated 将创建无框窗口。您可以将两个或多个组合在一起形成 L 形。

从6u10开始,Sun JRE还具有非标准API或非矩形和透明窗口。

java.awt.Window/javax.swing.JWindow and java.awt.Frame/javax.swing.JFrame with setUndecorated will create frameless windows. You could put two or more together to create an L-shape.

From 6u10, the Sun JRE also has a non-standard API or non-rectangular and transparent windows.

极度宠爱 2024-08-16 01:52:58

我认为这应该是可能的,尽管您可能必须小心布置组件。如果您查看此处,并阅读有关设置 a 的形状的部分窗口显示以下内容“形状可以是 java.awt.Shape 接口的任何实例”。如果您随后查看 Shape 接口,就会发现 java.awt.Polygon 实现了该接口。所以你应该能够实现一个带有“L”形状的多边形。试一试。

I think this should be possible, although you would probably have to be careful about laying out your components. If you look here, and read the Section on setting the shape of a window it says the following "The shape can be any instance of the java.awt.Shape interface". If you then look at the Shape interface, java.awt.Polygon implements that interface. So you should be able to implement a polygon w/ a "L" shape. Give it a shot.

原谅过去的我 2024-08-16 01:52:58

在这里,Asa,这正是您所需要的:

import com.sun.awt.AWTUtilities;
import java.awt.Polygon;
import java.awt.Shape;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import javax.swing.JFrame;

public static void main(String[] args)
{
    // create an undecorated frame
    final JFrame lframe = new JFrame();                
    lframe.setSize(1600, 1200);
    lframe.setUndecorated(true);

    // using component resize allows for precise control
    lframe.addComponentListener(new ComponentAdapter() {
        // polygon points non-inclusive
        // {0,0} {350,0} {350,960} {1600,960} {1600,1200} {0,1200}
        int[] xpoints = {0,350,350,1600,1600,0};
        int[] ypoints = {0,0,960,960,1200,1200};

        @Override
        public void componentResized(ComponentEvent evt)
        {  
            // create the polygon (L-Shape)
            Shape shape = new Polygon(xpoints, ypoints, xpoints.length);

            // set the window shape
            AWTUtilities.setWindowShape(lframe, shape);
        }
    });

    // voila!
    lframe.setVisible(true);
}

参考 -> “设置窗口的形状”

Here you go Asa, this is exactly what you need:

import com.sun.awt.AWTUtilities;
import java.awt.Polygon;
import java.awt.Shape;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import javax.swing.JFrame;

public static void main(String[] args)
{
    // create an undecorated frame
    final JFrame lframe = new JFrame();                
    lframe.setSize(1600, 1200);
    lframe.setUndecorated(true);

    // using component resize allows for precise control
    lframe.addComponentListener(new ComponentAdapter() {
        // polygon points non-inclusive
        // {0,0} {350,0} {350,960} {1600,960} {1600,1200} {0,1200}
        int[] xpoints = {0,350,350,1600,1600,0};
        int[] ypoints = {0,0,960,960,1200,1200};

        @Override
        public void componentResized(ComponentEvent evt)
        {  
            // create the polygon (L-Shape)
            Shape shape = new Polygon(xpoints, ypoints, xpoints.length);

            // set the window shape
            AWTUtilities.setWindowShape(lframe, shape);
        }
    });

    // voila!
    lframe.setVisible(true);
}

reference -> "Setting the Shape of a Window"

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