Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (736)
Games in Android Showcase (223)
games submitted by our members
Games in WIP (813)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  [Solved] Game Launcher  (Read 549 times)
0 Members and 1 Guest are viewing this topic.
Offline Glabay
« Posted 2017-07-12 19:27:07 »

Hello,

I am writing my Game Engine from scratch, I decided to make a launcher to have the user open first and log into, get news/updates and download the game cache/updates.

I have it set up to open on a login page and if you click register it should replace the current panel and load the register one.

I have 2 classes, LoginPanel, and RegisterPanel. they both extend JPanel

in the main class I have a JPanel that is the current displayed panel, at launch the current panel is set to the login panel, if you click on register I want to replace the current panel with the registerPanel, but when I do this not all of the panel displays, either the JComboBox for DoB doesn't render unless you mouse over it, or the old panel will be there behind it still.


I have removed the loginPane from the contentPane and then added the register pane and re validated it, nothing
I have used repaint() and kinda but the JComboBoxes don't display or the Label doesn't show.


Bad for explaining things I am sorry, here are some pictures.


JComboBox not fully showing up and the login still in the background.





JComboBox only showing up if you hover over it, but the rest kinda loads



Last this is the content that should be displayed in the Register Panel when updated on the screen





As you can see in the pics, not all of the content is updated properly.

Does anyone know of a way to make this work properly, I can show current code if needed.

PI * 13.37 = 42
There are 10 kinds of people; those who know Binary and those who don't
Why programmers confuse Christmas and Halloween; Because 31 OCT = 25 DEC.
Offline KevinWorkman

« JGO Plugged Duke »


Medals: 262
Projects: 12
Exp: 12 years


HappyCoding.io - Coding Tutorials!


« Reply #1 - Posted 2017-07-13 03:58:43 »

Use a CardLayout.

It sounds like you're manually removing and adding components from your JFrame after it's already visible, which won't work. At the very least, you need to revalidate your JFrame after adding a new component to it. Look for useful functions in the API.

But really you should just use CardLayout instead of adding stuff after the JFrame is already visible.

If you're still stuck, please post a small example program that demonstrates the problem (it should just be a simple JFrame with one or two components, not your whole game), and we'll go from there. Good luck.

HappyCoding.io - Coding Tutorials!
Happy Coding forum - Come say hello!
Offline cylab

JGO Kernel


Medals: 173



« Reply #2 - Posted 2017-07-13 06:35:13 »

Also be careful to only modify the UI from the AWT event thread. Take a look at SwingUtils.invokeLater()

Mathias - I Know What [you] Did Last Summer!
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Glabay
« Reply #3 - Posted 2017-07-13 21:51:11 »

Use a CardLayout.

It sounds like you're manually removing and adding components from your JFrame after it's already visible, which won't work. At the very least, you need to revalidate your JFrame after adding a new component to it. Look for useful functions in the API.

But really you should just use CardLayout instead of adding stuff after the JFrame is already visible.

If you're still stuck, please post a small example program that demonstrates the problem (it should just be a simple JFrame with one or two components, not your whole game), and we'll go from there. Good luck.

Thanks for the tip I thought of using the CardLayout but just went another way, idk why lol.

I was declaring them both in the init(), I created 2 JPanels and then made them = the 2 panels (login and register)

and tried to use this


1  
2  
3  
4  
5  
6  
   public void sendRegPanel() {
      contentPane.remove(loginPane); // remove the pane
      contentPane.add(regPane); // set the new pane
      contentPane.revalidate(); // cause yea...
      repaint(); // and just to try see if it works
   }



roughly and I got nothing, I will work out the CardLayout and update this thread



UPDATE:

Solved this issue with the CardLayout, Thanks @KevinWorkman

PI * 13.37 = 42
There are 10 kinds of people; those who know Binary and those who don't
Why programmers confuse Christmas and Halloween; Because 31 OCT = 25 DEC.
Pages: [1]
  ignore  |  Print  
 
 

 
cybrmynd (122 views)
2017-08-02 12:28:51

cybrmynd (145 views)
2017-08-02 12:19:43

cybrmynd (140 views)
2017-08-02 12:18:09

Sralse (156 views)
2017-07-25 17:13:48

Archive (626 views)
2017-04-27 17:45:51

buddyBro (735 views)
2017-04-05 03:38:00

CopyableCougar4 (1263 views)
2017-03-24 15:39:42

theagentd (1242 views)
2017-03-24 15:32:08

Rule (1218 views)
2017-03-19 12:43:22

Rule (1271 views)
2017-03-19 12:42:17
List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05

SF/X Libraries
by SkyAphid
2017-03-02 06:38:56

SF/X Libraries
by SkyAphid
2017-03-02 06:38:32

SF/X Libraries
by SkyAphid
2017-03-02 06:38:05

SF/X Libraries
by SkyAphid
2017-03-02 06:37:51
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!