Olá, estou com 2 probleminhas pequenos aqui:
package tests;
import javax.swing.*;
import java.awt.*;
public class MapFrame extends JFrame {
private ImageIcon empty = new ImageIcon( "resources\emptysquare.gif" );
private ImageIcon red = new ImageIcon( "resources\redsquare.gif" );
private Tile[][] tiles = new Tile[6][6];
{
this.setSize( 6 * 64 , 6 * 64 );
this.setResizable( false );
for ( int x = 0 ; x < 6 ; x++ ){
for ( int y = 0 ; y < 6 ; y++ ){
if ( x == 0 && y == 0 )
tiles[x][y] = new Tile( false );
else
tiles[x][y] = new Tile( true );
}
}
}
public MapFrame( String title ){
super( title );
}
@Override
public void paint( Graphics g ){
super.paint(g);
for ( int x = 0 ; x < 6 ; x++ ){
for ( int y = 0 ; y < 6 ; y++ ){
tiles[x][y].getIcon().paintIcon(this, g, x * 64, y * 64);
}
}
}
public class Tile{
private boolean empty;
public Tile( boolean empty ){
this.empty = empty;
}
public ImageIcon getIcon(){
return this.empty ? MapFrame.this.empty : red;
}
}
}
package tests;
import javax.swing.*;
public class GUITest {
public static void main ( String args[] ){
JFrame map = new MapFrame( "Title" );
map.setVisible( true );
}
}
em que o archivo emptysquare é um gif 64x64 em branco, e o redsquare é um gif 64x64 vermelho…
Isso era pra aparecer um quadrado vermelho no começo e depois o resto branco… Enquanto isso era um JApplet funcionava bem, assim que fiz virar JFrame dá dois problemas:
- Primeiro o quadrado vermelho vira um retângulo ( Distorce )
- Segundo se vc mudar de tela, a parte do JFrame que ficou escondida atras de outra janela fica cinza. Quando ela ta cinza se vc minimiza e maximiza denovo ela volta ao normal.
pq?
vlw abraços[]`s