本文整理汇总了Java中javax.swing.JComponent.revalidate方法的典型用法代码示例。如果您正苦于以下问题:Java JComponent.revalidate方法的具体用法?Java JComponent.revalidate怎么用?Java JComponent.revalidate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JComponent
的用法示例。
在下文中一共展示了JComponent.revalidate方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: importUnit
import javax.swing.JComponent; //导入方法依赖的package包/类
/**
* Import a unit specified by its label to a component.
*
* @param comp The component to import to.
* @param label The {@code UnitLabel} specifying the unit.
* @param oldSelectedUnit A label for the old {@code Unit} to restore
* selection to.
* @return True if the import succeeds.
*/
private boolean importUnit(JComponent comp, UnitLabel label,
UnitLabel oldSelectedUnit) {
if (!(comp instanceof DropTarget)) return importFail(comp, "unit");
final DropTarget target = (DropTarget)comp;
// Check if the unit can be dragged to comp.
final Unit unit = label.getUnit();
if (!target.accepts(unit)) {
return importFail(comp, "unacceptable unit (" + unit + ")");
}
// OK, add it.
target.add(label, true);
// Update unit selection.
// New unit selection has already been taken care of
// if this unit was moved to ToAmericaPanel
restoreSelection(oldSelectedUnit);
comp.revalidate();
return true;
}
示例2: refreshMenu
import javax.swing.JComponent; //导入方法依赖的package包/类
private void refreshMenu() {
if (menuItems != null && menuItems.length > 0) {
firstIndex = Math.max(topFixedCount, firstIndex);
firstIndex = Math.min(menuItems.length - bottomFixedCount - scrollCount, firstIndex);
upItem.setEnabled(firstIndex > topFixedCount);
downItem.setEnabled(firstIndex + scrollCount < menuItems.length - bottomFixedCount);
menu.removeAll();
for (int i = 0; i < topFixedCount; i++) {
menu.add(menuItems[i]);
}
if (topFixedCount > 0) {
menu.addSeparator();
}
menu.add(upItem);
for (int i = firstIndex; i < scrollCount + firstIndex; i++) {
menu.add(menuItems[i]);
}
menu.add(downItem);
if (bottomFixedCount > 0) {
menu.addSeparator();
}
for (int i = menuItems.length - bottomFixedCount; i < menuItems.length; i++) {
menu.add(menuItems[i]);
}
JComponent parent = (JComponent) upItem.getParent();
parent.revalidate();
parent.repaint();
}
}
示例3: refreshMenu
import javax.swing.JComponent; //导入方法依赖的package包/类
private void refreshMenu() {
if (menuItems != null && menuItems.length > 0) {
firstIndex = Math.max(topFixedCount, firstIndex);
firstIndex = Math.min(menuItems.length - bottomFixedCount - scrollCount, firstIndex);
upItem.setEnabled(firstIndex > topFixedCount);
downItem.setEnabled(firstIndex + scrollCount < menuItems.length - bottomFixedCount);
menu.removeAll();
for (int i = 0; i < topFixedCount; i++) {
menu.add(menuItems[i]);
}
if (topFixedCount > 0) {
menu.add(new JSeparator());
}
menu.add(upItem);
for (int i = firstIndex; i < scrollCount + firstIndex; i++) {
menu.add(menuItems[i]);
}
menu.add(downItem);
if (bottomFixedCount > 0) {
menu.add(new JSeparator());
}
for (int i = menuItems.length - bottomFixedCount; i < menuItems.length; i++) {
menu.add(menuItems[i]);
}
JComponent parent = (JComponent) upItem.getParent();
parent.revalidate();
parent.repaint();
}
}
示例4: refreshMenu
import javax.swing.JComponent; //导入方法依赖的package包/类
private void refreshMenu() {
if (menuItems != null && menuItems.length > 0) {
firstIndex = Math.max(topFixedCount, firstIndex);
firstIndex = Math.min(menuItems.length - bottomFixedCount - scrollCount, firstIndex);
upItem.setEnabled(firstIndex > topFixedCount);
downItem.setEnabled(firstIndex + scrollCount < menuItems.length - bottomFixedCount);
menu.removeAll();
for (int i = 0; i < topFixedCount; i++) {
menu.add(menuItems[i]);
}
if (topFixedCount > 0) {
menu.addSeparator();
}
menu.add(upItem);
for (int i = firstIndex; i < scrollCount + firstIndex; i++) {
menu.add(menuItems[i]);
}
menu.add(downItem);
if (bottomFixedCount > 0) {
menu.addSeparator();
}
for (int i = menuItems.length - bottomFixedCount; i < menuItems.length; i++) {
menu.add(menuItems[i]);
}
JComponent parent = (JComponent) upItem.getParent();
parent.revalidate();
parent.repaint();
}
}
示例5: selectPlatform
import javax.swing.JComponent; //导入方法依赖的package包/类
private void selectPlatform (Node pNode) {
Component active = null;
for (Component c : cards.getComponents()) {
if (c.isVisible() &&
(c == jPanel1 || c == messageArea)) {
active = c;
break;
}
}
final Dimension lastSize = active == null ?
null :
active.getSize();
this.clientArea.removeAll();
this.messageArea.removeAll();
this.removeButton.setEnabled (false);
if (pNode == null) {
((CardLayout)cards.getLayout()).last(cards);
return;
}
JComponent target = messageArea;
JComponent owner = messageArea;
JavaPlatform platform = pNode.getLookup().lookup(JavaPlatform.class);
if (pNode != getExplorerManager().getRootContext()) {
if (platform != null) {
this.removeButton.setEnabled (canRemove(platform, pNode.getLookup().lookup(DataObject.class)));
if (!platform.getInstallFolders().isEmpty()) {
this.platformName.setText(pNode.getDisplayName());
for (FileObject installFolder : platform.getInstallFolders()) {
File file = FileUtil.toFile(installFolder);
if (file != null) {
this.platformHome.setText (file.getAbsolutePath());
}
}
target = clientArea;
owner = jPanel1;
}
}
Component component = null;
if (pNode.hasCustomizer()) {
component = pNode.getCustomizer();
}
if (component == null) {
final PropertySheet sp = new PropertySheet();
sp.setNodes(new Node[] {pNode});
component = sp;
}
addComponent(target, component);
}
if (lastSize != null) {
final Dimension newSize = owner.getPreferredSize();
final Dimension updatedSize = new Dimension(
Math.max(lastSize.width, newSize.width),
Math.max(lastSize.height, newSize.height));
if (!newSize.equals(updatedSize)) {
owner.setPreferredSize(updatedSize);
}
}
target.revalidate();
CardLayout cl = (CardLayout) cards.getLayout();
if (target == clientArea) {
cl.first (cards);
}
else {
cl.last (cards);
}
}
示例6: resizeContainer
import javax.swing.JComponent; //导入方法依赖的package包/类
final void resizeContainer() {
JComponent c = ( JComponent ) container.getParent();
c.invalidate();
c.revalidate();
c.doLayout();
}
示例7: selectPlatform
import javax.swing.JComponent; //导入方法依赖的package包/类
private void selectPlatform(Node pNode) {
Component active = null;
for (Component c : cards.getComponents()) {
if (c.isVisible()
&& (c == jPanel1 || c == messageArea)) {
active = c;
break;
}
}
final Dimension lastSize = active == null
? null
: active.getSize();
this.clientArea.removeAll();
this.messageArea.removeAll();
this.removeButton.setEnabled(false);
if (pNode == null) {
((CardLayout) cards.getLayout()).last(cards);
return;
}
JComponent target = messageArea;
JComponent owner = messageArea;
selectedPlatform = pNode.getLookup().lookup(AndroidSdk.class);
if (pNode != getExplorerManager().getRootContext()) {
if (selectedPlatform != null) {
mkDefault.setEnabled(!selectedPlatform.isDefaultSdk());
this.removeButton.setEnabled(!selectedPlatform.isDefaultSdk());
if (!selectedPlatform.getInstallFolders().isEmpty()) {
this.platformName.setText(pNode.getDisplayName());
for (FileObject installFolder : selectedPlatform.getInstallFolders()) {
File file = FileUtil.toFile(installFolder);
if (file != null) {
this.platformHome.setText(file.getAbsolutePath());
}
}
target = clientArea;
owner = jPanel1;
}
} else {
removeButton.setEnabled(false);
mkDefault.setEnabled(false);
}
Component component = null;
if (pNode.hasCustomizer()) {
component = pNode.getCustomizer();
}
if (component == null) {
final PropertySheet sp = new PropertySheet();
sp.setNodes(new Node[]{pNode});
component = sp;
}
addComponent(target, component);
}
if (lastSize != null) {
final Dimension newSize = owner.getPreferredSize();
final Dimension updatedSize = new Dimension(
Math.max(lastSize.width, newSize.width),
Math.max(lastSize.height, newSize.height));
if (!newSize.equals(updatedSize)) {
owner.setPreferredSize(updatedSize);
}
}
target.revalidate();
CardLayout cl = (CardLayout) cards.getLayout();
if (target == clientArea) {
cl.first(cards);
} else {
cl.last(cards);
}
}