java - JLabel background image... weird behaviour? -
I have an image in which to create 8x8 grid, so this is the background of the board.
I am told that it is possible to use this image Incon and JLABB, which I tried to do and it does not work.
- This does not allow me to add components
- In addition to when the program is running and I click on a square - it disappears, Not because it is considered background.
-
Here is the code:
for
(int i = 0; i <8; i ++) {for (Int j = 0; j & lt; 8; j ++) {class = new jlab (); Square.setIcon (icon); Chess (category); }}
Full code:
Am I doing something wrong with this background image?
Any help would be appreciated, thanks in advance.
Are you looking for something like that?
import java.awt *. Import javax.swing *; Public class chisboord jepframe (personal jepineal panel; public chisboord () {panel = new zpn (); Panel.setLayout (new grid layout (8, 8, 0, 0)) // Create board // Add for JLLLs ( Int i = 0; i <47; i ++) {jlabel label = new jlab (); Label.setIcon (getClass (.) GetResource ("picture / face .png")); panel Add (label);} Add the // panel to JFrame. Add (panel); this.pack (); this.setVisible (right); this.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);} Public static zero main (string [] Args) {try {UIManager.setLookAndFeel (UI Manager.getSystemLookAndFeelClassName ());} Hold (Exception e) {e.printStackTrace ();} Java.awt.EventQueue.invokeLater (New Runnabel) {@Override Public Zero () (New Chasboord (;)}}; }}
Comments
Post a Comment