当前位置:首页 » 编程语言 » java标题栏

java标题栏

发布时间: 2022-07-17 15:34:47

java中窗体的标题栏如何设为透明

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowFocusListener;

import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.UIManager;

import com.birosoft.liquid.LiquidLookAndFeel;

public class TestEvent extends JComponent
implements ComponentListener,WindowFocusListener {

private JFrame frame;

private boolean start = false;

private Image background;

private Point p;

// 获得当前屏幕快照
public void updateBackground() {
try {
Robot rbt = new Robot();
Toolkit tk = Toolkit.getDefaultToolkit();
Dimension dim = tk.getScreenSize();
background = rbt.createScreenCapture(new Rectangle(0, 0, (int) dim
.getWidth(), (int) dim.getHeight()));
} catch (Exception ex) {
// p(ex.toString());
// 此方法没有申明过 ,因为无法得知上下文 。因为不影响执行效果 ,先注释掉它 ex.printStackTrace();
}

}

// 将窗口掉离出屏幕以获得纯粹的背景图象
public void refresh() {
if (start == true) {
this.updateBackground();
frame.setLocation(p);
if (p.x < 0 || p.y < 0)
frame.setLocation(0, 0);
this.repaint();
}
}

public void componentHidden(ComponentEvent e) {
System.out.println("Hidden");
}

// 窗口移动时
public void componentMoved(ComponentEvent e) {
System.out.println("moved");
this.repaint();
}

// 窗口改变大小时
public void componentResized(ComponentEvent e) {
System.out.println("resized");
this.repaint();
}

public void componentShown(ComponentEvent e) {
System.out.println("shown");
}

// 窗口得到焦点后,用refresh()方法更新界面
public void windowGainedFocus(WindowEvent e) {
System.out.println("gainedFocus");
refresh();
start = false;
}

// 窗口失去焦点后,将其移出屏幕
public void windowLostFocus(WindowEvent e) {
System.out.println("lostFocus");
if (frame.isShowing() == true) {
System.out.println("visible");
} else {
System.out.println("invisible");
}
start = true;
p = frame.getLocation();
frame.setLocation(-2000, -2000);
}

public TestEvent(JFrame frame) {
super();
this.frame = frame;
updateBackground();
this.setSize(200, 120);
this.setVisible(true);
frame.addComponentListener(this);
frame.addWindowFocusListener(this);

}

// 绘制外观,注意,其中 pos,offset 是为了将特定部分的图象贴到窗口上
public void paintComponent(Graphics g) {
Point pos = this.getLocationOnScreen();
Point offset = new Point(-pos.x, -pos.y);
g.drawImage(background, offset.x, offset.y, null);
}

/**
* @param args
*/
public static void main(String[] args) {
try {
// UIManager.setLookAndFeel("org.fife.plaf.Office2003.Office2003LookAndFeel");
// UIManager.setLookAndFeel("org.fife.plaf.OfficeXP.OfficeXPLookAndFeel");
// UIManager.setLookAndFeel("org.fife.plaf.OfficeXP.OfficeXPLookAndFeel");
UIManager.setLookAndFeel("com.birosoft.liquid.LiquidLookAndFeel");
LiquidLookAndFeel.setLiquidDecorations(true);
// LiquidLookAndFeel.setLiquidDecorations(true, "mac");
// UIManager.setLookAndFeel(new SubstanceLookAndFeel());
// UIManager.setLookAndFeel(new SmoothLookAndFeel());
// UIManager.setLookAndFeel(new QuaquaLookAndFeel());
// UIManager.put("swing.boldMetal", false);
if (System.getProperty("substancelaf.useDecorations") == null) {
JFrame.(true);
// JDialog.(true);
}
System.setProperty("sun.awt.noerasebackground", "true");
// SubstanceLookAndFeel.setCurrentTheme(new
// SubstanceLightAquaTheme());

// UIManager.setLookAndFeel("org.fife.plaf.VisualStudio2005.VisualStudio2005LookAndFeel");
} catch (Exception e) {
System.err.println("Oops! Something went wrong!");
}

JFrame frame = new JFrame("Transparent Window");
TestEvent t = new TestEvent(frame);
t.setLayout(new BorderLayout());
JButton button = new JButton("This is a button");
t.add("North", button);
JLabel label = new JLabel("This is a label");
t.add("South", label);
frame.getContentPane().add("Center", t);
frame.pack();
frame.setSize(150, 100);
frame.show();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// t.start=true;
}

}

㈡ Java 怎样获取标题栏的高度

自己已找到方法(没办法,没人回,只能靠自己。。):

用java.lang.Container的getInsets()方法可以获得标题栏的宽度和高度,Insets对象是容器边界的表示形式,有top,left,right,bottom四个属性可用。

An Insets object is a representation of the borders of a container. It specifies the space that a container must leave at each of its edges. The space can be a border, a blank space, or a title.

㈢ java如何获取窗体标题栏的颜色

类 java.awt.SystemColor
SystemColor.activeCaption
SystemColor.inactiveCaption

㈣ 怎样隐藏窗口标题栏(java)

楼主你好

可以用JFrame(或者Frame)类对象的setUndecorated方法来实现

public void setUndecorated(boolean undecorated)
禁用或启用此组件的装饰.

当参数设为true时 就隐藏了窗口标题栏

给lz一个例子:

import javax.swing.*;
public class Test extends JFrame
{
public Test()
{
this.setUndecorated(true);//隐藏标题栏
this.setSize(300,300);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

public static void main (String[] args) {
new Test();
}
}

希望能帮助你哈

㈤ java让标题栏显示信息

你说的是网页的标题栏吗?在<title>标签里写就可以了:

<html>
<title>这是我的班级</title>

<body>
</body>
</html>

㈥ Java中如何更换窗口标题栏字体(如何通过软件代码修改)

复制以下代码,修改相应地方即可:

privatestaticvoidloadIndyFont()
{
UIManager.put("CheckBox.font",newjava.awt.Font("宋体",0,12));
UIManager.put("Tree.font",newjava.awt.Font("宋体",0,12));
UIManager.put("Viewport.font",newjava.awt.Font("宋体",0,12));
UIManager.put("ProgressBar.font",newjava.awt.Font("宋体",0,12));
UIManager.put("RadioButtonMenuItem.font",newjava.awt.Font("宋体",0,12));
UIManager.put("FormattedTextField.font",newjava.awt.Font("宋体",0,12));
UIManager.put("ToolBar.font",newjava.awt.Font("宋体",0,12));
UIManager.put("ColorChooser.font",newjava.awt.Font("宋体",0,12));
UIManager.put("ToggleButton.font",newjava.awt.Font("宋体",0,12));
UIManager.put("Panel.font",newjava.awt.Font("宋体",0,12));
UIManager.put("TextArea.font",newjava.awt.Font("宋体",0,12));
UIManager.put("Menu.font",newjava.awt.Font("宋体",0,12));
UIManager.put("RadioButtonMenuItem.acceleratorFont",newjava.awt.Font("宋体",0,12));
UIManager.put("Spinner.font",newjava.awt.Font("宋体",0,12));
UIManager.put("Menu.acceleratorFont",newjava.awt.Font("宋体",0,12));
UIManager.put("CheckBoxMenuItem.acceleratorFont",newjava.awt.Font("宋体",0,12));
UIManager.put("TableHeader.font",newjava.awt.Font("宋体",0,12));
UIManager.put("TextField.font",newjava.awt.Font("宋体",0,12));
UIManager.put("OptionPane.font",newjava.awt.Font("宋体",0,12));
UIManager.put("MenuBar.font",newjava.awt.Font("宋体",0,12));
UIManager.put("Button.font",newjava.awt.Font("宋体",0,12));
UIManager.put("Label.font",newjava.awt.Font("宋体",0,12));
UIManager.put("PasswordField.font",newjava.awt.Font("宋体",0,12));
UIManager.put("InternalFrame.titleFont",newjava.awt.Font("宋体",0,12));
UIManager.put("OptionPane.buttonFont",newjava.awt.Font("宋体",0,12));
UIManager.put("ScrollPane.font",newjava.awt.Font("宋体",0,12));
UIManager.put("MenuItem.font",newjava.awt.Font("宋体",0,12));
UIManager.put("ToolTip.font",newjava.awt.Font("宋体",0,12));
UIManager.put("List.font",newjava.awt.Font("宋体",0,12));
UIManager.put("OptionPane.messageFont",newjava.awt.Font("宋体",0,12));
UIManager.put("EditorPane.font",newjava.awt.Font("宋体",0,12));
UIManager.put("Table.font",newjava.awt.Font("宋体",0,12));
UIManager.put("TabbedPane.font",newjava.awt.Font("宋体",0,12));
UIManager.put("RadioButton.font",newjava.awt.Font("宋体",0,12));
UIManager.put("CheckBoxMenuItem.font",newjava.awt.Font("宋体",0,12));
UIManager.put("TextPane.font",newjava.awt.Font("宋体",0,12));
UIManager.put("PopupMenu.font",newjava.awt.Font("宋体",0,12));
UIManager.put("TitledBorder.font",newjava.awt.Font("宋体",0,12));
UIManager.put("ComboBox.font",newjava.awt.Font("宋体",0,12));

}

㈦ java中设置标签标题的方法是

在Java代码设置Activity标题 2019-10-06 15:49:37 在对应的xxxActivity.java这种调用setTitle("Title")方法 自定义Java窗口标题栏菜单 千次阅读2021-03-09 03:4...

热点内容
鸟哥linux私房菜服务器 发布:2024-11-01 08:26:19 浏览:942
tomcat在linux下配置 发布:2024-11-01 08:09:57 浏览:94
工行密码器怎么买东西 发布:2024-11-01 08:00:02 浏览:711
查找子串的算法 发布:2024-11-01 07:58:25 浏览:214
最快学编程 发布:2024-11-01 07:30:56 浏览:527
买福克斯买哪个配置好 发布:2024-11-01 07:01:07 浏览:36
pip更新python库 发布:2024-11-01 06:42:57 浏览:666
忆捷加密软件 发布:2024-11-01 06:34:05 浏览:353
androidlistview事件冲突 发布:2024-11-01 06:23:14 浏览:858
哈灵麻将在安卓上叫什么名字 发布:2024-11-01 06:01:47 浏览:220