src/share/classes/java/awt/CardLayout.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 1995, 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
--- 1,7 ----
/*
! * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
*** 221,232 ****
synchronized (comp.getTreeLock()) {
if (!vector.isEmpty()) {
comp.setVisible(false);
}
for (int i=0; i < vector.size(); i++) {
! if (((Card)vector.get(i)).name.equals(name)) {
! ((Card)vector.get(i)).comp = comp;
return;
}
}
vector.add(new Card(name, comp));
}
--- 221,232 ----
synchronized (comp.getTreeLock()) {
if (!vector.isEmpty()) {
comp.setVisible(false);
}
for (int i=0; i < vector.size(); i++) {
! if ((vector.get(i)).name.equals(name)) {
! (vector.get(i)).comp = comp;
return;
}
}
vector.add(new Card(name, comp));
}
*** 240,250 ****
* @see java.awt.Container#removeAll()
*/
public void removeLayoutComponent(Component comp) {
synchronized (comp.getTreeLock()) {
for (int i = 0; i < vector.size(); i++) {
! if (((Card)vector.get(i)).comp == comp) {
// if we remove current component we should show next one
if (comp.isVisible() && (comp.getParent() != null)) {
next(comp.getParent());
}
--- 240,250 ----
* @see java.awt.Container#removeAll()
*/
public void removeLayoutComponent(Component comp) {
synchronized (comp.getTreeLock()) {
for (int i = 0; i < vector.size(); i++) {
! if ((vector.get(i)).comp == comp) {
// if we remove current component we should show next one
if (comp.isVisible() && (comp.getParent() != null)) {
next(comp.getParent());
}
*** 525,535 ****
synchronized (parent.getTreeLock()) {
checkLayout(parent);
Component next = null;
int ncomponents = vector.size();
for (int i = 0; i < ncomponents; i++) {
! Card card = (Card)vector.get(i);
if (card.name.equals(name)) {
next = card.comp;
currentCard = i;
break;
}
--- 525,535 ----
synchronized (parent.getTreeLock()) {
checkLayout(parent);
Component next = null;
int ncomponents = vector.size();
for (int i = 0; i < ncomponents; i++) {
! Card card = vector.get(i);
if (card.name.equals(name)) {
next = card.comp;
currentCard = i;
break;
}
*** 572,583 ****
// pre-1.4 stream
Hashtable<String, Component> tab = (Hashtable)f.get("tab", null);
vector = new Vector<>();
if (tab != null && !tab.isEmpty()) {
for (Enumeration<String> e = tab.keys() ; e.hasMoreElements() ; ) {
! String key = (String)e.nextElement();
! Component comp = (Component)tab.get(key);
vector.add(new Card(key, comp));
if (comp.isVisible()) {
currentCard = vector.size() - 1;
}
}
--- 572,583 ----
// pre-1.4 stream
Hashtable<String, Component> tab = (Hashtable)f.get("tab", null);
vector = new Vector<>();
if (tab != null && !tab.isEmpty()) {
for (Enumeration<String> e = tab.keys() ; e.hasMoreElements() ; ) {
! String key = e.nextElement();
! Component comp = tab.get(key);
vector.add(new Card(key, comp));
if (comp.isVisible()) {
currentCard = vector.size() - 1;
}
}
*** 595,605 ****
throws IOException
{
Hashtable<String, Component> tab = new Hashtable<>();
int ncomponents = vector.size();
for (int i = 0; i < ncomponents; i++) {
! Card card = (Card)vector.get(i);
tab.put(card.name, card.comp);
}
ObjectOutputStream.PutField f = s.putFields();
f.put("hgap", hgap);
--- 595,605 ----
throws IOException
{
Hashtable<String, Component> tab = new Hashtable<>();
int ncomponents = vector.size();
for (int i = 0; i < ncomponents; i++) {
! Card card = vector.get(i);
tab.put(card.name, card.comp);
}
ObjectOutputStream.PutField f = s.putFields();
f.put("hgap", hgap);