java - GUI doesn't display the background i set for it(compiles) -


I am trying to create a GUI to make a game, this game is irrelevant.

According to me, what I should do is show me a GUI, with one frame, however, only shows the frame, the image is not found anywhere: (

Does anyone tell me Could I have done wrong? Thank you for your time! javax.swing.jframe; import javax.swing.jpanel; import javax.swing.ImageIcon; import javax.swing.JLabel ; Import Javax.swing. *; Import java.awt.BorderLayout; import java.awt. *; Public class graph {int maxX, maxY; personal jframe frame; graph () {dimension screenSize = toolkit.getDefaultToolkit (). GetScreenSize (); MaxX = screenSize.width; maxY = screenSize.height; frame = new JFrame ("My application"); Frame.Set default close operation (JFrame.EXIT_ON_CLOSE); Frame.Set Size (Max, Max); Frame.Setlines SerialTit (Empty); JLabel label = new jlab (icon), zpnic panel = new zpinal (new border layout); panel.ed (la bell, border layout.c.ca); frame.add (panel, BorderLayout.CENTER); frame.setVisible (true);} public string (g) {return.getClass (). GetProtectionDomain (). GetCodeSource () GetLocation (). GetPath () ReplaceAll ("20", ""); } Public static zero major (string algos []) {SwingUtilities.invokeLater (new runall) {@Override Public run zero () {GraphG = new graph ();}}); }}

This example shows you the correct order in which you want to perform operations . In addition, the SwingUtilities.invokeLater () method should start a swing application. It uses EDT, which you can read, another note is that you set the size of the frame, but when it shows that it is too small, the reason is that you have created the frame.pack ( ) , which will ensure that only the location you really need is used.

  import java.awt.BorderLayout; Import javax.swing.JFrame; Import javax.swing.JLabel; Import javax.swing.JPanel; Public class graph {JFrame frame; Public Graph () {frames = new JFrame ("My Applications"); Frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); Frame.setSize (1366770); Frame.setLocationRelativeTo (zero); JAlabelLabel = New JLab ("Some Labels"); Jpegel panel = new zpinal (new border layout ()); Panel.ed (label, border layout.ca); frame.add (panel, BorderLayout.CENTER); Frame.pack (); Frame.setVisible (true); } Public static zero major (string algos []) {SwingUtilities.invokeLater (new runall) {@Override Public run zero () {GraphG = new graph ();}}); }}    

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -