2016-02-11 01:14:23 +01:00
|
|
|
/*
|
|
|
|
* Copyright 2015 dorkbox, llc
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
2017-07-28 22:07:01 +02:00
|
|
|
import java.awt.FlowLayout;
|
2017-09-17 16:29:46 +02:00
|
|
|
import java.awt.Image;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.InputStream;
|
2017-07-28 22:07:01 +02:00
|
|
|
|
2017-09-17 16:29:46 +02:00
|
|
|
import javax.imageio.ImageIO;
|
2017-07-28 22:07:01 +02:00
|
|
|
import javax.swing.JButton;
|
|
|
|
import javax.swing.JFrame;
|
|
|
|
import javax.swing.JLabel;
|
|
|
|
import javax.swing.JPanel;
|
|
|
|
|
2016-02-11 01:14:23 +01:00
|
|
|
import dorkbox.notify.Notify;
|
|
|
|
import dorkbox.notify.Pos;
|
2017-09-17 16:29:46 +02:00
|
|
|
import dorkbox.util.ImageUtil;
|
|
|
|
import dorkbox.util.LocationResolver;
|
2017-07-28 22:07:01 +02:00
|
|
|
import dorkbox.util.ScreenUtil;
|
2016-02-11 01:14:23 +01:00
|
|
|
|
|
|
|
public
|
|
|
|
class NotifyTest {
|
|
|
|
|
|
|
|
public static
|
|
|
|
void main(String[] args) {
|
|
|
|
Notify notify;
|
|
|
|
|
2017-07-28 22:07:01 +02:00
|
|
|
JFrame frame = new JFrame("Test");
|
|
|
|
|
|
|
|
JPanel panel = new JPanel();
|
|
|
|
panel.setLayout(new FlowLayout());
|
|
|
|
|
|
|
|
JLabel label = new JLabel("This is a label!");
|
|
|
|
|
|
|
|
JButton button = new JButton();
|
|
|
|
button.setText("Press me");
|
|
|
|
|
|
|
|
panel.add(label);
|
|
|
|
panel.add(button);
|
|
|
|
|
|
|
|
frame.add(panel);
|
2017-09-17 14:32:52 +02:00
|
|
|
frame.setSize(900, 600);
|
2017-07-28 22:07:01 +02:00
|
|
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
|
|
frame.setVisible(true);
|
|
|
|
|
|
|
|
ScreenUtil.showOnSameScreenAsMouse_Center(frame);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int count = 2;
|
|
|
|
|
2021-02-09 23:22:51 +01:00
|
|
|
// for (int i = 0; i < count; i++) {
|
|
|
|
// final int finalI = i;
|
|
|
|
// notify = Notify.create()
|
|
|
|
// .title("Notify title " + i)
|
|
|
|
// .text("This is a notification " + i + " popup message This is a notification popup message This is a " +
|
|
|
|
// "notification popup message")
|
|
|
|
// .hideAfter(13000)
|
|
|
|
// .position(Pos.BOTTOM_RIGHT)
|
|
|
|
// // .position(Pos.CENTER)
|
|
|
|
// // .setScreen(0)
|
|
|
|
// .darkStyle()
|
|
|
|
// // .shake(1300, 4)
|
|
|
|
// .shake(1300, 10)
|
|
|
|
// .attach(frame)
|
|
|
|
// .hideCloseButton()
|
|
|
|
// .onAction(new ActionHandler<Notify>() {
|
|
|
|
// @Override
|
|
|
|
// public
|
|
|
|
// void handle(final Notify arg0) {
|
|
|
|
// System.err.println("Notification " + finalI + " clicked on!");
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
// notify.showWarning();
|
|
|
|
//
|
|
|
|
// // try {
|
|
|
|
// // Thread.sleep(1000);
|
|
|
|
// // } catch (InterruptedException e) {
|
|
|
|
// // e.printStackTrace();
|
|
|
|
// // }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// for (int i = 0; i < count; i++) {
|
|
|
|
// final int finalI = i;
|
|
|
|
// notify = Notify.create()
|
|
|
|
// .title("Notify title " + i)
|
|
|
|
// .text("This is a notification " + i + " popup message This is a notification popup message This is a " +
|
|
|
|
// "notification popup message")
|
|
|
|
// .hideAfter(13000)
|
|
|
|
// .position(Pos.TOP_LEFT)
|
|
|
|
// // .position(Pos.CENTER)
|
|
|
|
// // .setScreen(0)
|
|
|
|
// // .darkStyle()
|
|
|
|
// // .shake(1300, 4)
|
|
|
|
// // .shake(1300, 10)
|
|
|
|
// .attach(frame)
|
|
|
|
// // .hideCloseButton()
|
|
|
|
// .onAction(new ActionHandler<Notify>() {
|
|
|
|
// @Override
|
|
|
|
// public
|
|
|
|
// void handle(final Notify arg0) {
|
|
|
|
// System.err.println("Notification " + finalI + " clicked on!");
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
// notify.showWarning();
|
|
|
|
//
|
|
|
|
// try {
|
|
|
|
// Thread.sleep(1000);
|
|
|
|
// } catch (InterruptedException e) {
|
|
|
|
// e.printStackTrace();
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// for (int i = 0; i < count; i++) {
|
|
|
|
// final int finalI = i;
|
|
|
|
// notify = Notify.create()
|
|
|
|
// .title("Notify title " + i)
|
|
|
|
// .text("This is a notification " + i + " popup message This is a notification popup message This is a " +
|
|
|
|
// "notification popup message")
|
|
|
|
// .hideAfter(3000)
|
|
|
|
// .position(Pos.TOP_RIGHT)
|
|
|
|
// // .setScreen(0)
|
|
|
|
// .darkStyle()
|
|
|
|
// // .shake(1300, 4)
|
|
|
|
// .shake(1300, 10)
|
|
|
|
// .hideCloseButton()
|
|
|
|
// .onAction(new ActionHandler<Notify>() {
|
|
|
|
// @Override
|
|
|
|
// public
|
|
|
|
// void handle(final Notify arg0) {
|
|
|
|
// System.err.println("Notification " + finalI + " clicked on!");
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
// notify.show();
|
|
|
|
//
|
|
|
|
// try {
|
|
|
|
// Thread.sleep(1000);
|
|
|
|
// } catch (InterruptedException e) {
|
|
|
|
// e.printStackTrace();
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
// The purpose of this, is to display this image AS A SQUARE!
|
2017-09-17 16:29:46 +02:00
|
|
|
InputStream resourceAsStream = LocationResolver.getResourceAsStream("notify-dark.png");
|
|
|
|
Image image = null;
|
|
|
|
try {
|
2021-02-09 23:22:51 +01:00
|
|
|
image = ImageIO.read(resourceAsStream);
|
|
|
|
ImageUtil.waitForImageLoad(image);
|
|
|
|
|
2017-09-17 16:29:46 +02:00
|
|
|
// image = image.getScaledInstance(144, 104, Image.SCALE_SMOOTH);
|
2017-09-17 21:05:31 +02:00
|
|
|
// image = image.getScaledInstance(104, 144, Image.SCALE_SMOOTH);
|
|
|
|
image = image.getScaledInstance(144, 144, Image.SCALE_SMOOTH);
|
2017-09-17 16:29:46 +02:00
|
|
|
} catch (IOException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
|
2021-02-09 23:22:51 +01:00
|
|
|
notify = Notify.create()
|
|
|
|
.title("Notify scaled")
|
|
|
|
.text("This is a notification popup message scaled This is a notification popup message This is a " +
|
|
|
|
"notification popup message scaled ")
|
|
|
|
// .hideAfter(13000)
|
|
|
|
.position(Pos.BOTTOM_LEFT)
|
2017-07-28 22:07:01 +02:00
|
|
|
// .setScreen(0)
|
2017-09-03 17:34:09 +02:00
|
|
|
// .darkStyle()
|
2021-02-09 23:22:51 +01:00
|
|
|
// .shake(1300, 4)
|
|
|
|
// .shake(1300, 10)
|
|
|
|
// .hideCloseButton()
|
|
|
|
.onAction(arg0->System.err.println("Notification scaled clicked on!"));
|
|
|
|
|
|
|
|
notify.image(image);
|
|
|
|
notify.show();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// for (int i = 0; i < count; i++) {
|
|
|
|
// final int finalI = i;
|
|
|
|
// notify = Notify.create()
|
|
|
|
// .title("Notify title " + i)
|
|
|
|
// .text("This is a notification " + i + " popup message This is a notification popup message This is a " +
|
|
|
|
// "notification popup message")
|
|
|
|
// // .hideAfter(13000)
|
|
|
|
// .position(Pos.BOTTOM_LEFT)
|
|
|
|
// // .setScreen(0)
|
|
|
|
// // .darkStyle()
|
|
|
|
// // .shake(1300, 4)
|
|
|
|
// // .shake(1300, 10)
|
|
|
|
// // .hideCloseButton()
|
|
|
|
// .onAction(new ActionHandler<Notify>() {
|
|
|
|
// @Override
|
|
|
|
// public
|
|
|
|
// void handle(final Notify arg0) {
|
|
|
|
// System.err.println("Notification " + finalI + " clicked on!");
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
//
|
|
|
|
// if (i == 0) {
|
|
|
|
// notify.image(image);
|
|
|
|
// notify.show();
|
|
|
|
// }
|
|
|
|
// else {
|
|
|
|
// notify.showConfirm();
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// try {
|
|
|
|
// Thread.sleep(1000);
|
|
|
|
// } catch (InterruptedException e) {
|
|
|
|
// e.printStackTrace();
|
|
|
|
// }
|
|
|
|
// }
|
2016-02-11 01:14:23 +01:00
|
|
|
}
|
|
|
|
}
|