JFrame标题栏颜色可不可以改? 如题~~谢谢大家 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 frame.setUndecorated(true);自己绘制标题栏,并实现鼠标拖动功能 [在标题栏区域内]。 上面的那个代码是显示标题栏,那如何绘制标题栏?请稍微具体一点~~谢谢nj_dobetter import javax.swing.*;import java.awt.*;import java.awt.event.*;import javax.swing.event.MouseInputListener;public class MyFrame extends JFrame implements MouseInputListener { private java.awt.Point oldP; private static final int BAR_HEIGHT = 35; public MyFrame() { this.addMouseListener(this); this.addMouseMotionListener(this); this.setUndecorated(true); this.setSize(600, 500); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(EXIT_ON_CLOSE); this.setVisible(true); } public static void main(String[] args) { MyFrame mainframe = new MyFrame(); } public void mouseMoved(MouseEvent mouseevent) { } public void mouseReleased(MouseEvent e) { } public void mouseEntered(MouseEvent mouseevent) { } public void mouseExited(MouseEvent mouseevent) { } public void mouseClicked(MouseEvent mouseevent) { } public void mousePressed(MouseEvent e) { if (e.getY() > BAR_HEIGHT) { oldP = null; return; } oldP = e.getPoint(); } public void mouseDragged(MouseEvent e) { if (oldP == null) { return; } java.awt.Point newP = e.getPoint(); int x = getX() + (newP.x - oldP.x); int y = getY() + (newP.y - oldP.y); if (x >= MainFrame.Width - 85 || y >= MainFrame.Height - 45) { return; } setLocation(x, y); } public void paint(Graphics g) { super.paint(g); g.setColor(Color.pink); g.fillRect(0, 0, getWidth(), BAR_HEIGHT); }} http://java.ccidnet.com/art/3737/20060309/457211_1.html 获得屏幕物理尺寸,不是分辨率 对一个 J2EE 软件项目的代码进行打印,有什么工具可以推荐? java简体中文的问题 Socket 总是收不到回应??? 请大家帮忙 请问基本类型在声明时是否在内存中分配存储空间? 一个关于HashMap的问题,不明白结果 用jdbc odbc桥连接access数据库的初级问题 在线等!!!!! java在linux下调用c,可行吗?(高分求救,分不够再加) 中秋送分了 java.util.NoSuchElementException: Vector Enumeration 求大神帮忙,在线急等 窗口关闭问题 紧急救援!!相同的算法不同的结果
自己绘制标题栏,并实现鼠标拖动功能 [在标题栏区域内]。
import java.awt.*;
import java.awt.event.*;
import javax.swing.event.MouseInputListener;public class MyFrame extends JFrame implements MouseInputListener {
private java.awt.Point oldP;
private static final int BAR_HEIGHT = 35;
public MyFrame() {
this.addMouseListener(this);
this.addMouseMotionListener(this);
this.setUndecorated(true);
this.setSize(600, 500);
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setVisible(true);
} public static void main(String[] args) {
MyFrame mainframe = new MyFrame();
} public void mouseMoved(MouseEvent mouseevent) {
} public void mouseReleased(MouseEvent e) {
} public void mouseEntered(MouseEvent mouseevent) {
} public void mouseExited(MouseEvent mouseevent) {
} public void mouseClicked(MouseEvent mouseevent) {
} public void mousePressed(MouseEvent e) {
if (e.getY() > BAR_HEIGHT) {
oldP = null;
return;
}
oldP = e.getPoint();
} public void mouseDragged(MouseEvent e) {
if (oldP == null) {
return;
}
java.awt.Point newP = e.getPoint();
int x = getX() + (newP.x - oldP.x);
int y = getY() + (newP.y - oldP.y);
if (x >= MainFrame.Width - 85 || y >= MainFrame.Height - 45) {
return;
}
setLocation(x, y);
} public void paint(Graphics g) {
super.paint(g);
g.setColor(Color.pink);
g.fillRect(0, 0, getWidth(), BAR_HEIGHT);
}}