لماذا ظهرت النتيجة أسفل؟
المدخلات والمخرجات باستخدام JOptionPane
لم يظهر المربع الثالث، فقط هذا النص
Exception in thread “main” java.lang.RuntimeException: JOptionPane: parentComponent does not have a valid parent
at javax.swing.JOptionPane.createInternalFrame(JOptionPane.java:1510)
at javax.swing.JOptionPane.showInternalOptionDialog(JOptionPane.java:1286)
at javax.swing.JOptionPane.showInternalMessageDialog(JOptionPane.java:1099)
at javax.swing.JOptionPane.showInternalMessageDialog(JOptionPane.java:1073)
at Addition.main(Addition.java:14)
Process finished with exit code 1
يبدو ان المشكلة في
showInternalMessageDialog
يمكنك قراءة معلومات تساعدك على حل المشكلة والاستخدام الصحيح لها من الروابط:
BarmejFrame.JAVA
package com.company;
import javax.swing.;
import java.awt.;
public class BarmejFrame extends JFrame {
private JLabel titlelabel;
private JLabel imagelabel;
public BarmejFrame() {
super("برمج");
setLayout(new FlowLayout());
titlelabel= new JLabel("مسار تعلم لغة الجافا");
add(titlelabel);
}
}
MainClass.JAVA
package com.company;
import javax.swing.*;
public class MainClass {
public static void main(String[] args) {
BarmejFrame barmejFrame= new BarmejFrame();
barmejFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
barmejFrame.setSize(250,150);
barmejFrame.setVisible(true);
barmejFrame.setLocationRelativeTo(null);
}
}
بعد الضغط على زر الكود:
“C:\Program Files\Java\jdk1.8.0_161\bin\java” “-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2017.3.4\lib\idea_rt.jar=53141:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2017.3.4\bin” -Dfile.encoding=UTF-8 -classpath “C:\Program Files\Java\jdk1.8.0_161\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_161\jre\lib\rt.jar;C:\Users\logo\IdeaProjects\GUI\out\production\untitled104” Addition
3
Exception in thread “main” java.lang.RuntimeException: JOptionPane: parentComponent does not have a valid parent
at javax.swing.JOptionPane.createInternalFrame(JOptionPane.java:1510)
at javax.swing.JOptionPane.showInternalOptionDialog(JOptionPane.java:1286)
at javax.swing.JOptionPane.showInternalMessageDialog(JOptionPane.java:1099)
at javax.swing.JOptionPane.showInternalMessageDialog(JOptionPane.java:1073)
at Addition.main(Addition.java:14)
Process finished with exit code 1
package com.company;
import javax.swing.;
import java.awt.;
public class BarmejFrame extends JFrame {
private JLabel titlelabel;
private JLabel imagelabel;
public BarmejFrame() {
super("برمج");
setLayout(new FlowLayout());
titlelabel= new JLabel("مسار تعلم لغة الجافا");
add(titlelabel);
Icon image= new ImageIcon(getClass().getResource("img/Chrysanthemum.jpg"));
imagelabel= new JLabel();
imagelabel.setIcon(image);
add(imagelabel);
}
}
تم نقل استفسارك للقسم المختص وسيتم التحقق والرد عليك بأقرب وقت ممكن