📄 windowpopup.java
字号:
/*
* RIC 2 by Harry Otten (c) Copyright 2003 hotten@dds.nl
* Check out http://www.hotten.dds.nl/ric/
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA.
*/
import java.awt.*;
import java.awt.event.*;
import java.awt.Window;
import javax.swing.*;
class WindowPopup extends Thread implements MouseListener {
private String message;
private MainScreenGUI mainScreenGUI;
private JLabel picture;
public WindowPopup(MainScreenGUI mainScreenGUI,String message) {
this.message=message;
this.mainScreenGUI=mainScreenGUI;
}
private JWindow popup;
public void run() {
System.out.println("Make a popup window!");
popup = new JWindow(mainScreenGUI);
(popup.getContentPane()).setLayout(null);
// TO DO make it paint a nice text....
// for now different slide
if (message.equals("Internet available"))
picture = new JLabel(new ImageIcon("../graphics/slide.jpg"),SwingConstants.CENTER);
else picture = new JLabel(new ImageIcon("../graphics/slide2.jpg"),SwingConstants.CENTER);
picture.setBounds(0,0,148,120);
picture.addMouseListener(this);
(popup.getContentPane()).add(picture);
int X = (int) (((Toolkit.getDefaultToolkit()).getScreenSize()).getWidth())-164; //16
int Y = (int) (((Toolkit.getDefaultToolkit()).getScreenSize()).getHeight())-148; //28
mainScreenGUI.setState(Frame.NORMAL);
mainScreenGUI.toFront();
popup.setLocation(X,Y+148);
popup.setSize(148,120);
popup.show();
int teller=Y;
// slide it up ;-)
for (teller=Y+148;teller>Y;teller-=6) {
try {
sleep(20);
} catch (InterruptedException e) {
}
popup.setLocation(X,teller);
}
try {
sleep(10000);
} catch (InterruptedException e) {
}
popup.dispose();
//and wait for the garbage collect to collect me ;-)
}
public void mouseClicked(MouseEvent e) {
popup.dispose();
}
public void mouseEntered(MouseEvent e) {
}
public void mouseExited(MouseEvent e) {
}
public void mousePressed(MouseEvent e) {
}
public void mouseReleased(MouseEvent e) {
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -