java - Nothing appears when I try to create a JFrame. (JButtons, JMenuBar etc.) -
I am working on a pathfinder program which uses GUI. I try to run the program before adding some things. And all this showed up fine. But after doing some more work on it, stopped showing the buttons and menu bar.
Here is the code. Some variable names are also in Swedish, but I hope this will not be an issue. (Please note that the program has expired.) Thanks in advance!
import java.util. *; Import javax.swing *; Import java.awt. *; Import java.awt.event. *; Import java.io.file; Public Square Pathfinder Provides JFrame {Jebton Hitta VG, Visa F.B.Bendails, Annaplets, NAFA, BBindles, NAFARFAURBandelse; JMURbar manibar; Jemanuitam NA, Eslutah, Hitovi Manami, Visa, frontbindelsemeni, naplatsmeni, NAFAURbindelsemeni, ÃndndraFàbindelsememeni; String str = System.getProperty ("user.dir"); JFileChooser jfc; BuildPlan Build = Null; Pathfinder () {Super ("Pathfinder"); Set layout (new border layout ()); Setisse (590, 400); SetDefaultCloseOperation (EXIT_ON_CLOSE); SetLocationRelativeTo (zero); SetVisible (true); Jfc = new JFileChooser ("."); Zeppelin Naura = new zeppel (); Junk (Nora, "Nora"); Jebton Hittagweg = new pocket ("Hitta Vieg"); Jebton VISA FARbindels = New Jebton ("Visa Farbindelse"); Jebton Newplate = New Jebton ("New Plats"); Jebton NFRBindelse = New Payton ("Night Fearbundles"); Jebtone ÃndndraFà ¶rbindelse = new pocket ("a ?? nder förbindelse"); Norra.add (hittaVÃgg); Norra.add (visaFörbindelse); Norra.add (nyPlats); Norra.add (nyFörbindelse); Norra.add (ändraFörbindelse); Hittavig.Aduction Listener (new Hitlallis ()); Visa FAWBandelsSeduction Listener (new visa) ()); NyPlats.addActionListener (New NyPlatsLyss ()); NyFöRbindelse.addActionListener (New NyFöRbindelseLyss ()); ÃndndraFöRbindelse.addActionListener (New NyFöRbindelseLyss ()); Jmurbar menubar = new jmur (); SetJMenuBar (menyBar); JMNU Active Manny = New JMNU ("Archive"); Jameson OperatorName = New JMNU ("Operator"); MenyBar.add (arkivMeny); MenyBar.add (operationerMeny); Jenemitum ny = new jemanuitime ("new"); Jenmenit avsluta = new gemenuitum ("esluta"); ArkivMeny.add (NY); ArkivMeny.add (avsluta); Ny.addActionListener (New NyLyss ()); Avsluta.addActionListener (new avascularis); Jemanuitam Hittavinamani = New Gemmannite ("Hitta Vieg"); Jemanuitam Visa Faeubindelselmany = New Gemmenitum ("Visa Farbindelse"); Jemanuitam nyPlatsMeny = new gemenuitem ("new plates"); Jemanuitam NFAURbandelmsmani = new gemenuitem ("Night Fearbindel"); Jenemitum ändraFà ¶rbindelseMeny = new jemanuitem ("a ?? centre agobendale"); OperationerMeny.add (hittaVÃgMeny); OperationerMeny.add (visaFörbindelseMeny); OperationerMyy.add (nyPlatsMeny); OperationerMeny.add (nyFörbindelseMeny); OperationerMeny.add (ändraFörbindelseMeny); Hittavig.Aduction Listener (new Hitlallis ()); Visa FAWBandelsSeduction Listener (new visa) ()); NyPlats.addActionListener (New NyPlatsLyss ()); NyFöRbindelse.addActionListener (New NyFöRbindelseLyss ()); ÃndndraFöRbindelse.addActionListener (New ÃÆ'à ¢ â,¬Å¡Ãƒâ € šÃ, ¢)} Implemented the Class Hitlerx Executioner (Public Zero Functionality) implementation (ActionAge Away) {}} class VisaLyss ActionListener {public Zero Action Action (Action Avent Away) {}} Implementation of Class NyPlatsLyss ActionListener {Public Zero Action Functional (ActionEvent ave) {}} class NyFöRbindelseLyss ActionListener {Zero Zero Action Action (A Snavent Ave.) {}} class ÃÆ'à ¢ â, ¬ Å ¡Ãƒâ € SA, à ¢, ÃÆ'à ¢ â, ¬ Å ¡Ãƒâ € SA, à ¢, .showOpenDialog (Pathfinder.this); If (svar == JFileChooser.APPROVE_OPTION) {file f = jfc.getSelectedFile (); String filename = F.etabolsection path (); If (build! = Null) remove (build); Bild = new BildPanel (filnam); Joint (Bild, BorderLayout.CENTER); Valid (); Repaint (); Pack (); }}} Class AvslutaLyss implementation ActionListener {Public Zero Functionality (ActionEvent ave) {}} Public Static Zero Main (string [] args) {new pathfinder (); }}
One of the issues is IllegalArgumentException at line Add (Nora, "Norra"); The layout of the content pane of the frame is set to border layout , but this layout does not understand the "norra" constraint. See for more details and examples. In addition, after you have added and started all code, you should call setVisible .
Comments
Post a Comment