0
20ms 동안 표시되는 이미지를 따라 투명한 화면을 1000ms 동안 보여주는 프로그램을 만들려고합니다. 그것은 루프 (1000m s -> 20ms -> 1000ms -> 20ms -> ....)에서 계속되어야합니다.빠른 이미지/프레임 변경 (20ms 동안 표시)
이미지를 표시하는 데 시간이 너무 오래 걸리므로 화면에 이미지가 표시 될 때 볼 수 있습니다.
더 나은 성능을 얻을 수있는 방법이 있습니까? 여기
코드입니다 :이 빨리 깜박 경우import java.awt.*;
import javax.swing.*;
import static java.awt.GraphicsDevice.WindowTranslucency.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Timer;
import java.util.TimerTask;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
public class SubPrimingJava extends JFrame {
public SubPrimingJava() {
super("GradientTranslucentWindow");
setBackground(new Color(0,0,0,0));
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
setBounds(0,0,screenSize.width+20, screenSize.height+200);
//setLocationRelativeTo(null);
setLocation(-10, -100);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel = new JPanel() {
@Override
protected void paintComponent(Graphics g) {
if (g instanceof Graphics2D) {
final int R = 240;
final int G = 240;
final int B = 240;
Paint p =
new GradientPaint(0.0f, 0.0f, new Color(R, G, B, 0),
0.0f, getHeight(), new Color(R, G, B, 0), true);
Graphics2D g2d = (Graphics2D)g;
g2d.setPaint(p);
g2d.fillRect(0, 0, getWidth(), getHeight());
}
}
};
setContentPane(panel);
setLayout(new GridBagLayout());
}
public static void main(String[] args) {
// Determine what the GraphicsDevice can support.
GraphicsEnvironment ge =
GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gd = ge.getDefaultScreenDevice();
boolean isPerPixelTranslucencySupported =
gd.isWindowTranslucencySupported(PERPIXEL_TRANSLUCENT);
//If translucent windows aren't supported, exit.
if (!isPerPixelTranslucencySupported) {
System.out.println(
"Per-pixel translucency is not supported");
System.exit(0);
}
JFrame.setDefaultLookAndFeelDecorated(true);
// Create the GUI on the event-dispatching thread
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
SubPrimingJava gtw = new
SubPrimingJava();
// Display the window.
gtw.setVisible(true);
ImageIcon icon = new ImageIcon("test.png");
JLabel label = new JLabel(icon);
gtw.add(label);
gtw.setOpacity(0);
Timer timer = new Timer(1000, new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
gtw.setOpacity(1);
Timer t2 = new Timer(1, new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
gtw.setOpacity(0);
}
});
t2.start();
t2.setRepeats(false);
}
});
timer.setRepeats(true);
timer.start();
}
});
}
}
이 * "시간 이미지가 너무 길어서 화면에 이미지가 표시되면이를 볼 수 있습니다. "* Subliminal suggestion? 이것의 핵심은 무엇입니까? –
예, 잠재적 인 제안입니다. 나는 이것을 연구해야한다. 관찰자가 그것을 보지 못하도록 이미지는 20ms 동안 만 표시되어야합니다. 내 솔루션은 느리다. 아이디어가 있습니까? – Peter