15. februar 2000 - 12:17Der er
4 kommentarer og 1 løsning
CardLayout
I need to be able to read which card in my cardlayout I am currently viewing. I have put my card contense inside two panels that have been added to the cardlayout they have in turn been added to an array (two cards total), this works fine. It is in another class(a frame) that I view the cards and switch between them, this also works fine. From a menu I call a method and this is were the problem is. The method has to, based upon which card is currently being viewed, clear all the textfields in the card. My problem is that I can't figure out how to tell which card I'm viewing, calling the first and last methods doesn't work. I need to specificaly check which card is being viewed. How do I do this ?
Denne side indeholder artikler med forskellige perspektiver på Identity & Access Management i private og offentlige organisationer. Artiklerne behandler aktuelle IAM-emner og leveres af producenter, rådgivere og implementeringspartnere.
Eeeks...there is no available method built into the cardlayout class that does what you want. You can either try to deduct the information from the toString method, if possible, or you can make your own extension of CardLayout.
Something like the following should work:
class MyCardLayout extends CardLayout {
public String getCurrentCard() {
int ncomponents = parent.getComponentCount(); for (int i = 0 ; i < ncomponents ; i++) { Component comp = parent.getComponent(i); if (comp.visible) { return comp.name; } } return null; } }
Du har her på det sidste besvaret en del af mine spørgsmål. Jeg er for tiden i praktik og arbejder sammen med en medstuderende på et mindre program. Vi vil gerne tilbyde dig en plads i listen af folk der har hjulpet os (credits). Du kan skrive en kommentar her eller emaile mig på Kobojt@hotmail.com hvis du er interesseret.
Kobojt
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.