0
私は、1000ミリ秒間、20ミリ秒間表示される画像に続く透明なスクリーンを示すプログラムを作成しようとしています。それはループ(1000m s - > 20 ms - > 1000 ms - > 20 ms - > ....)で続けるべきです。イメージ/フレームを高速で変更する(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();
}
});
}
}
*」を表示するための時間ここで
コードです画像が長すぎるので、画面に画像が表示されていればそれを見ることができます。」*昇格提案?これのポイントは何ですか? –
はい、昇進の提案。私は研究のためにこれが必要です。観察者はそれを見ないように、画像は20msだけ表示されるはずです。私の解決策は遅いです。あなたはなにか考えはありますか? – Peter