如何解决当我单击运行我的项目 java 时,它不会运行
当我点击运行程序时,虽然我将它包含在主类中,但在我看来并没有运行 jframe。有时,当我运行程序时,GUI 只出现在没有效果和功能的情况下。这是名为 suivi medicale 的主类
public class SuiviMedicale extends PAge_principale{
public SuiviMedicale() {
setTitle("page principale");
setLocationRelativeto(null);
setDefaultCloSEOperation(EXIT_ON_CLOSE);
}
public static void main(String[] args) {
// new PAge_principale().setVisible(true);
PAge_principale page = new PAge_principale();
page.setVisible(true);
}
}
当我运行 jframe 时,只有 runnunig 。这个名为 Page_principale 的 jframe
package suivi.medicale;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
public class PAge_principale extends javax.swing.JFrame {
public PAge_principale() {
initComponents();
}
/**
* 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() {
jPanel1 = new javax.swing.JPanel();
process_download = new javax.swing.JProgressBar();
jTextField1 = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
peurcentage = new javax.swing.JTextField();
setDefaultCloSEOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jPanel1.setBackground(new java.awt.Color(255,102,0));
process_download.setBackground(new java.awt.Color(153,153,153));
jTextField1.setBackground(new java.awt.Color(255,0));
jTextField1.setFont(new java.awt.Font("Verdana",18)); // NOI18N
jTextField1.setForeground(new java.awt.Color(204,204,255));
jTextField1.setText("Bienvenue à suivi maladie application");
jTextField1.setBorder(null);
peurcentage.setBackground(new java.awt.Color(255,0));
peurcentage.setFont(new java.awt.Font("Verdana",18)); // NOI18N
peurcentage.setForeground(new java.awt.Color(204,255));
peurcentage.setText("%");
peurcentage.setBorder(null);
peurcentage.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
peurcentageActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(process_download,javax.swing.GroupLayout.Alignment.TRAILING,javax.swing.GroupLayout.DEFAULT_SIZE,Short.MAX_VALUE)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(91,91,91)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jTextField1,javax.swing.GroupLayout.PREFERRED_SIZE,402,javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2,280,javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(130,130,130)
.addComponent(peurcentage,50,javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jTextField1,37,javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,Short.MAX_VALUE)
.addComponent(jLabel2,215,javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(peurcentage,javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(25,25,25)
.addComponent(process_download,26,javax.swing.GroupLayout.PREFERRED_SIZE))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1,Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1,Short.MAX_VALUE)
);
pack();
}// </editor-fold>
private void peurcentageActionPerformed(java.awt.event.ActionEvent evt) {
// Todo add your handling code here:
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
PAge_principale mypage = new PAge_principale();
mypage.setVisible(true);
try{
for(int i=0;i<=100;i++){
Thread.sleep(40);
mypage.process_download.setValue(i);
mypage.peurcentage.setText(Integer.toString(i)+"%");
}
}catch(Exception e){
}
new Login_page().setVisible(true);
mypage.dispose();
/* 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()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(PAge_principale.class.getName()).log(java.util.logging.Level.SEVERE,null,ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(PAge_principale.class.getName()).log(java.util.logging.Level.SEVERE,ex);
} catch (illegalaccessexception ex) {
java.util.logging.Logger.getLogger(PAge_principale.class.getName()).log(java.util.logging.Level.SEVERE,ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(PAge_principale.class.getName()).log(java.util.logging.Level.SEVERE,ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokelater(new Runnable() {
public void run() {
//eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeerrrrrrrrrrrrroooooooooooooooorrrrrrrrrrrrrrrrrrrrr
}
});
}
// Variables declaration - do not modify
private javax.swing.JLabel jLabel2;
private javax.swing.JPanel jPanel1;
private javax.swing.JTextField jTextField1;
private javax.swing.JTextField peurcentage;
private javax.swing.JProgressBar process_download;
// End of variables declaration
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。