How can i obtain a flash message ( a black screen that splashes for few seconds ) on screen for the time limit that i suggest ?
The whole screen of the computer should go black and there should be a message at the center.
For example in the following picture the length and width will be the length and width of the screen of the monitor:
Message covering the whole screen
I want this to be fired if a button is click or on it's own when some event is fired.
Here are my suggestions, Since you want this every time you click a button, the splash screen is not a viable solution.I think you have to make a window with your message,but keep in mind that going full screen isn't as simple as making a large panel, you need to look into the underlying OS graphics. Here is a solution to create a full-screen (non-windowed) application in Java which might be helpful to you.
Also I suggest you to have a look at the Java's Full-Screen mode API .
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class displayFullScreen extends JFrame {
private JLabel alarmMessage = new JLabel("Alarm !");
private JPanel panel = new JPanel();
public displayFullScreen() {
setUndecorated(true);
panel.setLayout(new FlowLayout(FlowLayout.CENTER));
alarmMessage.setText("Alarm !");
alarmMessage.setFont(new Font("Cambria",Font.BOLD,100));
alarmMessage.setForeground(Color.CYAN);
panel.add(alarmMessage);
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
setBounds(0,0,screenSize.width,screenSize.height);
panel.setBackground(Color.black);
add(panel);
addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent ke) {
escapeHandler(ke);
}
});
}
public void escapeHandler(KeyEvent ke) {
if(ke.getKeyCode() == ke.VK_ESCAPE) {
displayFullScreen.this.dispose();
}
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.