我在我的应用程序上安装并正确应用了 JTattoo L&F,但由于某种原因,主 JFrame 没有得到 L&F!我认为这与它在 main 方法中使用 .setVisible(true); 实例化有关。方法,在为整个应用实例化 JTattoo L&F 之后!我尝试了一切,包括更改 JFrame 代码本身中的 L&F,无论我做什么,都没有任何效果......它就是不会让步!在谷歌上寻找类似的问题,没有发现任何相关的东西,我已经在这个问题上花了几个小时但无法弄清楚,我尝试了一切!包括“逆向工程”一些方法,都行不通!
这是我的代码:
public class DsrApplication {
public static MeniuPrincipalTaburi meniuTaburi = new MeniuPrincipalTaburi();
public static boolean isAdmin;
public static ArrayList<String> arrUti;
public static void main(String[] args) throws SQLException {
try {
//here you can put the selected theme class name in JTattoo
UIManager.setLookAndFeel("com.jtattoo.plaf.mint.MintLookAndFeel");
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(DsrApplication.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(DsrApplication.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(DsrApplication.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(DsrApplication.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
String connectionUrl = String.format("jdbc:mysql://%s:%s/%s", "127.0.0.1", "3306", "dsr");
DataBaseConnection db = new DataBaseConnection(connectionUrl, "root", "@Root123#");
Connection conn = db.getConnection();
Logare logare = new Logare();
meniuTaburi.setVisible(true);
MeniuPrincipalTaburi.Meniu.addTabNoExit("Logare", logare.getContentPane());
MeniuPrincipalTaburi.Meniu.setSelectedComponent(logare.getContentPane());
Map<String, String> utilizatori = new HashMap<>();
UtilizatoriDAO userManagement = new UtilizatoriDAO(conn);
try {
utilizatori = userManagement.getAll();
} catch (SQLException ex) {
Logger.getLogger(CreeareUtilizatori.class.getName()).log(Level.SEVERE, null, ex);
}
Map<String, String> getUtilizatori = new HashMap<>();
System.out.println(getUtilizatori.get("Admin"));
FisierDAO fisierDB = new FisierDAO(db.getConnection());
List<Fisier> fisiere = new ArrayList<>();
fisiere = fisierDB.getAll();
arrUti = userManagement.getNames();
}
这是 JFrame 的代码:
public class MeniuPrincipalTaburi extends javax.swing.JFrame {
/**
* Creates new form MeniuPrincipalTaburi
*/
public static JTabbedPaneCloseButton Meniu = new JTabbedPaneCloseButton();
public MeniuPrincipalTaburi() {
Meniu.setEnabled(true);
Meniu.setSize(1000, 500);
this.setSize(1000, 500);
this.add(Meniu);
initComponents();
ImageIcon img = new ImageIcon("C:\\Users\\Dragos\\Documents\\NetBeansProjects\\project\\Fisiere\\Alte Documente\\Logo\\transformator.png");
this.setIconImage(img.getImage());
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Sistem informatic laborator");
addContainerListener(new java.awt.event.ContainerAdapter() {
public void componentAdded(java.awt.event.ContainerEvent evt) {
formComponentAdded(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 1008, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 665, Short.MAX_VALUE)
);
pack();
}// </editor-fold>
private void formComponentAdded(java.awt.event.ContainerEvent evt) {
// TODO add your handling code here:
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
UIManager.setLookAndFeel("com.jtattoo.plaf.mint.MintLookAndFeel");
/*if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}*/
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(MeniuPrincipalTaburi.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(MeniuPrincipalTaburi.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(MeniuPrincipalTaburi.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(MeniuPrincipalTaburi.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new MeniuPrincipalTaburi().setEnabled(true);
}
});
}
// Variables declaration - do not modify
// End of variables declaration
}
如您所见,还尝试在 JFrame 的 L&F 代码中更改 Nimbus L&F……仍然没有!如果有人愿意提供任何提示,谢谢大家。