Javaが初めてで、何をしても修正できないように見える問題があるため、どんな助けも大歓迎です。
Java で小さなアプリケーションを作成し、Nimbus のルック アンド フィールを使用するポップアップ カレンダー (WWW) を統合しました。私の問題は、ポップアップ カレンダーが初めて呼び出された後、GUI で同じルック アンド フィールを取得できないことです。私には2つの選択肢があります。私のGUIが以前と同じように設定をリセットしてポップアップへの呼び出しが行われるようにする方法を見つけるか、すべてのGUIがニンバスのルックアンドフィールを使用するように場所(メインクラス)がわからないコードを入力します。
ポップアップカレンダーのコードはこちら
import java.awt.*;
import javax.swing.*;
import javax.swing.UIManager.*;
public class Celendar extends JFrame {
//private JPanel p;
Celendar(){
//super("ColorEditor");
//UIManager.put("nimbusBase", new Color(233,22,22));
//UIManager.put("nimbusBlueGrey", new Color(22,200,150));
//UIManager.put("control", new Color(100,150,200));
try {
for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
UIManager.setLookAndFeel(info.getClassName());
break;
}else{
UIManager.setLookAndFeel"com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
}
}
} catch (Exception e) {
// If Nimbus is not available, you can set the GUI to another look and
// feel
}
setLayout(new GridLayout(1,1));
setSize(322,250);
setLocation(500,400);
setResizable(false);
Days d= new Days();
/*----- Here -----*/
//setVisible(true);
//setDefaultCloseOperation(EXIT_ON_CLOSE);
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
I THINK HERE IS WHERE I NEED TO INSERT SOME CODE TO GET MY GUI DISPLAYING
BEFORE THECALL TO THE POP UP IS MADE.
/*----------------*/
add(d);
// try{
// //UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
// //UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
// UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
// //UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
// //UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
// //UIManager.setLookAndFeel("com.sun.javax.swing.plaf.metal.MetalLookAndFeel");
// SwingUtilities.updateComponentTreeUI(this);
// }catch(Exception e){System.out.println("error "+e);}
}
}
または、すべての GUI に Nimbus のルック アンド フィールを持たせるコードをどこに挿入しますか?