- 浏览: 220049 次
- 性别:
- 来自: 西安
文章分类
最新评论
-
xiaoxiaowuxian1:
终于找到了,感谢~
大话设计模式(带目录完整版)PDF -
jiaoronggui:
一键安装,很方便
BitNami Redmine Stack -
s21109:
不错 很详细
java文件复制 -
ryanflyer:
白下了半天,无法使用
大话设计模式(带目录完整版)PDF -
xbgd:
sunwang810812 写道根本不能用啊用7z解压试试
大话设计模式(带目录完整版)PDF
效果超炫,看附件截图
package monitor.ico; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Font; import java.awt.GraphicsEnvironment; import java.awt.Insets; import java.awt.Rectangle; import javax.swing.BorderFactory; import javax.swing.Icon; import javax.swing.ImageIcon; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextArea; import javax.swing.JWindow; import javax.swing.border.EtchedBorder; public class ToolTip { // 气泡提示宽 private int _width = 300; // 气泡提示高 private int _height = 100; // 设定循环的步长 private int _step = 30; // 每步时间 private int _stepTime = 30; // 显示时间 private int _displayTime = 6000; // 目前申请的气泡提示数量 private int _countOfToolTip = 0; // 当前最大气泡数 private int _maxToolTip = 0; // 在屏幕上显示的最大气泡提示数量 private int _maxToolTipSceen; // 字体 private Font _font; // 边框颜色 private Color _bgColor; // 背景颜色 private Color _border; // 消息颜色 private Color _messageColor; // 差值设定 int _gap; // 是否要求至顶(jre1.5以上版本方可执行) boolean _useTop = true; /** * 构造函数,初始化默认气泡提示设置 * */ public ToolTip() { // 设定字体 _font = new Font("宋体", 0, 12); // 设定边框颜色 _bgColor = new Color(255, 255, 225); _border = Color.BLACK; _messageColor = Color.BLACK; _useTop = true; // 通过调用方法,强制获知是否支持自动窗体置顶 try { JWindow.class.getMethod("setAlwaysOnTop", new Class[] { Boolean.class }); } catch (Exception e) { _useTop = false; } } /** * 重构JWindow用于显示单一气泡提示框 * */ class ToolTipSingle extends JWindow { private static final long serialVersionUID = 1L; private JLabel _iconLabel = new JLabel(); private JTextArea _message = new JTextArea(); public ToolTipSingle() { initComponents(); } private void initComponents() { setSize(_width, _height); _message.setFont(getMessageFont()); JPanel externalPanel = new JPanel(new BorderLayout(1, 1)); externalPanel.setBackground(_bgColor); // 通过设定水平与垂直差值获得内部面板 JPanel innerPanel = new JPanel(new BorderLayout(getGap(), getGap())); innerPanel.setBackground(_bgColor); _message.setBackground(_bgColor); _message.setMargin(new Insets(4, 4, 4, 4)); _message.setLineWrap(true); _message.setWrapStyleWord(true); // 创建具有指定高亮和阴影颜色的阴刻浮雕化边框 EtchedBorder etchedBorder = (EtchedBorder) BorderFactory .createEtchedBorder(); // 设定外部面板内容边框为风化效果 externalPanel.setBorder(etchedBorder); // 加载内部面板 externalPanel.add(innerPanel); _message.setForeground(getMessageColor()); innerPanel.add(_iconLabel, BorderLayout.WEST); innerPanel.add(_message, BorderLayout.CENTER); getContentPane().add(externalPanel); } /** * 动画开始 * */ public void animate() { new Animation(this).start(); } } /** * 此类处则动画处理 * */ class Animation extends Thread { ToolTipSingle _single; public Animation(ToolTipSingle single) { this._single = single; } /** * 调用动画效果,移动窗体坐标 * * @param posx * @param startY * @param endY * @throws InterruptedException */ private void animateVertically(int posx, int startY, int endY) throws InterruptedException { _single.setLocation(posx, startY); if (endY < startY) { for (int i = startY; i > endY; i -= _step) { _single.setLocation(posx, i); Thread.sleep(_stepTime); } } else { for (int i = startY; i < endY; i += _step) { _single.setLocation(posx, i); Thread.sleep(_stepTime); } } _single.setLocation(posx, endY); } /** * 开始动画处理 */ public void run() { try { boolean animate = true; GraphicsEnvironment ge = GraphicsEnvironment .getLocalGraphicsEnvironment(); Rectangle screenRect = ge.getMaximumWindowBounds(); int screenHeight = (int) screenRect.height; int startYPosition; int stopYPosition; if (screenRect.y > 0) { animate = false; } _maxToolTipSceen = screenHeight / _height; int posx = (int) screenRect.width - _width - 1; _single.setLocation(posx, screenHeight); _single.setVisible(true); if (_useTop) { _single.setAlwaysOnTop(true); } if (animate) { startYPosition = screenHeight; stopYPosition = startYPosition - _height - 1; if (_countOfToolTip > 0) { stopYPosition = stopYPosition - (_maxToolTip % _maxToolTipSceen * _height); } else { _maxToolTip = 0; } } else { startYPosition = screenRect.y - _height; stopYPosition = screenRect.y; if (_countOfToolTip > 0) { stopYPosition = stopYPosition + (_maxToolTip % _maxToolTipSceen * _height); } else { _maxToolTip = 0; } } _countOfToolTip++; _maxToolTip++; animateVertically(posx, startYPosition, stopYPosition); Thread.sleep(_displayTime); animateVertically(posx, stopYPosition, startYPosition); _countOfToolTip--; _single.setVisible(false); _single.dispose(); } catch (Exception e) { throw new RuntimeException(e); } } } /** * 设定显示的图片及信息 * * @param icon * @param msg */ public void setToolTip(Icon icon, String msg) { try { // 多个文件变化时,每个间隔2秒 Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } ToolTipSingle single = new ToolTipSingle(); if (icon != null) { single._iconLabel.setIcon(icon); } single._message.setText(msg); single.animate(); } /** * 设定显示的信息 * * @param msg */ public void setToolTip(String msg) { setToolTip(null, msg); } /** * 获得当前消息字体 * * @return */ public Font getMessageFont() { return _font; } /** * 设置当前消息字体 * * @param font */ public void setMessageFont(Font font) { _font = font; } /** * 获得边框颜色 * * @return */ public Color getBorderColor() { return _border; } /** * 设置边框颜色 * * @param _bgColor */ public void setBorderColor(Color borderColor) { this._border = borderColor; } /** * 获得显示时间 * * @return */ public int getDisplayTime() { return _displayTime; } /** * 设置显示时间 * * @param displayTime */ public void setDisplayTime(int displayTime) { this._displayTime = displayTime; } /** * 获得差值 * * @return */ public int getGap() { return _gap; } /** * 设定差值 * * @param gap */ public void setGap(int gap) { this._gap = gap; } /** * 获得信息颜色 * * @return */ public Color getMessageColor() { return _messageColor; } /** * 设定信息颜色 * * @param messageColor */ public void setMessageColor(Color messageColor) { this._messageColor = messageColor; } /** * 获得循环步长 * * @return */ public int getStep() { return _step; } /** * 设定循环步长 * * @param _step */ public void setStep(int _step) { this._step = _step; } public int getStepTime() { return _stepTime; } public void setStepTime(int _stepTime) { this._stepTime = _stepTime; } public Color getBackgroundColor() { return _bgColor; } public void setBackgroundColor(Color bgColor) { this._bgColor = bgColor; } public int getHeight() { return _height; } public void setHeight(int height) { this._height = height; } public int getWidth() { return _width; } public void setWidth(int width) { this._width = width; } public static void main(String[] args) { ToolTip tip = new ToolTip(); tip.setToolTip(new ImageIcon("F:\\a.jpg"),"我就是一农民 ---xbgd"); } }
发表评论
-
WindowBuilder Pro
2011-06-26 22:14 2078http://www.eclipse.org/windowbu ... -
GUI框架
2011-04-26 22:55 838http://tikeswing.sourceforge.ne ... -
Java中用线程实现带有滚动效果的Label标签
2011-04-17 22:19 1506import java.awt.Graphics; impo ... -
Java Swing 进度条
2010-07-31 21:37 2075注:不是自己写的,转的。 参数Thread 就是做耗时任务的 ... -
Swing开发之JProgressBar篇
2010-07-31 21:31 16275JProgressBar是一个简单的 ... -
禁用swing窗体右上角关闭按钮
2010-06-29 22:05 1690其实还可以通过评比关闭按钮的事件来达到该效果 import ... -
Java进度条JProgressBar使用方法
2010-06-03 22:05 3013Java进度条JProgressBar使用方法 packag ... -
Swing创建单选按钮
2010-04-29 23:18 31421. import javax.swing.JFram ... -
swing 单选(互斥)按钮
2010-04-29 23:18 2410package org.moon.admin; import ... -
JTextPane禁止换行的解决办法
2010-04-28 22:50 1241解决办法,重写下列方法: Java: public b ... -
Swing JTable高级使用-如何增加checkbox组件
2010-04-28 22:32 2097[url][/url] package components ... -
Swing 对JTextPane中字体颜色的设置
2010-04-09 20:52 2038import java.awt.BorderLayout; i ...
相关推荐
在Swing开发时,有个地方需要实现窗口右下解的浮动窗口效果 必须及时信息提示,新闻预览等。
Java Swing实现的生命游戏Java Swing实现的生命游戏Java Swing实现的生命游戏 Java Swing实现的生命游戏Java Swing实现的生命游戏Java Swing实现的生命游戏 Java Swing实现的生命游戏Java Swing实现的生命游戏Java ...
用java swing 实现的pdf阅读器 很强大 喜欢。。。
Java+Swing实现打飞机游戏。Java+Swing实现打飞机游戏。Java+Swing实现打飞机游戏。Java+Swing实现打飞机游戏。Java+Swing实现打飞机游戏。Java+Swing实现打飞机游戏。Java+Swing实现打飞机游戏。Java+Swing实现打...
java Swing多Jpanel仿安卓苹果桌面动态切换滑动效果
java Swing panel button左右滑动效果
JavaSwing 实现俄罗斯方块游戏。
java贪吃蛇javaswing实现贪吃蛇javaswing实现贪吃蛇javaswing实现贪吃蛇javaswing实现贪吃蛇javaswing实现贪吃蛇javaswing实现贪吃蛇javaswing实现贪吃蛇javaswing实现贪吃蛇javaswing实现贪吃蛇javaswing实现贪吃蛇...
swing 鼠标事件 loading效果
使用swing实现的java音乐播放器 有音乐列表,开始和暂停按钮
Java Swing实现仿Chrome浏览器跳跳龙小游戏 Java Swing实现仿Chrome浏览器跳跳龙小游戏 Java Swing实现仿Chrome浏览器跳跳龙小游戏 Java Swing实现仿Chrome浏览器跳跳龙小游戏 Java Swing实现仿Chrome浏览器跳跳龙小...
java swing实现学生住宿管理系统(源码) java swing实现学生住宿管理系统(源码) java swing实现学生住宿管理系统(源码) java swing实现学生住宿管理系统(源码) java swing实现学生住宿管理系统(源码) java ...
使用java swing,socket,多线程实现。 1) 客户端用来接收和展示数据,服务器实现与底层数据的交互。 2) 实现服务器端与客户端的分离,如果要操作数据库,可以在服务器端改代码调用Model。 3) 实现用户上线/下线...
使用Java Swing界面实现数据库基本操作,使用Java Swing界面实现数据库基本操作
利用JavaSwing实现简单的计算器,输入计算表达式得出结果,支持左右括号,负数以及小数。简单处理表达式不正确的情况,并且负数需打上括号。
实现了音乐列表、播放、暂停、上下歌曲切换等音乐播放器基本功能。利用到JavaSwing、多线程、音乐控制等多个知识点。且代码注释详细。欢迎下载~有问题可以私信我噢 ^_^
JAVA SWing 实现C/S模式的数据库编程及WebServices 调用实现
俄罗斯方块游戏-Java-Swing实现.zip俄罗斯方块游戏-Java-Swing实现.zip 俄罗斯方块游戏-Java-Swing实现.zip俄罗斯方块游戏-Java-Swing实现.zip 俄罗斯方块游戏-Java-Swing实现.zip俄罗斯方块游戏-Java-Swing实现.zip...
本项目是一套基于Java Swing实现的日历记事本系统,主要针对计算机相关专业的正在学习java的学生与需要项目实战练习的Java学习者。 包含:项目源码、报告文档等。 项目都经过严格调试,确保可以运行! 该系统功能...