JFrame
提供された 3 ~ 4 枚の写真を背景としてランダムに選択するを作成できますか。そのため、ユーザーが を開くとJFrame
、 はJFrame
指定された画像のいずれかを背景として選択します。
私はそれを次のようにしたい:
ImageIcon background = new ImageIcon("First Image.png");
JLabel label = new JLabel(background);
frame.add(label);
そして2番目の写真:
ImageIcon background2 = new ImageIcon("Second Image.png");
JLabel label2 = new JLabel(background2);
frame.add(label2);
第3:
ImageIcon background3 = new ImageIcon("Third Image.png");
JLabel label3 = new JLabel(background3);
frame.add(label3);
そしておそらく4番目:
ImageIcon background4 = new ImageIcon("Fourth Image.png");
JLabel label4 = new JLabel(background4);
frame.add(label4);
そして、JFrameがこれらのコードのいずれかを使用できるように、いくつかのコードが必要です。
また、JFrame のタイトルをランダムに変更する方法はありますか?
私が欲しいのは次のようなものです:
'My Game: It's the best!'
...そして、ユーザーが JFrame を再度開くと、タイトルが次のように変更されます。
'My Game: Try it, it's new!'
および/または
'My Game: You can play it easily!'
および/または
'My Game: Find all the mysteries...'
および/または
'My Game: Money don't go on trees!'
と他の面白い行。
私はあなたが理解しやすいように願っています!