Questions tagged [cardlayout]

A CardLayout is a graphical layout manager for a container. It treats each component in the container as a card. Only one card is visible at a time, and the container acts as a stack of cards.

A CardLayout is a graphical layout manager for a Container. It treats each component in the container as a card. Only one card is visible at a time, and the container acts as a stack of cards.

For Java Swing, see How to Use CardLayout.

562 questions
4
votes
2 answers

Java how to add image as background in layout

I have a class that uses a CardLayout which has two cards that have a button on them. What I would like to be able to do is put an image that would act like a background such as a desktop background in Windows. The program eventually will have…
Jarod
  • 157
  • 2
  • 4
  • 12
3
votes
1 answer

java.lang.IllegalArgumentException: cannot add to layout: constraint must be a string

I am having difficulty with CardLayout Manager in my code. I can't figure out why i am getting this exception. I am passing a string in the CardLayout.show() method but still i get this error. Please help. This is my main…
Jha
  • 54
  • 1
  • 5
3
votes
1 answer

Cardlayout addLayoutComponent() API

I'm a bit confused by the logic that's been used to arrive at the current API for addLayoutComponent(). There's two methods, one that takes a string and a component, and the other that takes an object and a component (but fails at runtime unless…
Michael Berry
  • 70,193
  • 21
  • 157
  • 216
3
votes
1 answer

Get focus on a JTextField inside a CardLayout

I have a JTextField inside a JPanel A which is a part of CardLayout. When this A gets shown, I want to set the focus automatically to the JTextField (i.e. the cursor is flashing in the text field so the user doesn't need to click on it to enable the…
skyork
  • 7,113
  • 18
  • 63
  • 103
3
votes
2 answers

Check if a card with a name is present in a CardLayout

I have a CardLayout in which I add cards only as needed. So, when the need arises to show a particular card (identifed by its name), I need a way to check if a card with that name is already present, so that I can either show or create it…
sharat87
  • 7,330
  • 12
  • 55
  • 80
3
votes
3 answers

CardLayout - How to Delete current card (Java Swing)

How would one delete the current card that the user is on. I know how to go through a card layout using the next and previous function, but how would one remove the current frame that the user is on? For example, if I have a program where I am…
ghart145
  • 65
  • 6
3
votes
2 answers

Java Swing - CardLayout, how to 'update' cards while running?

I am pretty new at . Java Swing, and am using the CardLayout for my application. In this app a user can create activities and, in an other JPanel, view the existing ones. I am having trouble updating the card (where the label is in). If I add the…
belens
  • 962
  • 1
  • 8
  • 18
3
votes
2 answers

Strange problem with java CardLayout in JFrame

hello i have a Jframe with a CardLayout and 3 cards. I have an ActionListener on a button on the first card. This code is working well: JButton btnLogin = new JButton("Login"); btnLogin.addActionListener(new ActionListener() { public void…
Laphroaig
  • 619
  • 4
  • 12
  • 26
3
votes
0 answers

How to use card layout with IntelliJ's form builder?

I'm having trouble getting my program to switch JPanels when I press the nextButton using card layout. This is what it looks like: I want the program to switch to the "customerSearch" JPanel. It has the Card Name & name of Card2. panelContainer has…
3
votes
2 answers

Showing the previous tab of CardLayout

I'm having trouble figuring this one out. The situation is no difficult to imagine so I hope I could post this without a sample code. I have JPanel with CardLayout. The panel contains several other panels as individual tabs. What I'm trying to…
Martin
  • 3,445
  • 4
  • 23
  • 21
3
votes
1 answer

how to return to my main panel in java?

I want to back to the main panel in my java application with a jMenuItem, my panels and other stuff are set with a CardLayout. So I have 3 panels and from any of them I want to be able to return to the first panel using this menu item to start a new…
Angel Ruvalcaba
  • 105
  • 1
  • 6
3
votes
2 answers

Android create item in GridView with round corners and ImageView

I have a GriView in which every element is a card with rounded corners. At the top of it there's an ImageView loaded from the net. I would like to fit the image inside the card so that it will have the top corners rounded. I've tryied with…
Lorenzo Barbagli
  • 1,241
  • 2
  • 16
  • 34
3
votes
2 answers

Event Handling Between Two Classes

I have been searching for hours and still haven't found what I need, nor any tutorials/help guides/forums to point me in the right direction. I have two separate classes that I need to implement an action listener. I'm able to go to one class from…
3
votes
1 answer

GridBagLayout misbehaving. Horizontal distribution problems

This is what I am trying to achieve: |--0--|--1--|--2--|--3--|--4--|--5--|--6--|--7--|--8--|--9--| 0 | |JLabe|l----|-----|-----|-----|-----|-----|-----|-----| 1 | | |JLabe|l----|-----|-----|-----|-----|-----|-----| 2 | | | …
SimpleProgrammer
  • 323
  • 3
  • 25
3
votes
1 answer

CardLayout (swing) with action listeners on buttons?

I've been trying to figure out CardLayout with action listeners on button (so like - starts on a load-up page- and on a button click switches to a different "card" my code won't even run right now i'm not entirely sure why - most implementations I…
gadu
  • 1,816
  • 1
  • 17
  • 31
1 2
3
37 38