我有一個奇怪的白色條紋(見下文)出現在我的背景圖像上。代碼很簡單。如何擺脫白色條紋?JFrame奇怪的白色條紋背景圖像
//Graphics side of the game
public class GUI extends JFrame {
private final int larghezza = 1280;
private final int altezza = 720;
private final String name = "Sette e Mezzo";
private final ImageIcon backgroundImage;
private JLabel bgImageLabel;
private JPanel backgroundPanel, borderLayoutPanel, topGridLayout, botGridLayout;
public GUI() {
backgroundImage = new ImageIcon ("assets/background.png");
bgImageLabel = new JLabel (backgroundImage);
//Panels
borderLayoutPanel = new JPanel (new BorderLayout());
topGridLayout = new JPanel (new GridLayout (1, 3));
botGridLayout = new JPanel (new GridLayout (1, 3));
backgroundPanel = new JPanel();
backgroundPanel.add (bgImageLabel);
//Frame
this.setName (name);
this.setPreferredSize (new Dimension(larghezza, altezza));
this.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
//Adding to frame and panels
borderLayoutPanel.add (topGridLayout, BorderLayout.NORTH);
borderLayoutPanel.add (botGridLayout, BorderLayout.SOUTH);
this.add (borderLayoutPanel);
this.add (backgroundPanel);
this.pack();
this.setLocationRelativeTo (null);
this.setVisible (true);
}
}
1)爲了更好地幫助越早,張貼[MCVE]或[簡要,獨立的,正確的示例](http://www.sscce.org/)。 (例如,爲了完成上面的代碼需要導入和一個主要的方法)2)*「'新的ImageIcon(」assets/background.png「);'」*一個例子獲取圖像的方法是以熱點鏈接到[本問答](http://stackoverflow.com/q/19209650/418556)中看到的圖像。 –
.. 3)順便說一句 - 這不是白色的,它是RGB(255,250,254)。 –