import java.awt.AWTException;
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Container;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.MediaTracker;
import java.awt.MenuItem;
import java.awt.PopupMenu;
import java.awt.SystemTray;
import java.awt.TrayIcon;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.geom.RoundRectangle2D;
import java.awt.image.BufferedImage;
import java.awt.image.ImageObserver;
import java.io.IOException;
import javax.swing.ImageIcon;
import javax.swing.JDialog;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextArea;
//import TipFrameA.DisplayPanel;
import com.sun.awt.AWTUtilities;
/**
* 便筏A
* @author fox
*
*/
public class TipFrameA extends JDialog{
public JLabel jl=null;
public JLabel jPic=null;
public JLabel jl1=null;
public JTextArea jta=null;
Font font=null;
JLabel save=null;
JLabel history=null;
JLabel delete=null;
public JLabel menuBar=null;
RButton old=null;//历史便笺
RButton bg=null;//更换背景
RButton more=null;//更多功能
RButton top=null;//置顶
DisplayPanel displayPanel =null; //显示背景图片的面板
public TipFrameA(){
final Container content = getContentPane();//怎么一定要final呢?
this.setLayout(null);
this.setSize(250,330);
this.setLocationRelativeTo(null);
//this.setAlwaysOnTop(true);
font=new Font("微软雅黑", Font.LAYOUT_NO_START_CONTEXT, 20);
displayPanel = new DisplayPanel();
jl=new JLabel(new ImageIcon("images/0000.png"));
jl.setBounds(0, 0,250,330);
jl.setLayout(null);
jta=new JTextArea(20,13);
//jta.setWrapStyleWord(false);
jta.setLineWrap(true);
jta.setFont(font);
jta.setForeground(new Color(71,30,38));
jta.setBounds(0, 20,250, 330);
jta.setOpaque(false);
save=new JLabel(new ImageIcon("images/0000.png"));
save.setIcon(new ImageIcon("images/65.png"));
save.setBounds(218, 310, 30, 20);
save.addMouseListener(new SaveListener(this));
jl.add(save);
history=new JLabel(new ImageIcon("0000.png"));
history.setBounds(186, 310, 30, 20);
history.setIcon(new ImageIcon("images/27.png"));
history.addMouseListener(new HistoryMouse(this));
jl.add(history);
delete=new JLabel(new ImageIcon("0000.png"));
delete.setIcon(new ImageIcon("images/64.png"));
delete.setBounds(218, 0, 30, 20);
delete.addMouseListener(new DeleteListener(this));
jl.add(delete);
menuBar=new JLabel(new ImageIcon("0000.png"));
menuBar.setBounds(123, 231, 70, 80);
menuBar.setLayout(null);
old=new RButton(RButton.LEFT_ROUND_RECT);
old.setBounds(0, 0, 70, 20);
old.setText("历史");
old.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
String str="c:\\我的便筏记录";
try {
Runtime.getRuntime().exec("explorer.exe "+str);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
});
bg=new RButton(RButton.LEFT_ROUND_RECT);
bg.setBounds(0, 20, 70, 20);
bg.setText("背景");
bg.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent arg0) {
// 定义文件选择组件
JFileChooser jfc = new JFileChooser();//JFileChooser 为用户选择文件提供了一种简单的机制。
//设置文件过滤器
jfc.setFileFilter(new MyFilter());
jfc.showOpenDialog(null);//弹出一个 "Open File" 文件选择器对话框。
//拿到用户选择的图片所对应的File对象
String selectedPath=jfc.getSelectedFile().getAbsolutePath();
String selectedPath1=selectedPath.replaceAll("\\\\","\\\\\\\\");
content.remove(displayPanel);
content.validate();
DisplayPanel.path=selectedPath1;
displayPanel = new DisplayPanel();
displayPanel.setBounds(0, 0, 250,330);
content.add(displayPanel);
content.repaint();
content.validate();
}});
top=new RButton(RButton.LEFT_ROUND_RECT);
top.setBounds(0, 40, 70, 20);
top.setText("置顶");
top.addActionListener(new ActionListener(){
int i=1;
@Override
public void actionPerformed(ActionEvent arg0) {
if(i<2){
i++;
setAlwaysOnTop(true);
top.setText("正常");
}else{
setAlwaysOnTop(false);
top.setText("置顶");
i=1;
}
}
});
more=new RButton(RButton.LEFT_ROUND_RECT);
more.setBounds(0, 60, 70, 20);
more.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent arg0) {
JOptionPane.showMessageDialog(null, "施工ing....美女你有男朋友没?我还是单身");
}
});
more.setText("更多");
menuBar.add(old);
menuBar.add(bg);
menuBar.add(more);
menuBar.add(top);
menuBar.setVisible(false);
jl.add(menuBar);
jl.add(jta);
//jl1.add(jl);
//透明
this.setUndecorated(true);
AWTUtilities.setWindowOpaque(this, false);
com.sun.awt.AWTUtilities.setWindowOpacity(this,(float)1.0);
content.add(jl);
displayPanel.setBounds(0, 0, 250,330);
content.add(displayPanel);
// this.add(jPic);
//圆角
AWTUtilities.setWindowShape(this, new RoundRectangle2D.Double(
0.0D, 0.0D, this.getWidth(), this.getHeight(), 20.0D, 20.0D));
//鼠标监听
MyMouseListener ml=new MyMouseListener(this);
this.addMouseListener(ml);
this.addMouseMotionListener(ml);
//系统托盘
SystemTray st=SystemTray.getSystemTray();
TrayIcon icon=new TrayIcon(new ImageIcon("images/tay.png").getImage(),"做更优秀的自己");
PopupMenu popup = new PopupMenu();
MenuItem itemExit = new MenuItem("退出");
popup.add(itemExit);
itemExit.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
});
icon.setPopupMenu(popup);
icon.addMouseListener(new MouseAdapter(){
int count=1;
public void mouseClicked(MouseEvent e) {
if(count<2){
count++;
setVisible(false);
}else{
setVisible(true);
count=1;
}
}
});
try {
st.add(icon);
} catch (AWTException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
this.setVisible(true);
this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
}
public static void main(String[] args) {
new TipFrameA();
}
}