|
|
@@ -4,10 +4,14 @@ import net.ranides.assira.events.EventLock;
|
|
|
import net.ranides.assira.events.EventReactor;
|
|
|
import net.ranides.assira.events.EventRouter;
|
|
|
import net.ranides.assira.observable.BeanEvent;
|
|
|
+import net.ranides.assira.ui.helpers.WindowUtils;
|
|
|
+import org.junit.Ignore;
|
|
|
import org.junit.Test;
|
|
|
|
|
|
import javax.swing.*;
|
|
|
import java.awt.*;
|
|
|
+import java.awt.event.MouseAdapter;
|
|
|
+import java.awt.event.MouseEvent;
|
|
|
import java.awt.event.WindowAdapter;
|
|
|
import java.awt.event.WindowEvent;
|
|
|
|
|
|
@@ -63,31 +67,28 @@ public class ParseCssFontTest {
|
|
|
assertEquals(new Font(Font.SERIF, Font.PLAIN, 32), ParseCssFont.font("24pt serif"));
|
|
|
}
|
|
|
|
|
|
- private void showPreview(Font font) {
|
|
|
- EventRouter router = EventReactor.newInstance("me");
|
|
|
+ @Ignore("manual")
|
|
|
+ @Test
|
|
|
+ public void preview() {
|
|
|
+ showPreview(ParseCssFont.font("bold 24pt 'comic sans ms'"));
|
|
|
+ showPreview(ParseCssFont.font("bold italic 24pt 'arial black'"));
|
|
|
+ }
|
|
|
|
|
|
+ private void showPreview(Font font) {
|
|
|
JFrame frame = new JFrame();
|
|
|
- frame.setSize(400, 300);
|
|
|
+ frame.setSize(600, 200);
|
|
|
JLabel label = new JLabel();
|
|
|
label.setText("Hello world. This is font.");
|
|
|
label.setFont(font);
|
|
|
label.setHorizontalAlignment(SwingConstants.CENTER);
|
|
|
- frame.add(label);
|
|
|
-
|
|
|
- frame.addWindowListener(new WindowAdapter() {
|
|
|
+ label.addMouseListener(new MouseAdapter() {
|
|
|
@Override
|
|
|
- public void windowClosing(WindowEvent e) {
|
|
|
- router.signalEvent(BeanEvent.change(this, "close", false, true));
|
|
|
+ public void mouseClicked(MouseEvent e) {
|
|
|
+ frame.dispatchEvent(new WindowEvent(frame, WindowEvent.WINDOW_CLOSING));
|
|
|
}
|
|
|
});
|
|
|
- frame.setVisible(true);
|
|
|
-
|
|
|
- try {
|
|
|
- EventLock.lock(BeanEvent.class, router).waitForEvent();
|
|
|
- router.dispose();
|
|
|
- } catch (InterruptedException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
+ frame.add(label);
|
|
|
|
|
|
+ WindowUtils.waitForFrame(frame);
|
|
|
}
|
|
|
}
|