JPanel wird erst im Fullscreen angezeigt

RemForWin

Neues Mitglied
Wie schon im Titel erklärt , habe ich ein JPanel programmiert, das erst angezeigt wird, wenn ich in fullscreen gehe und danach bleibt es auch da, auch wenn ich wieder in die normale Fenstergröße zurückgehe. Finde das seltsam, da ich in dem Programm schon einige Panels eingebaut hab, die tadellos funktionieren.
Hier erstmal der Code:

[CODE lang="java" highlight="155-119"]import java.awt.Color;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;

public class Game {
JFrame window;
JPanel titlePanel, startButtonPanel, mainTextPanel, choiceButtonPanel, playerPanel;
JLabel titleText;
Font titleFont = new Font("Times New Roman", Font.PLAIN, 140);
Font normalFont = new Font("Times New Roman", Font.PLAIN, 30);
JButton startButton, choice1, choice2, choice3, choice4;
JTextArea mainTextArea;

TitleScreenHandler tsHandler = new TitleScreenHandler();

public static void main(String[] args)
{
new Game();
}

public Game()
{

window = new JFrame();
window.setSize(800, 600); //window.setSize(width, height)
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.getContentPane().setBackground(Color.black);
window.setLayout(null); //deaktiviert das default Layer von Java
window.setVisible(true);

titlePanel = new JPanel();
titlePanel.setBounds(100, 100, 600, 150); //title.setBounds(x, y, width, height)
titlePanel.setBackground(Color.black);
titleText = new JLabel("Adventure");
titleText.setForeground(Color.white);
titleText.setFont(titleFont);

startButtonPanel = new JPanel();
startButtonPanel.setBounds(300, 400, 200, 100);
startButtonPanel.setBackground(Color.black);

startButton = new JButton("START");
startButton.setBackground(Color.black); //Color of button
startButton.setForeground(Color.white); //Color of text in button
startButton.setFont(normalFont);
startButton.addActionListener(tsHandler);

titlePanel.add(titleText);
startButtonPanel.add(startButton);

window.add(titlePanel);
window.add(startButtonPanel);

}

public void createGameScreen()
{
titlePanel.setVisible(false);
startButtonPanel.setVisible(false);

mainTextPanel = new JPanel();
mainTextPanel.setBounds(100, 100, 600, 250);
mainTextPanel.setBackground(Color.black);

window.add(mainTextPanel);

mainTextArea = new JTextArea("This is the main text area.");
mainTextArea.setBounds(100, 100, 600, 250);
mainTextArea.setBackground(Color.black);
mainTextArea.setForeground(Color.white); // color of text
mainTextArea.setFont(normalFont);
mainTextArea.setLineWrap(true); // Zeilenumbruch findet bei zu langem Text automatisch statt

mainTextPanel.add(mainTextArea);

choiceButtonPanel = new JPanel();
choiceButtonPanel.setBounds(250, 350, 300, 150);
choiceButtonPanel.setBackground(Color.black);
choiceButtonPanel.setLayout(new GridLayout(4,1)); //...new GridLayout(Vertikal, Horizontal));

window.add(choiceButtonPanel);

choice1 = new JButton("Choice 1");
choice1.setBackground(Color.black);
choice1.setForeground(Color.white);
choice1.setFont(normalFont);
choiceButtonPanel.add(choice1);

choice2 = new JButton("Choice 2");
choice2.setBackground(Color.black);
choice2.setForeground(Color.white);
choice2.setFont(normalFont);
choiceButtonPanel.add(choice2);

choice3 = new JButton("Choice 3");
choice3.setBackground(Color.black);
choice3.setForeground(Color.white);
choice3.setFont(normalFont);
choiceButtonPanel.add(choice3);

choice4 = new JButton("Choice 4");
choice4.setBackground(Color.black);
choice4.setForeground(Color.white);
choice4.setFont(normalFont);
choiceButtonPanel.add(choice4);

playerPanel = new JPanel();
playerPanel.setBounds(100, 15, 600, 50);
playerPanel.setBackground(Color.blue);
playerPanel.setLayout(new GridLayout(1,4));
window.add(playerPanel);

}

public class TitleScreenHandler implements ActionListener
{
public void actionPerformed(ActionEvent event)
{
createGameScreen();
}
}

}
[/CODE]

Das "playerPanel" wird ist das besagte Panel, was ohne fullscreen nicht angezeigt wird. Ich habe schon playerPanel.setVisible(true) versucht und ich habe auch versucht dem Panel ein JLabel zuzuweisen, beides ohne Erfolg.
Könnte mir hier vielleicht jemand weiterhelfen?
Danke im voraus :)
 

RemForWin

Neues Mitglied
Wie schon im Titel erklärt , habe ich ein JPanel programmiert, das erst angezeigt wird, wenn ich in fullscreen gehe und danach bleibt es auch da, auch wenn ich wieder in die normale Fenstergröße zurückgehe. Finde das seltsam, da ich in dem Programm schon einige Panels eingebaut hab, die tadellos funktionieren.
Hier erstmal der Code:

[CODE lang="java" highlight="155-119"]import java.awt.Color;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;

public class Game {
JFrame window;
JPanel titlePanel, startButtonPanel, mainTextPanel, choiceButtonPanel, playerPanel;
JLabel titleText;
Font titleFont = new Font("Times New Roman", Font.PLAIN, 140);
Font normalFont = new Font("Times New Roman", Font.PLAIN, 30);
JButton startButton, choice1, choice2, choice3, choice4;
JTextArea mainTextArea;

TitleScreenHandler tsHandler = new TitleScreenHandler();

public static void main(String[] args)
{
new Game();
}

public Game()
{

window = new JFrame();
window.setSize(800, 600); //window.setSize(width, height)
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.getContentPane().setBackground(Color.black);
window.setLayout(null); //deaktiviert das default Layer von Java
window.setVisible(true);

titlePanel = new JPanel();
titlePanel.setBounds(100, 100, 600, 150); //title.setBounds(x, y, width, height)
titlePanel.setBackground(Color.black);
titleText = new JLabel("Adventure");
titleText.setForeground(Color.white);
titleText.setFont(titleFont);

startButtonPanel = new JPanel();
startButtonPanel.setBounds(300, 400, 200, 100);
startButtonPanel.setBackground(Color.black);

startButton = new JButton("START");
startButton.setBackground(Color.black); //Color of button
startButton.setForeground(Color.white); //Color of text in button
startButton.setFont(normalFont);
startButton.addActionListener(tsHandler);

titlePanel.add(titleText);
startButtonPanel.add(startButton);

window.add(titlePanel);
window.add(startButtonPanel);

}

public void createGameScreen()
{
titlePanel.setVisible(false);
startButtonPanel.setVisible(false);

mainTextPanel = new JPanel();
mainTextPanel.setBounds(100, 100, 600, 250);
mainTextPanel.setBackground(Color.black);

window.add(mainTextPanel);

mainTextArea = new JTextArea("This is the main text area.");
mainTextArea.setBounds(100, 100, 600, 250);
mainTextArea.setBackground(Color.black);
mainTextArea.setForeground(Color.white); // color of text
mainTextArea.setFont(normalFont);
mainTextArea.setLineWrap(true); // Zeilenumbruch findet bei zu langem Text automatisch statt

mainTextPanel.add(mainTextArea);

choiceButtonPanel = new JPanel();
choiceButtonPanel.setBounds(250, 350, 300, 150);
choiceButtonPanel.setBackground(Color.black);
choiceButtonPanel.setLayout(new GridLayout(4,1)); //...new GridLayout(Vertikal, Horizontal));

window.add(choiceButtonPanel);

choice1 = new JButton("Choice 1");
choice1.setBackground(Color.black);
choice1.setForeground(Color.white);
choice1.setFont(normalFont);
choiceButtonPanel.add(choice1);

choice2 = new JButton("Choice 2");
choice2.setBackground(Color.black);
choice2.setForeground(Color.white);
choice2.setFont(normalFont);
choiceButtonPanel.add(choice2);

choice3 = new JButton("Choice 3");
choice3.setBackground(Color.black);
choice3.setForeground(Color.white);
choice3.setFont(normalFont);
choiceButtonPanel.add(choice3);

choice4 = new JButton("Choice 4");
choice4.setBackground(Color.black);
choice4.setForeground(Color.white);
choice4.setFont(normalFont);
choiceButtonPanel.add(choice4);

playerPanel = new JPanel();
playerPanel.setBounds(100, 15, 600, 50);
playerPanel.setBackground(Color.blue);
playerPanel.setLayout(new GridLayout(1,4));
window.add(playerPanel);

}

public class TitleScreenHandler implements ActionListener
{
public void actionPerformed(ActionEvent event)
{
createGameScreen();
}
}

}
[/CODE]

Das "playerPanel" wird ist das besagte Panel, was ohne fullscreen nicht angezeigt wird. Ich habe schon playerPanel.setVisible(true) versucht und ich habe auch versucht dem Panel ein JLabel zuzuweisen, beides ohne Erfolg.
Könnte mir hier vielleicht jemand weiterhelfen?
Danke im voraus :)
Kleiner edit: Das playerPanel geht von Zeile 115-119
 
Ähnliche Java Themen
  Titel Forum Antworten Datum
M 1. Menüleiste wird doppelt gezeichnet 2. awt auf ein jpanel Spiele- und Multimedia-Programmierung 4
P selectedItem aus einem Methodenerstellten JPanel auslesen. Spiele- und Multimedia-Programmierung 5
M JPanel mit Graphics2D Objekten mit JScrollpane Spiele- und Multimedia-Programmierung 6
K JPanel wechseln & Neu starten - SnakeSpiel Spiele- und Multimedia-Programmierung 2
A paintComponent in JPanel in JFrame Spiele- und Multimedia-Programmierung 7
N JPanel Inhalt aktualisiert nach Thread.sleep nicht Spiele- und Multimedia-Programmierung 2
S Thread und jpanel-paintcomponent kombinierbar?? Spiele- und Multimedia-Programmierung 14
E Animiertes JPanel dynamisch wechseln Spiele- und Multimedia-Programmierung 3
W Panel/JPAnel createImage() Exception Spiele- und Multimedia-Programmierung 2
R Probleme mit JPanel!KeyListener geht nicht Spiele- und Multimedia-Programmierung 6
T Problem bei LinkedList / JPanel Spiele- und Multimedia-Programmierung 4
C 2D Sprites an die JPanel Größe (Auflösung) anpassen/skalieren Spiele- und Multimedia-Programmierung 3
F Vektorgrafik in JPanel Spiele- und Multimedia-Programmierung 5
E Active Rendering im FSEM auf ein JPanel? Spiele- und Multimedia-Programmierung 4
L 2D-Spiele ruckeln auf JPanel Spiele- und Multimedia-Programmierung 7
A Mehrere geometrische Objekte in JPanel zeichnen Spiele- und Multimedia-Programmierung 4
X JPanel dynamisch (Koordinatensystem)? Spiele- und Multimedia-Programmierung 30
M Jpanel Graphik speichern Spiele- und Multimedia-Programmierung 6
DamienX Canvas vs JPanel Spiele- und Multimedia-Programmierung 15
S Problem mit JPanel bzw p a i n t Spiele- und Multimedia-Programmierung 6
K stringWidth bei Graphics von JPanel und Printer unterschiedl Spiele- und Multimedia-Programmierung 4
R SimpleUniverse in JPanel Spiele- und Multimedia-Programmierung 4
M Jpanel mit Keylistener Spiele- und Multimedia-Programmierung 6
D 2D Graphic Objekte in ein JPanel einfügen Spiele- und Multimedia-Programmierung 2
TobiasN Wer Wird Millionär Spiele- und Multimedia-Programmierung 4
B Bild wird nicht geladen Spiele- und Multimedia-Programmierung 4
K Das Leerzeichen der Tastatur wird nicht gleichgesetzt mit dem Leerzeichen aus der Text Datei Spiele- und Multimedia-Programmierung 5
B Programmieren wie der Befehl /ban in Minecraft geblockt wird aber nicht /ban mit einem Argument Spiele- und Multimedia-Programmierung 1
J OpenGL Bild wird nicht richtig angezeigt Spiele- und Multimedia-Programmierung 2
S GetBufferStrategy-Methode wird nicht angezeigt Spiele- und Multimedia-Programmierung 6
G Wer wird Millionär / Fragefenster Spiele- und Multimedia-Programmierung 6
L Transparenz wird magenta Spiele- und Multimedia-Programmierung 3
Polarfuchs Status von Midi Datei(wird gerade abgespielt oder nicht) Spiele- und Multimedia-Programmierung 0
A Bild(sequenz) wird nicht geladen Spiele- und Multimedia-Programmierung 1
F 4 Gewinnt - Code wird ignoriert Spiele- und Multimedia-Programmierung 7
C Mein Programm wird sofort terminated Spiele- und Multimedia-Programmierung 8
A [LWJGL] BMP Textur wird nicht richtig dargestellt Spiele- und Multimedia-Programmierung 8
S LWJGL Rechteck wird nicht gezeichnet Spiele- und Multimedia-Programmierung 6
J Versch. Pfeiltasten angezeigt obwohl nur 1 gedrückt wird Spiele- und Multimedia-Programmierung 2
Creylon [LWJGL] Textur wird falsch angezeigt Spiele- und Multimedia-Programmierung 12
S Nur den Bereich des JPanels zeichen der im Viewport des JScrollPane angezeigt wird Spiele- und Multimedia-Programmierung 8
Q BufferedImage vs. Heap Space ‒ Warum wird der Speicher nicht freigegeben? Spiele- und Multimedia-Programmierung 6
M Karte wird falsch gezeichnet Spiele- und Multimedia-Programmierung 9
H Skalierung eines Polygons ohne das es verschoben wird Spiele- und Multimedia-Programmierung 3
C Alles hängt, wenn ein Sound abgespielt wird Spiele- und Multimedia-Programmierung 9
K Transformation wird nicht angewendet Spiele- und Multimedia-Programmierung 3
A Wie wird die Person im Game animiert, dass sie ihre Körperteile bewegen? Spiele- und Multimedia-Programmierung 3
A Shape Geometry, wird nicht angezeigt Spiele- und Multimedia-Programmierung 6
L Progress Bar wird erst zu spät ganz angezeigt Spiele- und Multimedia-Programmierung 5
D Jogl:Textur auf GLUquadric wird vertikal spiegelverkehrt dargestellt Spiele- und Multimedia-Programmierung 2
M Java Textadventure HashMap wird nicht befüllt? Spiele- und Multimedia-Programmierung 7
P [JMF] Webcam wird nicht gefunden Spiele- und Multimedia-Programmierung 3
P Erkennen auf welche Objekte gezeigt wird in JoGL Spiele- und Multimedia-Programmierung 6
Steev KeyPressed:Tab wird nicht mehr weitergeleitet Spiele- und Multimedia-Programmierung 2
J JOGL - Bild wird immer wieder weiß Spiele- und Multimedia-Programmierung 2
0x7F800000 weiß einer wozu ANTLR beim build von JOGL verwendet wird? Spiele- und Multimedia-Programmierung 3
J MenuBar wird bei Spiel nicht angezeigt Spiele- und Multimedia-Programmierung 5
L Frame wird geöffnet es wird aber nix angezeigt Spiele- und Multimedia-Programmierung 2
R Die korrekte Breite/Höhe eines Bildes wird nicht erkannt. Spiele- und Multimedia-Programmierung 2
P JOGL: mit glTranslated wird nichts gezeichnet Spiele- und Multimedia-Programmierung 3
F Szene wird nicht komplett angezeigt (Tiefenproblem?) Spiele- und Multimedia-Programmierung 2
G Fragespiel, Hilfe ! like Wer wird Millinär Spiele- und Multimedia-Programmierung 12
F WakeupOnAWTEvent wird ignoriert! Spiele- und Multimedia-Programmierung 2
C BackgroundSound wird nicht abgespielt Spiele- und Multimedia-Programmierung 3
dummycoders Android Studio - Button ändert Farbe erst nach Delay? Spiele- und Multimedia-Programmierung 5
R Java3d ViewingPlatform erst Verschieben und dann RotationsInterpolator Spiele- und Multimedia-Programmierung 0

Ähnliche Java Themen

Neue Themen


Oben