![JAR search and dependency download from the Maven repository](/logo.png)
com.talk2object.plum.view._abstract.components.AppView Maven / Gradle / Ivy
package com.talk2object.plum.view._abstract.components;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;
import org.apache.commons.lang3.RandomUtils;
import com.talk2object.plum.interaction.model.Application;
import com.talk2object.plum.view.component.Component;
import com.talk2object.plum.view.component.Label;
import com.talk2object.plum.view.component.TextBox;
import com.talk2object.plum.view.component.containers.window.MainWindow;
import com.talk2object.plum.view.event.AbstractEventListener;
import com.talk2object.plum.view.misc.Color;
import com.talk2object.plum.view.misc.Font;
public class AppView extends MainWindow {
TextBox tbname;
Label lblGreetUser;
Label lblTime;
Application app;
Timer timer;
public AppView() {
init();
}
private void init() {
setName("plumDemo");
setTitle("PLUM Demo");
lblTime = new Label();
// lblTime.setExtraAttribute("html-id", "footer-time");
lblTime.setText((new Date()).toString());
footPanel.addChild(lblTime);
addEventListener(EVENT_BEFORE_REFRESH_VIEW,
new AbstractEventListener() {
@Override
public void process(Component source, String eventName,
Object[] parameters) {
// update time label
lblTime.setText((new Date()).toString());
}
});
timer = new Timer("appView timer");
TimerTask task = new TimerTask() {
@Override
public void run() {
// refresh time
// System.out.println("update footer time");
Color color = new Color(RandomUtils.nextInt(0, 256),
RandomUtils.nextInt(0, 256),
RandomUtils.nextInt(0, 256));
Color backgroundColor = new Color(RandomUtils.nextInt(0, 256),
RandomUtils.nextInt(0, 256),
RandomUtils.nextInt(0, 256));
Font font = new Font();
//font.setSize(RandomUtils.nextInt(10, 32)+"px");
lblTime.setColor(color);
//lblTime.setBackgroundColor(backgroundColor);
lblTime.setFont(font);
lblTime.setText((new Date()).toString(), true);
}
};
//timer.scheduleAtFixedRate(task, 1000 * 1, 1000 * 5);
}
@Override
public void destroy() {
super.destroy();
System.out.println("cancel timer.");
timer.cancel();
timer.purge();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy