cardlayout

Switching between JPanels in a JFrame

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-02 04:04:59
Now I know there are many, many questions on this and I've read a dozen. But I've just hit a wall, I can't make heads or tails of it. Heres my question. I have 3 Panel classes. ConfigurePanel.java ConnectServerPanel.java RunServerPanel.java and my JFrame class StartUPGUI.java This is what is initialised at startup private void initComponents() { jPanel1 = new javax.swing.JPanel(); startUp = new sjdproject.GUI.ConfigurePanel(); runServer = new sjdproject.GUI.RunServerPanel(); serverConnect = new sjdproject.GUI.ConnectServerPanel(); setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING

Previous function of CardLayout not working?

我只是一个虾纸丫 提交于 2019-12-02 03:55:40
The next function of my cardlayout is working properly, but previous isnt. As far as I'm concerned, just having "layout.previous( _ );" in the actionPerformed method body in my makePanel() method should work, but when I run my program and click the prev button, nothing happens. What am I doing wrong? – import java.awt.*; import javax.swing.*; import java.util.*; import java.awt.event.*; public class Temp { public static void main (String[] args) { new MakeAQuiz(); } static class MakeAQuiz { private JPanel start, base, fields, buttonz, question; private String [] labels = {"Enter your question:

Running a method after switching cards in cardlayout

戏子无情 提交于 2019-12-01 22:51:30
I'm sure someone has asked this question before, but my google-fu is not strong today. I have a JFrame that uses a CardLayout as its manager. How do I run a "Start" method when I switch to each JPanel without using a switch? The code I use to add the frames to the layout is: /** * Adds JPanels to the Card Layout. * @param panel is the JPanel to add to the layout. * @param windowName is the identifier used to recognise the Panel. */ public final void addToCards(final JPanel panel, final WindowNames windowName) { view.getBasePanel().add(panel, windowName.getValue()); } The code I use to switch

Resizing a JPanel inside a JFrame

本秂侑毒 提交于 2019-12-01 20:22:38
I am new to Java, started learning swing and have a problem with resizing a JPanel inside a JFrame. I am following this tutorial: http://vincentramdhanie.blogspot.com/2009/11/cardlayout-with-netbeans.html because ultimately I am learning each of the different layouts and have come to the CardLayout now. In the above, there is a JPanel being used for a status panel. That is what I want to do as well, but when I drag a JPanel onto my blank JForm it takes up all the space and I don't see any resizing handles for it like I would if I were using a .NET panel. Changing preferredSize in the

frame 2 inside frame 1

江枫思渺然 提交于 2019-12-01 14:42:42
I have 2 classes; Students and RegisterStudents, and hence 2 different main_panel(Class 1) and panel_1 (Class 2). What I am trying to do is, when a button on the Students Interface is pressed, the whole panel_1 should appear within main_panel. I have set both to same size already. is that possible? The code i got so far is: JButton btnNewButton = new JButton("Register Student"); btnNewButton.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { Students main_panel = new Students(); RegisterStudent panel_1 = new RegisterStudent(); main_panel.add(panel_1); }

Implementing CardLayout within a JFrame and switching cards based on specific button presses

℡╲_俬逩灬. 提交于 2019-12-01 14:14:49
I've posted my code below. I have the simple task of creating a navigable GUI. I've spent the past few hours doing research on how to accomplish this, and this is the code that I've put together. Originally I wanted to perform the navigation without any layouts or anything. I need the home panel to display after the user clicks on the "login" button on the welcome panel. It displays the welcome card just fine, but when I get to the validateLogin method(which is activated when the login button is press, and upon successful login it should show the home panel within cards) it simply stays on the

CardLayout, switch between JPanels by ButtonClick

送分小仙女□ 提交于 2019-12-01 09:28:41
I want to switch between JPanels by clicking buttons on the JPanels. For example: I have a JPanel sim with a JButton simknop and a JPanel help with JButton helpknop I want to switch between these 2 JPanels by clicking the buttons. When I click JButton simknop JPanel help should appear and when I click JButton help JPanel sim should appear. Below you can find the different classes: main.java public class main extends JFrame { JPanel cards; sim sim; help help; public main() { this.setSize(1024,768); //this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); this.setDefaultCloseOperation(JFrame

How to Integrate Multi-page Java Desktop Application from Multiple GUI Classes

强颜欢笑 提交于 2019-12-01 07:25:18
问题 I am working on a Java Swing desktop application project. The application has about 15 GUI pages. I can use Layered Panes and Tabbed Panes to put all the GUI components in one class. But that class will be huge. It would be idea if I can divide the project into several smaller sub-projects and let each have one or a few GUI pages. I can work on each sub-project individually and integrate them back into one application when all sub-projects are finished. My question is that how I can integrate

CardLayout get the selected card's name

廉价感情. 提交于 2019-12-01 04:11:12
How can I get the string identifier of the selected panel in card layout. The CardLayout does not know what the currently selected panel is. You should keep this in memory yourself, when calling the show() method. The CardLayout does not allow you to do this. However, you should be able to access the top panel of the CardLayout. So a little work around is to give each added panel a name, equal to the string identifier. That way you can get the top card, and get it's name. This is how you do it: final String CARD1 = "Card 1"; final String CARD2 = "Card 2"; JPanel panel = new JPanel(new

CardLayout with different sizes

亡梦爱人 提交于 2019-12-01 03:35:55
问题 Well I'm having some troubles by making a CardLayout with different sizes on each card. After reading The Use of Multiple JFrames: Good or Bad Practice? I noticed I was doing things in a way that is not the apropiate, so I decided to start learning how to use CardLayout I have tried this answer from @HovercraftFullOfEels This one from @mKorbel And finally the answer of @Kleopatra All of them are based on Hovercraft's answer but with some changes. I was able to create the CardLayout (and still