Graphics bug on Win and Linux ?
Hi all,I have a graphic problem. I have created a JFrame and I have added him a JPanel (1) that it has as Layout a BorderLayout. To this JPanel (1) I have added another JPanel (2) that it has as Layout a GridLayout and a JLabel that I have used as StatusBar.
The problem is that when a window overlaps to the JPanel (1), the JPanel (2) is visualized to the initial state in which it had been created.After click on it returns to the actual state.
I post you an image to make to understand better me.
http://img176.imageshack.us/my.php?image=screenji3.gif
Someone know how i can resolve this problem?
Ps: sorry for my bad English.
Message was edited by:
JinKazama
I have forgotten to say that use Java5
package it.unibo.cs.CSameGame;
import javax.swing.JFrame;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import javax.swing.ButtonGroup;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JFileChooser;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JMenuBar;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.JTextField;
import javax.swing.JComboBox;
import javax.swing.JButton;
import javax.swing.KeyStroke;
import javax.swing.UIManager;
import java.awt.BorderLayout;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.awt.GridLayout;
import java.awt.Insets;
import java.io.IOException;
import java.net.URL;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import javax.swing.JCheckBox;
import java.awt.Toolkit;
* @author Paolino Carmine
* @author Statuto Riccardo
public class Swingui {
private JFrame FinestraPrincipale = null; // @jve:decl-index=0:visual-constraint="576,53"
private JMenuBar BarraMenu = null;
private JMenu Gioco = null;
private JMenuItem NuovoGioco = null;
private JMenu Impostazioni = null;
private JMenu Aiuto = null;
private JMenuItem About = null;
private JMenuItem Help = null;
private JMenuItem Esci = null;
private JMenuItem CaricaMappa = null;
private JMenuItem SalvaMappa = null;
private JMenuItem Settings = null;
private JFrame Preferenze = null; // @jve:decl-index=0:visual-constraint="10,10"
private JLabel L_lbl = null;
private JTextField L_txt = null;
private JLabel H_lbl = null;
private JTextField H_txt = null;
private JLabel N_lbl = null;
private JTextField N_txt = null;
private JLabel Stile_lbl = null;
private JComboBox Stile_cbox = null;
private JButton Salva_btn = null;
private static Game game; // @jve:decl-index=0:
private int l;
private int h;
private int n;
private int style;
private JPanel PrefContentPane = null;
private JPanel ContentPanePrincipale = null;
private JLabel StatusBarLabel = null;
private URL imageURL;
private ImageIcon image;
private JLabel piece;
private JLabel Player_lbl = null;
private JTextField Player_txt = null;
private String player;
private JMenu MenuTemi = null;
private JRadioButtonMenuItem Standard = null;
private JRadioButtonMenuItem Futurama = null;
private String tema = "base";
private JCheckBox NewGameAfterWinCB = null;
private JRadioButtonMenuItem KillBill = null;
private JPanel MainPanel = null;
private GridLayout LayoutGriglia;
private ArrayList<String> listaTipi = new ArrayList<String>();
private boolean flag;
* This method initializes FinestraPrincipale
* @return javax.swing.JFrame
private JFrame getFinestraPrincipale() {
if (FinestraPrincipale == null) {
try {
FinestraPrincipale = new JFrame();
FinestraPrincipale.setSize(new Dimension(374, 294)); // Generated
FinestraPrincipale.setTitle("CSameGame"); // Generated
FinestraPrincipale.setResizable(false);
FinestraPrincipale
.setIconImage(Toolkit
.getDefaultToolkit()
.getImage(
getClass()
.getResource(
"/it/unibo/cs/CSameGame/icons/face-surprise.png")));
FinestraPrincipale.setJMenuBar(getBarraMenu()); // Generated
FinestraPrincipale.setContentPane(getMainPanel()); // Generated
FinestraPrincipale
.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
} catch (java.lang.Throwable e) {
// TODO: Something
return FinestraPrincipale;
* This method initializes BarraMenu
* @return javax.swing.JMenuBar
private JMenuBar getBarraMenu() {
if (BarraMenu == null) {
try {
BarraMenu = new JMenuBar();
BarraMenu.add(getGioco()); // Generated
BarraMenu.add(getImpostazioni()); // Generated
BarraMenu.add(getAiuto()); // Generated
} catch (java.lang.Throwable e) {
// TODO: Something
return BarraMenu;
* This method initializes Gioco
* @return javax.swing.JMenu
private JMenu getGioco() {
if (Gioco == null) {
try {
Gioco = new JMenu();
Gioco.setText("Gioco"); // Generated
Gioco.setMnemonic(KeyEvent.VK_G);
Gioco.add(getNuovoGioco()); // Generated
Gioco.addSeparator();
Gioco.add(getCaricaMappa()); // Generated
Gioco.add(getSalvaMappa()); // Generated
Gioco.addSeparator();
Gioco.add(getEsci()); // Generated
} catch (java.lang.Throwable e) {
// TODO: Something
return Gioco;
* This method initializes NuovoGioco
* @return javax.swing.JMenuItem
private JMenuItem getNuovoGioco() {
if (NuovoGioco == null) {
try {
URL iconURL = getClass().getResource("icons/new.png");
Icon icon = new ImageIcon(iconURL);
NuovoGioco = new JMenuItem("Nuovo gioco", icon);
NuovoGioco.setMnemonic(KeyEvent.VK_N);
NuovoGioco.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N,
ActionEvent.CTRL_MASK));
NuovoGioco.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
flag=true;
newGame();
} catch (java.lang.Throwable e) {
// TODO: Something
return NuovoGioco;
* This method initializes Impostazioni
* @return javax.swing.JMenu
private JMenu getImpostazioni() {
if (Impostazioni == null) {
try {
Impostazioni = new JMenu();
Impostazioni.setText("Impostazioni"); // Generated
Impostazioni.setMnemonic(KeyEvent.VK_I);
Impostazioni.add(getSettings()); // Generated
Impostazioni.add(getMenuTemi());
} catch (java.lang.Throwable e) {
// TODO: Something
return Impostazioni;
* This method initializes Aiuto
* @return javax.swing.JMenu
private JMenu getAiuto() {
if (Aiuto == null) {
try {
Aiuto = new JMenu();
Aiuto.setText("Aiuto"); // Generated
Aiuto.setMnemonic(KeyEvent.VK_A);
Aiuto.add(getAbout()); // Generated
Aiuto.add(getHelp()); // Generated
} catch (java.lang.Throwable e) {
// TODO: Something
return Aiuto;
* This method initializes About
* @return javax.swing.JMenuItem
private JMenuItem getAbout() {
if (About == null) {
try {
About = new JMenuItem();
About.setText("Informazioni su..."); // Generated
About.setMnemonic(KeyEvent.VK_I);
} catch (java.lang.Throwable e) {
// TODO: Something
return About;
* This method initializes Help
* @return javax.swing.JMenuItem
private JMenuItem getHelp() {
if (Help == null) {
try {
URL iconURL = getClass().getResource("icons/help.png");
Icon icon = new ImageIcon(iconURL);
Help = new JMenuItem("Aiuto CSameGame", icon);
Help.setMnemonic(KeyEvent.VK_A);
} catch (java.lang.Throwable e) {
// TODO: Something
return Help;
* This method initializes Esci
* @return javax.swing.JMenuItem
private JMenuItem getEsci() {
if (Esci == null) {
try {
URL iconURL = getClass().getResource("icons/exit.png");
Icon icon = new ImageIcon(iconURL);
Esci = new JMenuItem("Esci", icon);
Esci.setMnemonic(KeyEvent.VK_E);
Esci.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q,
ActionEvent.CTRL_MASK));
Esci.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.exit(0);
} catch (java.lang.Throwable e) {
// TODO: Something
return Esci;
* This method initializes CaricaMappa
* @return javax.swing.JMenuItem
private JMenuItem getCaricaMappa() {
if (CaricaMappa == null) {
try {
URL iconURL = getClass().getResource("icons/open.png");
Icon icon = new ImageIcon(iconURL);
CaricaMappa = new JMenuItem("Carica partita...", icon);
CaricaMappa.setMnemonic(KeyEvent.VK_C);
CaricaMappa.setAccelerator(KeyStroke.getKeyStroke(
KeyEvent.VK_L, ActionEvent.CTRL_MASK));
CaricaMappa.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JFileChooser fc = new JFileChooser();
Filtro txtFiltro = new Filtro();
fc.setFileFilter(txtFiltro);
fc.addChoosableFileFilter(txtFiltro);
int scelta = fc.showOpenDialog(CaricaMappa);
try {
style = Stile_cbox.getSelectedIndex();
player = Player_txt.getText();
} catch (NullPointerException exception) {
player = "Anonimo";
if (scelta == JFileChooser.APPROVE_OPTION) {
try {
game = new Game(fc.getSelectedFile().getPath(),
style);
game.setPlayerName(player);
game.setPlayerScore();
StatusBarLabel.setText("Punteggio attuale: "
+ game.getPlayerScore());
printSurface();
SalvaMappa.setEnabled(true);
} catch (IOException exception) {
exception.printStackTrace();
} catch (StringIndexOutOfBoundsException exception) {
JOptionPane.showMessageDialog(null,
"Il file della mappa � corrotto",
"Aiaiai...", JOptionPane.ERROR_MESSAGE);
} catch (NoSuchAlgorithmException exception) {
JOptionPane.showMessageDialog(null, exception
.toString().split(": ")[1],
"Aiaiai...", JOptionPane.ERROR_MESSAGE);
} catch (SecurityException exception) {
JOptionPane.showMessageDialog(null, exception
.toString().split(": ")[1],
"Aiaiai...", JOptionPane.ERROR_MESSAGE);
} catch (java.lang.Throwable e) {
// TODO: Something
return CaricaMappa;
* This method initializes SalvaMappa
* @return javax.swing.JMenuItem
private JMenuItem getSalvaMappa() {
if (SalvaMappa == null) {
try {
URL iconURL = getClass().getResource("icons/save.png");
Icon icon = new ImageIcon(iconURL);
SalvaMappa = new JMenuItem("Salva partita...", icon);
SalvaMappa.setMnemonic(KeyEvent.VK_S);
SalvaMappa.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,
ActionEvent.CTRL_MASK));
SalvaMappa.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JFileChooser fc = new JFileChooser();
Filtro txtFiltro = new Filtro();
fc.setFileFilter(txtFiltro);
fc.addChoosableFileFilter(txtFiltro);
int scelta = fc.showSaveDialog(SalvaMappa);
SurfaceParser map = new SurfaceParser("");
if (scelta == JFileChooser.APPROVE_OPTION) {
try {
map.saveMap(fc.getSelectedFile().getPath(),
game.getSurface(), game.getH(), game
.getL(), game.getPlayerScore(),
style);
} catch (IOException exception) {
exception.printStackTrace();
} catch (NoSuchAlgorithmException exception) {
JOptionPane.showMessageDialog(null, exception
.toString().split(": ")[1],
"Aiaiai...", JOptionPane.ERROR_MESSAGE);
} catch (java.lang.Throwable e) {
// TODO: Something
return SalvaMappa;
* This method initializes Settings
* @return javax.swing.JMenuItem
private JMenuItem getSettings() {
if (Settings == null) {
try {
URL iconURL = getClass().getResource("icons/preferences.png");
Icon icon = new ImageIcon(iconURL);
Settings = new JMenuItem("Preferenze", icon);
Settings.setMnemonic(KeyEvent.VK_P);
Settings.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P,
ActionEvent.CTRL_MASK));
Settings.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JFrame Preferenze = getPreferenze();
Preferenze.setVisible(true);
} catch (java.lang.Throwable e) {
// TODO: Something
return Settings;
* This method initializes jTable
* @return javax.swing.JTable
* This method initializes Preferenze
* @return javax.swing.JFrame
private JFrame getPreferenze() {
if (Preferenze == null) {
Preferenze = new JFrame("Preferenze");
Preferenze.setSize(new Dimension(530, 250));
Preferenze.setResizable(false); // Generated
Preferenze.setContentPane(getJContentPane()); // Generated
return Preferenze;
* This method initializes L_txt
* @return javax.swing.JTextField
private JTextField getL_txt() {
if (L_txt == null) {
L_txt = new JTextField("15");
return L_txt;
* This method initializes H_txt
* @return javax.swing.JTextField
private JTextField getH_txt() {
if (H_txt == null) {
H_txt = new JTextField("10");
return H_txt;
* This method initializes N_txt
* @return javax.swing.JTextField
private JTextField getN_txt() {
if (N_txt == null) {
N_txt = new JTextField("3");
return N_txt;
* This method initializes Stile_cbox
* @return javax.swing.JComboBox
private JComboBox getStile_cbox() {
if (Stile_cbox == null) {
String[] style = { "Standard", "Continous", "Megashift", "Shifter" };
Stile_cbox = new JComboBox(style);
return Stile_cbox;
* This method initializes Salva_btn
* @return javax.swing.JButton
private JButton getSalva_btn() {
if (Salva_btn == null) {
Salva_btn = new JButton();
Salva_btn.setText("Salva");
Salva_btn.addActionListener(new ActionListener() {
private Game fakegame;
public void actionPerformed(ActionEvent e) {
Preferenze.setVisible(false);
try {
l = Integer.parseInt(L_txt.getText());
h = Integer.parseInt(H_txt.getText());
n = Integer.parseInt(N_txt.getText());
style = Stile_cbox.getSelectedIndex();
player = Player_txt.getText();
fakegame = new Game(l, h, n, style);
fakegame.setPlayerName(player);
} catch (Exception expt) {
JOptionPane.showMessageDialog(null, expt.toString()
.split(": ")[1], "Aiaiai...",
JOptionPane.ERROR_MESSAGE);
getPreferenze();
Preferenze.setVisible(true);
return Salva_btn;
* This method initializes jContentPane
* @return javax.swing.JPanel
private JPanel getJContentPane() {
if (PrefContentPane == null) {
try {
GridBagConstraints gridBagConstraints32 = new GridBagConstraints();
gridBagConstraints32.gridx = 0;
gridBagConstraints32.gridy = 5;
Player_lbl = new JLabel();
Player_lbl.setText("Nome giocatore");
Stile_lbl = new JLabel();
Stile_lbl.setText("Stile di gioco");
N_lbl = new JLabel();
N_lbl.setText("Numero di tipi di pedine");
H_lbl = new JLabel();
H_lbl.setText("Altezza griglia");
L_lbl = new JLabel();
L_lbl.setText("Larghezza griglia");
GridBagConstraints gridBagConstraints41 = new GridBagConstraints();
gridBagConstraints41.insets = new Insets(35, 10, 2, 10);
gridBagConstraints41.fill = GridBagConstraints.NONE;
gridBagConstraints41.gridy = 0;
gridBagConstraints41.weightx = 1.0;
gridBagConstraints41.anchor = GridBagConstraints.SOUTH;
gridBagConstraints41.gridx = 1;
gridBagConstraints41.ipadx = 90;
GridBagConstraints gridBagConstraints31 = new GridBagConstraints();
gridBagConstraints31.insets = new Insets(5, 10, 5, 10);
gridBagConstraints31.gridx = 0;
gridBagConstraints31.fill = GridBagConstraints.HORIZONTAL;
gridBagConstraints31.anchor = GridBagConstraints.SOUTHWEST;
gridBagConstraints31.gridy = 0;
GridBagConstraints gridBagConstraints6 = new GridBagConstraints();
gridBagConstraints6.fill = GridBagConstraints.VERTICAL; // Generated
gridBagConstraints6.gridx = 1; // Generated
gridBagConstraints6.gridy = 4; // Generated
gridBagConstraints6.weightx = 1.0; // Generated
GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
gridBagConstraints5.gridx = 1; // Generated
gridBagConstraints5.anchor = GridBagConstraints.EAST; // Generated
gridBagConstraints5.ipadx = 0; // Generated
gridBagConstraints5.insets = new Insets(15, 0, 35, 20); // Generated
gridBagConstraints5.fill = GridBagConstraints.NONE; // Generated
gridBagConstraints5.gridy = 7; // Generated
GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
gridBagConstraints4.gridx = 0; // Generated
gridBagConstraints4.anchor = GridBagConstraints.WEST; // Generated
gridBagConstraints4.insets = new Insets(5, 10, 5, 10); // Generated
gridBagConstraints4.fill = GridBagConstraints.HORIZONTAL; // Generated
gridBagConstraints4.gridy = 4; // Generated
GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
gridBagConstraints3.fill = GridBagConstraints.NONE; // Generated
gridBagConstraints3.gridy = 3; // Generated
gridBagConstraints3.weightx = 1.0; // Generated
gridBagConstraints3.insets = new Insets(2, 10, 2, 10); // Generated
gridBagConstraints3.ipadx = 90; // Generated
gridBagConstraints3.anchor = GridBagConstraints.CENTER; // Generated
gridBagConstraints3.gridx = 1; // Generated
GridBagConstraints gridBagConstraints21 = new GridBagConstraints();
gridBagConstraints21.gridx = 0; // Generated
gridBagConstraints21.anchor = GridBagConstraints.WEST; // Generated
gridBagConstraints21.insets = new Insets(5, 10, 5, 10); // Generated
gridBagConstraints21.fill = GridBagConstraints.BOTH; // Generated
gridBagConstraints21.gridy = 3; // Generated
GridBagConstraints gridBagConstraints11 = new GridBagConstraints();
gridBagConstraints11.fill = GridBagConstraints.NONE; // Generated
gridBagConstraints11.gridy = 2; // Generated
gridBagConstraints11.weightx = 1.0; // Generated
gridBagConstraints11.insets = new Insets(2, 10, 2, 10); // Generated
gridBagConstraints11.ipadx = 90; // Generated
gridBagConstraints11.anchor = GridBagConstraints.CENTER; // Generated
gridBagConstraints11.gridx = 1; // Generated
GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
gridBagConstraints2.gridx = 0; // Generated
gridBagConstraints2.insets = new Insets(5, 10, 5, 10); // Generated
gridBagConstraints2.fill = GridBagConstraints.BOTH; // Generated
gridBagConstraints2.gridy = 2; // Generated
GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
gridBagConstraints1.fill = GridBagConstraints.NONE; // Generated
gridBagConstraints1.gridy = 1; // Generated
gridBagConstraints1.weightx = 1.0; // Generated
gridBagConstraints1.gridheight = 1; // Generated
gridBagConstraints1.insets = new Insets(2, 10, 2, 10); // Generated
gridBagConstraints1.ipadx = 90; // Generated
gridBagConstraints1.anchor = GridBagConstraints.SOUTH; // Generated
gridBagConstraints1.gridx = 1; // Generated
GridBagConstraints gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridx = 0; // Generated
gridBagConstraints.anchor = GridBagConstraints.SOUTH; // Generated
gridBagConstraints.gridheight = 1; // Generated
gridBagConstraints.ipadx = 0; // Generated
gridBagConstraints.insets = new Insets(0, 10, 5, 10); // Generated
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; // Generated
gridBagConstraints.ipady = 0; // Generated
gridBagConstraints.gridwidth = 1; // Generated
gridBagConstraints.gridy = 1; // Generated
PrefContentPane = new JPanel();
PrefContentPane.setLayout(new GridBagLayout()); // Generated
PrefContentPane.add(L_lbl, gridBagConstraints);
PrefContentPane.add(getL_txt(), gridBagConstraints1);
PrefContentPane.add(H_lbl, gridBagConstraints2);
PrefContentPane.add(getH_txt(), gridBagConstraints11);
PrefContentPane.add(N_lbl, gridBagConstraints21);
PrefContentPane.add(getN_txt(), gridBagConstraints3);
PrefContentPane.add(Stile_lbl, gridBagConstraints4);
PrefContentPane.add(getSalva_btn(), gridBagConstraints5);
PrefContentPane.add(getStile_cbox(), gridBagConstraints6);
PrefContentPane.add(Player_lbl, gridBagConstraints31);
PrefContentPane.add(getPlayer_txt(), gridBagConstraints41);
PrefContentPane.add(getNewGameAfterWinCB(),
gridBagConstraints32);
} catch (java.lang.Throwable e) {
// TODO: Something
return PrefContentPane;
* This method initializes Player_txt
* @return javax.swing.JTextField
private JTextField getPlayer_txt() {
if (Player_txt == null) {
Player_txt = new JTextField("Anonimo");
return Player_txt;
* This method initializes MenuTemi
* @return javax.swing.JMenu
private JMenu getMenuTemi() {
if (MenuTemi == null) {
MenuTemi = new JMenu();
MenuTemi.setText("Cambia tema");
ButtonGroup group = new ButtonGroup();
MenuTemi.add(getStandard());
group.add(Standard);
MenuTemi.add(getFuturama());
group.add(Futurama);
MenuTemi.add(getKillBill());
group.add(KillBill);
return MenuTemi;
* This method initializes Standard
* @return javax.swing.JMenuItem
private JRadioButtonMenuItem getStandard() {
if (Standard == null) {
Standard = new JRadioButtonMenuItem("Base", true);
Standard.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
tema = "base";
if (game != null){
createLista();
printSurface();
return Standard;
* This method initializes Futurama
* @return javax.swing.JMenuItem
private JRadioButtonMenuItem getFuturama() {
if (Futurama == null) {
Futurama = new JRadioButtonMenuItem("Futurama");
Futurama.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
tema = "futurama";
if (game != null){
createLista();
printSurface();
return Futurama;
* This method initializes NewGameAfterWinCB
* @return javax.swing.JCheckBox
private JCheckBox getNewGameAfterWinCB() {
if (NewGameAfterWinCB == null) {
NewGameAfterWinCB = new JCheckBox(
"Inizia automaticamente un nuovo gioco alla fine della partita",
true);
return NewGameAfterWinCB;
* This method initializes KillBill
* @return javax.swing.JRadioButtonMenuItem
private JRadioButtonMenuItem getKillBill() {
if (KillBill == null) {
KillBill = new JRadioButtonMenuItem("Kill Bill");
KillBill.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
tema = "killbill";
if (game != null){
createLista();
printSurface();
return KillBill;
* This method initializes MainPanel
* @return javax.swing.JPanel
private JPanel getMainPanel() {
if (MainPanel == null) {
try {
StatusBarLabel = new JLabel();
StatusBarLabel.setText("Avvia un nuovo gioco!"); // Generated
MainPanel = new JPanel();
MainPanel.setLayout(new BorderLayout()); // Generated
MainPanel.add(StatusBarLabel, BorderLayout.SOUTH); // Generated
} catch (java.lang.Throwable e) {
// TODO: Something
return MainPanel;
public static void main(String[] args) {
try {
// Set System L&F
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
e.printStackTrace();
new Swingui();
private Swingui() {
JFrame FinestraPrincipale = getFinestraPrincipale();
FinestraPrincipale.setVisible(true);
SalvaMappa.setEnabled(false);
private void printSurface() {
ContentPanePrincipale = null;
ContentPanePrincipale = new JPanel();
LayoutGriglia = new GridLayout(game.getH(), game.getL());
ContentPanePrincipale.setLayout(LayoutGriglia);
makeMatrice();
MainPanel.add(ContentPanePrincipale, BorderLayout.CENTER);
ContentPanePrincipale
.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
int x = evt.getX() / 38;
int y = (game.getH() - evt.getY() / 38) - 1;
try {
game.move(x, y);
StatusBarLabel.setText("Punteggio attuale: "
+ game.getPlayerScore());
} catch (RuntimeException e) {
StatusBarLabel.setText(e.toString().split(": ")[1]);
printSurface();
if (game.isEnded()) {
StatusBarLabel
.setText("Nessuna mossa disponibile!");
if (game.getPlayerName().equals("Anonimo")
|| game.getPlayerName().equals("")) {
String in = JOptionPane.showInputDialog(
"Inserisci il tuo nome", "Anonimo");
if (in == null || in.equals(""))
in = "Anonimo";
game.setPlayerName(in);
JOptionPane.showMessageDialog(null,
"Complimenti, " + game.getPlayerName()
+ "! Il tuo punteggio �: "
+ game.getPlayerScore(),
"Grande!",
JOptionPane.INFORMATION_MESSAGE);
} else {
JOptionPane.showMessageDialog(null,
"Complimenti, " + game.getPlayerName()
+ "! Il tuo punteggio �: "
+ game.getPlayerScore(),
"Grande!",
JOptionPane.INFORMATION_MESSAGE);
try {
if (NewGameAfterWinCB.isSelected()){
flag=true;
newGame();
else
ContentPanePrincipale.setVisible(false);
} catch (NullPointerException exptz) {
flag=true;
newGame();
FinestraPrincipale.pack();
private void newGame() {
try {
l = Integer.parseInt(L_txt.getText());
h = Integer.parseInt(H_txt.getText());
n = Integer.parseInt(N_txt.getText());
style = Stile_cbox.getSelectedIndex();
player = Player_txt.getText();
} catch (Exception e) {
l = 15;
h = 10;
n = 3;
style = 0;
player = "Anonimo";
try {
game = new Game(l, h, n, style);
game.setPlayerName(player);
} catch (IndexOutOfBoundsException e) {
JOptionPane.showMessageDialog(null, e.toString().split(": ")[1],
"Aiaiai...", JOptionPane.ERROR_MESSAGE);
printSurface();
StatusBarLabel.setText("Punteggio attuale: " + game.getPlayerScore());
SalvaMappa.setEnabled(true);
private void makeMatrice() {
if (flag) {
createLista();
flag = false;
for (int y = game.getH() - 1; y >= 0; y--) {
for (int x = 0; x < game.getL(); x++) {
char type = game.getSurface()[x][y].getType();
imageURL = getClass().getResource(returnPath(type));
image = new ImageIcon(imageURL);
piece = new JLabel(image);
ContentPanePrincipale.add(piece);
private void createLista() {
listaTipi=new ArrayList<String>();
int i = 0;
if (n == 0)
n = 20;
for (int y = game.getH() - 1; y >= 0; y--) {
for (int x = 0; x < game.getL(); x++) {
if (i < n) {
if (game.getSurface()[x][y].getType() != '.') {
if (notInLista(game.getSurface()[x][y].getType())) {
int j = i + 1;
String type = game.getSurface()[x][y].getType()
+ " " + "images/" + tema + "/" + j + ".png";
listaTipi.add(type);
i++;
} else
break;
if (i > n)
break;
private boolean notInLista(char type) {
if (listaTipi == null)
return true;
for (int k = 0; k < listaTipi.size(); k++) {
if (type == listaTipi.get(k).split(" ")[0].charAt(0))
return false;
return true;
private String returnPath(char type) {
for (int k = 0; k < listaTipi.size(); k++) {
if (type == listaTipi.get(k).split(" ")[0].charAt(0)) {
String path = listaTipi.get(k).split(" ")[1];
return path;
return "images/empty.png";
Message was edited by:
JinKazama
On Mac this class work perfectly
Similar Messages
-
IndexOf - difference between Win and Linux encoding
Hello folks, wondering if someone could put me on the right track over this little problem with porting a java app to Linux...
I have a nice little program, developed on (the latest) JDK under windows which reads a custom file format, locates the second occurance of the substring 'PNG', ignores everything before the character before this PNG (hence the -1 below) and saves the remainder, which is now a bog-standard PNG image. The first 'PNG substring always occurs within the first 50 bytes (hence the 50 below) and the second around the 2kB mark. Here's the line that finds the location of the second 'PNG' in the file loaded into strFileContent:
location = strFileContent.indexOf( "PNG", 50 )-1;All is well compiled and run on windows, say file 'test1.xyz' produces a value for location of 2076 and saves a nice PNG called 'test1.png'.
When I haul it over to Linux (Ubuntu 9.04) and lo, location comes out as 1964 for the same file, and of course the file is no-longer a PNG because there are an extra 112 bytes on the front end. Running the windows compile of the code or a fresh Linux compile makes no difference.
I'm suspecting Win and Linux Java count, perhaps, line endings or some such differently, perhaps have to check an encoding. I'd appreciate any pointers on correcting this to work on both platforms (ultimately I'm trying to appease a Mac user, but don't have a Mac to play with at the moment).
Cheers,
K.
Kenphaethon2008 wrote:
I'm suspecting Win and Linux Java count, perhaps, line endings or some such differently, perhaps have to check an encoding. I'd appreciate any pointers on correcting this to work on both platforms (ultimately I'm trying to appease a Mac user, but don't have a Mac to play with at the moment).The immediate cause of your problem is probably that Windows uses a 8bit encoding as the default (probably some ISO-8859-{noformat}*{noformat} variant or the Windows-bastardization of it), while Ubuntu uses UTF-8, which has a varying number of bytes per character.
The much more important underlying problem is that you're trying to treat binary data as if it were text. A PNG image is not text. Handling binary data in Strings (or char[]) is a sure way to invite desaster.
You must convert your code to handle InputStream/OutputStream/byte[] instead of Reader/Writer/String/char[]. -
Fonts in java apps for win and linux
Hi everyone.
i need to build an application mult-plataform, to run in windows and linux...
but i don�t know waht font i must use...the default font that java takes doesn�t exist in linux (dialog)...
waht font should i use in my app??
thanxFor going multi-platform it is easiest to stick to the logical fonts: Fonts named "Serif", "SansSerif", "Monospaced", "Dialog", and "DialogInput".
These fonts are guaranteed to exist on any platform, although their implementations may be different. If you use others then you'll have to figure out how to deal with cross platform issues.
Jeff -
2 Queries for OCCI on WIN and Linux platform
Hi,
I got 2 questions on using OCCI.
1. [Linux] Is it possible to compile OCCI programs on Linux if I am using gcc 3.2?
2. [WIN XP] Recently, I installed the oracle client 10g with OCCI libs installed. I linked my program with ..\oci\lib\msvc\vc6\oraocci10.lib and copied the oraocci10.dll to my project folder so it will be used during execution. I am using VC6++(sp6). I managed to compile without any error. However, my program crashed with a call to createConnection() method. Can anyone help?
Could I be using the wrong DLL? How to check which dll I am using? The program is planned to run on Instant Client on other machines.Hi,
thks for the reply.
no, i only have vc++ 6 installed.
i even tried to create a seperate folder with just the program and all the required dlls.
However, I found a 'sqlnet.log' file in the vc project folder. Why is it using BEQ protocol when it should be TCP? Is the dll using any registry entries instead of running in instant client mode?
Fatal NI connect error 12560, connecting to:
(DESCRIPTION=(ADDRESS=(PROTOCOL=BEQ)(PROGRAM=oracle)(ARGV0=oracleORCL)(ARGS='(DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))'))(CONNECT_DATA=(SID=ORCL)(CID=(PROGRAM=H:\vcproj\trial\desc\Debug\desc.exe)(HOST=xFtfdjkw3)(USER=peter))))
VERSION INFORMATION:
TNS for 32-bit Windows: Version 10.1.0.2.0 - Production
Oracle Bequeath NT Protocol Adapter for 32-bit Windows: Version 10.1.0.2.0 - Production
Time: 27-APR-2004 13:59:54
Tracing not turned on.
Tns error struct:
ns main err code: 12560
TNS-12560: TNS:protocol adapter error
ns secondary err code: 0
nt main err code: 530
TNS-00530: Protocol adapter error
nt secondary err code: 126
nt OS err code: 0 -
Intel 4000 graphics failure both windows and linux on thinkpad edge s430
After 5-30 minutes the screen breaks up in flickering (or just black) and system freezes. I need to turn off computer. After restart the error occurs again quickly.
This occurs regardless if I boot to windows or into a linux bootable dvd.
But
Remote desktop connection to the computer and it works fine for days .
->
Thus I believe it is the intel 4000 graphics that has some hardware failure which is not invoked upon remote desktop.
I wonder if this is a known issue?
I wonder if only a replacement of the intel 4000 graphics will fix this (this probably means replacing the main board entirely?)
Or
If it is in any way likely that it is _only_ because maybe thermal paste between cooler and cpu/graphics is slipping?
Lenovo Thinkpad Edge S430
Intel I7 + Intel HD 4000
No additional graphicsHave you tried setting up the connection manually?
e.g.
/etc/init.d/networkmanager stop
#Unlock wireless devices
rfkill unblock all
#enable interface
ifconfig wlan0 up
#check network visibility
iwlist wlan0 scanning
#configure wifi
iwconfig wlan0 essid <ESSID>
iwconfig tx auto
and then set up wpa_supplicant in case you use WPA2!
#Get ip address
dhclient wlan0
One thing I regularly miss when getting a new wifi device is to add it to the MAC filter list of my router, so check if the MAC address is added there...
W520|4282-W16|2720QM|16GB|Q1000M|FHD|500GB|UMTS|BIOS 1.26|Gentoo Linux/2.6.39-r3|Win7-64-Prof| -
Apple - PLEASE fix the graphical bug with Dock and Stacks! PLEASE!
Using popular Mac games such as Diablo II, Freeverse's Wingnuts, Ambrosia's Aperion, and Blitwise's Super DX-Ball (as well as a LOT more) results in a common graphical glitch with the Dock and stacks, making fan stacks totally useless until I restart my iMac. Killing and relaunching the Dock doesn't fix it. Only restarting my Mac temporarily sorts it out. This is a highly annoying bug most often set off by games that Apple STILL hasn't fixed as of 10.5.3. So I let every developer (who I do not blame, BTW) know whose product results in this bug, in the hope they will apply pressure to Apple. Leopard has been the buggiest release since 10.1 IME and Apple is taking there sweet time about crushing such crippling bugs. Suffice to say it's really ******* me off.
Here is a screenshot from another 24" iMac afflicted by this bug after running a game:
<http://img231.imageshack.us/img231/5324/corrupteddockandmenuletpk1.png>
Notice the open stack is just grey bars. The icons and names are not
showing.
Regards,
Jamie Kahn GenetHi Wizardling
These forums are User to User technical forums Apple employees do not often read these forums. You can do 1 of two things.
1. Send feedback to Apple via http://www.apple.com/feedback or
2. Sign up for a free developer account and open a bug report with Apple through http://bugreporter.apple.com
Hope this helps
J.C -
Resource for BO on Win and Linux
Hi,
I have a BusinessObjects project. Can you give me requirements resource for BO on Linux and Window??
Thanks
DuypmHi Duypm,
go to below
http://help.sap.com/
and SAP BusinessObjects -> All Products
you will get all the BO product giudes
Thanks,
Praveen. -
Absolute paths (win and linux)
hy
is there a solution to write absolute paths independent of operating system?
I mean e.g. in windows instead of y:\\folder\file.name maybe y//folder/file.name?
the methods in class File only give me \\ (fileSeparator) and ; (pathSeparator)
(using java 1.4)
big thx
cheersAbsolute paths, by their very nature, are platform-specific, so, no. For instance, what's the platform-independent way of referring to D:\ ? There isn't one, because not all platforms, and indeed not all installations of any platform, have a D: drive. The path " y//folder/file.name" makes no sense
java.io.File.listRoots() returns an array of File objects representing the root volumes for your machine. For instance, it might return C:\, D:\, E:\ on your Windows box. That might be of some use to you. Or better yet, avoid absolute paths altogether, if you can. -
Preferences under the user home in win and linux
hi,
how can i save my looger-file under the user home and not in the registry usw.? under my user home in windows i see lots of .PROGRAMNAME directorys! is there any class for using that?Preferences or log files? Your title says "preferences" and your text says "looger" (which I'm assuming is just a typo).
If you want to store user-specific data (aka preferences), then use the new java.util.preferences classes and use the user context.
If you want to store files (like log files) in the user's directory, then use the System property DrClap suggested to get the directory name. -
Hello!
I'm getting graphic corruption with 3D games on my Arch Linux configuration using Wine and Catalyst. Tried World of Warcraft (also with opengl rendering) and Guild Wars - graphics look stretched and teared.
Using ATI Mobility Radeon HD4570.
Any ideas? Thanks in advance.
Last edited by CHPE (2011-01-02 17:37:11)I get same problem with guildwars in fullscreen when entering character select. I have to ctrl-alt-F1 to tty then back to get rid of the garbled graphics. Then my characters vanishes except for their armor/effects. Going into windowed mode stops the garbling of the graphics but the bodyless avatars remain. There is one error stands out in wine output but can't find anything specific to this error that helps.
fixme:actctx:parse_depend_manifests Could not find dependent assembly L"Microsoft.Windows.Common-Controls" (6.0.0.0)
Infos
2.6.36-ARCH X86_64
ATI Radeon 5870
catalyst-hook 10.11-1
catalyst-utils 10.11-1
lib32-catalyst-utils
xorg 1.9.2
wine 1.3.9 (same problem with previous versions of wine)
Winetricks version 20101106
Last edited by Snakeye (2010-12-13 03:03:49) -
Personas suddenly not working Firefox 30, 31, 32 on Win 7 Pro x64 and Linux Mint 16 x64
Personas which have been working for a long time suddenly quit working on Win 7 and Linux. I tried changing to a different persona to change the background for the top border of the window and it just goes to some odd color and the personas just don't show up. This has been with Firefox 30, 31, 32. The personas still work with Win XP Pro run as a virtual machine on Win 7 host or Win 8 host. I thought it was a Windows thing until I saw the same problem with Linux. Everything else seems normal so this isn't a real bad problem. It's just odd.
Make sure that you do not run Firefox in permanent Private Browsing mode (Never remember history).
*https://support.mozilla.org/kb/Private+Browsing
*Tools > Options > Privacy > Firefox will: "Use custom settings for history"
*Deselect: [ ] "Always use Private Browsing mode" -
G780: dual boot Win 7 and Linux
I have a G780 with win7 pre-installed. When I tried to get GNU/Linux Mint Dual-booting, the wifi-driver didn't work and most importantly, I wasn't able to make a new partition because there were already four: the boot-partition, the windows-partition, one labeled "Lenovo" and one "Lenovo2" (or something like this). The hard-disk is formatted in a way so that only four partitions are allowed.
Does anyone have an idea how to solve those problems?
Moderator note: off-topic post moved to its own thread. Subject edited to match content. Was: Re: Dual booting pre-installed Windows 8 and Linux?Hi Zoltan.
You'll need to operate on the partitions with gparted. It uses its own partition table type, gpt, instead of the DOS partition type, which limits the number of primary partions to four.
I believe that Mint comes with gparted, but you can boot gparted from a live cd or usb. With it you can shrink the Windoze partition to create root, swap and home partitions.
Regards,
KD -
Will OSB be released for Win64 and Linux 64 platforms?
If so, when?
ChrisYes, we are now working on Win64, Linux64 as well as other platforms. I anticipate having support in about 2 -3 month timeframe
-
CSCur27617: AnyConnect vulnerable to POODLE attack (CVE-2014-3566) Win/Mac/Linux
I wanted to know if the AnyConnect Secure Mobility Client would still be vulnerable to this if it was only connecting via SSL VPN (TLS) to an ASA that already has the workaround implemented on it (Disable SSLv3)?
Thanks,
Rob MieleHi Rob ,
According to the bug:
All versions of desktop AnyConnect for Mac OS X and Linux prior to 3.1.00495 are vulnerable , so Anyconnect 3.1.06.073 is safe from POODLE vulnerability
On the Anyconnect you can disable the SSL using Ikev2 instead of the SSL protocols , however as the bug mention , the client creates a paralel ssl tunnel to get updates and profile from the router.
If you're asking to disable SSLv3 on the router , unfortunately there is not code yet , the workaround is to disable the webvpn or upgrade the VPN client.
As well here is the officil advisory for the POODLE vulnerbility on Cisco Products.
http://tools.cisco.com/security/center/content/CiscoSecurityAdvisory/cisco-sa-20141015-poodle
Hope it helps
- Randy - -
L_Proaudio Project: Wine-L_pa + Linux-L_pa
Announcing L_ProAudio;
L_ProAudio
The L_ProAudio project aimed at Vastly improving wine-enabled Windows VST/ASIO applications to run more seamlessly and integrated in a Gnu/Linux environment. EDIT: it ALREADY accomplishes it's aims for the most part, with the exception of WineASIO / wine-rt / wineserver bound applications ~ which are stuck using the 'wineserver bottleneck'. ~ but this is being looked into so be patient...
NOTE: there is lots of info (below) and at SF.net wiki + readme.
I've started some docs for the wiki, but you'll have to wait a few days for that.
This project is split into components:
1. Linux-L_pa is the specially tweaked kernel. This kernel is tweaked for RT (Realtime Linux), but more specifically 3.6.11-rt25-1-rt patched with a few 'cherry-picked' patches (by me) from various useful sources. These sources include; Muse Research, Mao Tao / Google / google, while others will be identified in the patch, themselves. These were all then applied and/or reworked in order to work nicely. This kernel is designed to work with wine-L_pa and does so, very well.
2. Wine-L_pa is a highly modified version of Wine. It's patches were also cherry-picked from Muse Research / Codeweavers, my own patches or otherwise identified, respectfully. This version is based on 1.5.21 (and thus all patches were re-based...). A brief log of useful stuff included;
- new threading/priority model; L_RT_THREADS bool (env variables for new prio/threading enablement)
- ntdll use syncronisations for pipes (<-- needs investigating by devs, but provides jack like synchronization to wine-apps)
- Rendering vastly improved for vst plugins (and wine in general, no flickering on move/scale)
- much better handling of threads/priorites
- signicant reduction in CPU usage (in general)
- much more stable than upstream wine
- fixes for disk geometry io ctl
- fixes for DnD
- fixes for metacity / hidden windows / etc...and much more
FSThost from SVN on SF.net will also be useful, since it integrates with L_pa-Wine's new priority mapping / threading code via env variables (that fsthost handles)
https://sourceforge.net/projects/fsthost/
< triplesquarednine (_AT_) gmail (_DOT_) com
Wine-L_pa is available in the AUR:
https://aur.archlinux.org/packages/wine-l-pa/
Linux-L_pa is available at sourceforge project page, but will be available in AUR, in the next day or so (along with nvidia-l-pa, for binary driver rt-users, like myself)
http://sourceforge.net/projects/l-proau … z/download
report back issues, patchwork, etc... have fun
Last edited by triplesquarednine (2013-01-05 13:28:23)I don't know how many people are following this thread, but i have several areas of news;
1. I am working on figuring out issues with Cockos Reaper (including being in touch with them, plus kindly given an NFR'd copy for reaper testing puroses.
2. I am working with Upstream wine and in the next release or two - some of my patches will be merged upstream (although not the _best_ ones), mostly one's that fix bugs in upstream wine. ~ that's okay though, we still have a proaudio geared L_pa-Wine anyway. (which is part of the point, in the first place - i knew they would reject the best patches from L-pa - but this is entirely why L-pa is a downstream project ~ that will continue to work with upstream).
3. FSThost fully-supports my project with integration of L_RT_THREADS and the pipe_sync support. ~ it is the de-facto standard for hosting VSTs in L_pa.
4. WineASIO needs to be looked at as faw as hosting DAWs. FSThost seems to be a more direct path and handles prios properly, wineASIO does not (with or without wine-rt patch apllied to L_pa-Wine)- but as far as single hosting + WineASIO ~ just pass the env L_ variables and you should be fine. (the threading/prio mapping gets trickier with DAWs and needs to be investigated / tested quite a bit more - before i can promise your wineDAW will run well).
5. I've got a good amount of testers for both system components, some having great success, some still having issues (to be expected, this is experimental software ~ and an *alpha" project. ~ i am making progress very quickly though, so be patient.
6. I _think_ in 3.8-rt ext4 _may_ be alright with some tweaking. noatime,data=writeback are almost certainly going to be requirements though, (since they reduce latency / increase performance ~ albeit at the cost of a little data integrity... so it's upto you what you wanna do in this regard. Ext4 is not very performant for these kinds of uses (with RT and Wine). Using a different file-system could fix the problem ~ but not many of us, have that choice always.
7. 1 system (out of many testers) is incompatible with the revert-stable-page-write patch, if you get hung on boot - with a stop on loading ramdisk ~ you need to revert it and re-compile. Unfortunately, this is _likely_ to mean ext4 will be a much bigger bottleneck on your system ~ so you will need to look into alternative ways of taming the latency inducing / xruns causing beast that is ext4.. ~ but we will get upstream ext4 tamed in the next couple of releases (as forementioned). ~ but note: i am looking into the 1 system that hangs on boot (i just need logging/crash info, and a bit of time).
I am also looking into Btrfs support, although there is no rush for that (since i am not using it). (
anyway,
more to come
Jordan
Last edited by triplesquarednine (2013-01-04 18:39:02)
Maybe you are looking for
-
Using a Mac Mini with an iMac (11,1)
Hi, I am considering buying a Mac Mini to replace an old netbook I use as a development server. The old netbook runs Ubuntu and was a cheap but excellent machine that I utilized to develop customized software. Unfortunately that machine is starting
-
Oracle 9i windows to Oracle 9i AIX
Dear All, Currently we have our db Oracle 9i running on windows 2k3. Now organisation want it to shift to IBM AIX 5.3. By which way I can transfer my whole db to IBM AIX? I read that prior to oracle 10g cant support "*Cross platform transport tablesp
-
Dictionaries in v2.1 on iPod Touch?
According to http://www.apple.com/ipodtouch/softwareupdate.html ... v2.1 includes dictionaries: "Updated Keyboard and Dictionary Support. In addition to its complete support for 17 languages, iPod touch now supports 30 international keyboard layouts
-
Namespace declaration using DOM
Hi, I am using DOM to create an XML document. How do I declare namespace? I want to know which API is used to create namespace declaration in an XML document. I want my final XML document to be <RootElement xmlns:c="http://pradeep.somesite.com"> <nam
-
How can I see my sync bookmarks on Sumsung Tab S
On my bookmark android page I can not see sync bookmarks from my desk top everything else is synchronized correctly