java中怎样设置窗体无边框?包括关毕、最小化、最大化也不要?是调用那个方法?

Python010

java中怎样设置窗体无边框?包括关毕、最小化、最大化也不要?是调用那个方法?,第1张

下面是一个类用来完成你所要求的:

class TestFrame extends JFrame

{

public TestFrame()

{

setTitle("")//设置无标题

setResizable(true)//设置用户可以改变窗口大小

setVisible(true)//窗体可见

}

}

至于所说的无边框,在没有给窗体设置大小时,系统默认就是无边框的

希望我的回答能使你满意,如果满意 请给我最佳答案,谢谢

import javax.swing.JFramepublic class FrameTest {

public static void main(String[] args) {

JFrame jf=new JFrame("Test")

jf.setSize(300, 200)

jf.setUndecorated(true)

jf.setVisible(true)

}

}

import java.awt.event.MouseAdapter

import java.awt.event.MouseEvent

import java.awt.event.MouseMotionAdapter

import javax.swing.JFrame

public class test extends JFrame{

private int xx, yy

private boolean isDraging = false

public test(){

setUndecorated(true)// 没有标题栏

setSize(200, 200)

setVisible(true)

this.addMouseListener(new MouseAdapter() {

public void mousePressed(MouseEvent e) {

isDraging = true

xx = e.getX()

yy = e.getY()

}

public void mouseReleased(MouseEvent e) {

isDraging = false

}

})

this.addMouseMotionListener(new MouseMotionAdapter() {

public void mouseDragged(MouseEvent e) {

if (isDraging) {

int left = getLocation().x

int top = getLocation().y

setLocation(left + e.getX() - xx, top + e.getY() - yy)

}

}

})

}

public static void main(String[] args) {

test t =new test()

t.setDefaultCloseOperation(3)

}

}