Browse Source

Pull request #2299: 无jira 解决冲突

Merge in DESIGN/design from ~HADES/design:feature/10.0 to feature/10.0

* commit '9312bf5367d1a87ccbabf3bf7a5606f2021914c8':
  无jira任务 漏了冒号
  REPORT-38954&&REPORT-38927&&REPORT-38924&&REPORT-38896 修改Nullable的import
  REPORT-38954&&REPORT-38927&&REPORT-38924&&REPORT-38896 消除NPE
  REPORT-38954&&REPORT-38927&&REPORT-38924&&REPORT-38896 TopXCreator中添加XCreator的变量,绘制的时候禁用其双缓冲然后直接调用其paint方法
persist/11.0
Hades 4 years ago
parent
commit
9605b85427
  1. 2
      build.gradle
  2. 1
      designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java
  3. 35
      designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java
  4. 25
      designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java
  5. 15
      designer-form/src/main/java/com/fr/design/designer/creator/XCreatorUtils.java
  6. 17
      designer-form/src/main/java/com/fr/design/designer/creator/XElementCase.java
  7. 6
      designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java
  8. 6
      designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java
  9. 5
      designer-form/src/main/java/com/fr/design/designer/creator/XWParameterLayout.java
  10. 5
      designer-form/src/main/java/com/fr/design/designer/creator/XWTitleLayout.java
  11. 6
      designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java
  12. 1
      designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java
  13. 19
      designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java
  14. 39
      designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java
  15. 40
      designer-form/src/main/java/com/fr/design/mainframe/TopXCreator.java
  16. 40
      designer-form/src/main/java/com/fr/design/mainframe/TopXCreators.java
  17. 49
      designer-form/src/main/java/com/fr/design/mainframe/widget/topxcreator/TopXCreator.java

2
build.gradle

@ -73,7 +73,7 @@ allprojects {
implementation 'com.fr.decision:fine-decision:' + frVersion
implementation 'com.fr.schedule:fine-schedule:' + frVersion
implementation 'com.fr.report:fine-report-engine:' + frDevVersion
implementation 'com.fr.design:design-i18n' + frDevVersion
implementation 'com.fr.design:design-i18n:' + frDevVersion
testImplementation 'org.easymock:easymock:3.5.1'
testImplementation 'org.powermock:powermock-module-junit4:1.7.1'
testImplementation 'org.powermock:powermock-api-easymock:1.7.1'

1
designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java

@ -310,7 +310,6 @@ public class SelectionModel {
designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_DELETED);
setSelectedCreator(isInPara ? designer.getParaComponent() : designer.getRootComponent());
designer.getTopXCreators().refresh();
// 触发事件

35
designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java

@ -17,8 +17,6 @@ import com.fr.design.mainframe.CoverReportPane;
import com.fr.design.mainframe.EditingMouseListener;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.HelpDialogManager;
import com.fr.design.mainframe.widget.topxcreator.BasicTopXCreator;
import com.fr.design.mainframe.widget.topxcreator.TopXCreator;
import com.fr.design.mainframe.widget.editors.WLayoutBorderStyleEditor;
import com.fr.design.module.DesignModuleFactory;
import com.fr.form.ui.BaseChartEditor;
@ -231,6 +229,9 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
*/
public void paint(Graphics g) {
designerEditor.paintEditor(g, this.getSize());
if (coverPanel != null) {
coverPanel.setSize(this.getSize());
}
super.paint(g);
if (isEditing) {
g.setColor(INNER_BORDER_COLOR);
@ -361,34 +362,4 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
return false;
}
@Override
public BasicTopXCreator getTopXCreator() {
return new TopXChart(this);
}
private class TopXChart extends TopXCreator {
private final DesignerEditor designerEditor;
public TopXChart(XCreator creator) {
super(creator);
designerEditor = creator.getDesignerEditor();
Rectangle bounds = getBounds();
designerEditor.getEditorTarget().setBounds(bounds.x + 1, bounds.y + 1, bounds.width - 2, bounds.height - 2);
}
/**
* 更新designerEditor的大小
*/
protected void resetSize(Rectangle bounds) {
super.resetSize(bounds);
designerEditor.getEditorTarget().setBounds(bounds.x + 1, bounds.y + 1, bounds.width - 2, bounds.height - 2);
}
@Override
public void paint(Graphics g) {
designerEditor.paintEditor(g, this.getSize());
super.paint(g);
}
}
}

25
designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java

@ -19,7 +19,6 @@ import com.fr.design.mainframe.CoverReportPane;
import com.fr.design.mainframe.EditingMouseListener;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.NoSupportAuthorityEdit;
import com.fr.design.mainframe.widget.topxcreator.BasicTopXCreator;
import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.design.utils.gui.LayoutUtils;
import com.fr.form.ui.Widget;
@ -812,31 +811,7 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
return false;
}
/**
* 获得该组件的顶层显示组件
*/
@Nullable
public BasicTopXCreator getTopXCreator() {
return new BasicTopXCreator(this) {
@Override
protected void addComponent() {
Icon icon = new ImageIcon(getImage());
JLabel jLabel = new JLabel(icon, JLabel.CENTER);
jLabel.setSize(getSize());
this.add(jLabel);
}
};
}
/**
* 获得组件的图像
*/
public BufferedImage getImage() {
BufferedImage image = CoreGraphHelper.createBufferedImage(getWidth(), getHeight());
Graphics g = image.createGraphics();
this.paint(g);
return image;
}
/**
* 初始化组件的预定义信息

15
designer-form/src/main/java/com/fr/design/designer/creator/XCreatorUtils.java

@ -343,4 +343,19 @@ public class XCreatorUtils {
}
return xCreator != null;
}
/**
* 获取组件的最顶层XMainBorderLayout,没有则返回null
* */
@Nullable
public static XWCardMainBorderLayout getTopXMainBorderLayout(Container creator) {
XWCardMainBorderLayout result = null;
while (creator != null) {
if (creator instanceof XWCardMainBorderLayout) {
result = (XWCardMainBorderLayout) creator;
}
creator = creator.getParent();
}
return result;
}
}

17
designer-form/src/main/java/com/fr/design/designer/creator/XElementCase.java

@ -13,8 +13,6 @@ import com.fr.design.mainframe.widget.editors.ElementCaseToolBarEditor;
import com.fr.design.mainframe.widget.editors.PaddingMarginEditor;
import com.fr.design.mainframe.widget.editors.WLayoutBorderStyleEditor;
import com.fr.design.mainframe.widget.propertypane.BrowserFitPropertyEditor;
import com.fr.design.mainframe.widget.topxcreator.BasicTopXCreator;
import com.fr.design.mainframe.widget.topxcreator.TopXCreator;
import com.fr.form.FormElementCaseContainerProvider;
import com.fr.form.FormElementCaseProvider;
import com.fr.form.FormProvider;
@ -377,21 +375,6 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
return true;
}
@Override
public BasicTopXCreator getTopXCreator() {
return new TopXElementCase(this);
}
private class TopXElementCase extends TopXCreator {
private UILabel imageLabel;
public TopXElementCase(XCreator creator) {
super(creator);
imageLabel = initImageBackground();
add(imageLabel);
}
}
/**
* 初始化组件的预定义信息
*/

6
designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java

@ -7,7 +7,6 @@ import com.fr.design.form.util.XCreatorConstants;
import com.fr.design.fun.WidgetPropertyUIProvider;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.widget.editors.WLayoutBorderStyleEditor;
import com.fr.design.mainframe.widget.topxcreator.BasicTopXCreator;
import com.fr.form.ui.NameFormBackground;
import com.fr.form.ui.container.WAbsoluteBodyLayout;
@ -134,11 +133,6 @@ public class XWAbsoluteBodyLayout extends XWAbsoluteLayout {
return false;
}
@Override
public BasicTopXCreator getTopXCreator() {
return null;
}
/**
* 初始化组件的预定义信息
*/

6
designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java

@ -25,8 +25,6 @@ import com.fr.design.mainframe.FormArea;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.WidgetHelpDialog;
import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.design.mainframe.widget.topxcreator.BasicTopXCreator;
import com.fr.design.mainframe.widget.topxcreator.TopXCreator;
import com.fr.form.ui.Connector;
import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WAbsoluteLayout;
@ -610,8 +608,4 @@ public class XWAbsoluteLayout extends XLayoutContainer {
}
}
@Override
public BasicTopXCreator getTopXCreator() {
return new TopXCreator(this);
}
}

5
designer-form/src/main/java/com/fr/design/designer/creator/XWParameterLayout.java

@ -15,7 +15,6 @@ import com.fr.design.mainframe.widget.editors.BooleanEditor;
import com.fr.design.mainframe.widget.editors.WidgetDisplayPosition;
import com.fr.design.mainframe.widget.renderer.BackgroundRenderer;
import com.fr.design.mainframe.widget.renderer.WidgetDisplayPositionRender;
import com.fr.design.mainframe.widget.topxcreator.BasicTopXCreator;
import com.fr.form.ui.container.WBorderLayout;
import com.fr.form.ui.container.WFitLayout;
import com.fr.form.ui.container.WParameterLayout;
@ -252,10 +251,6 @@ public class XWParameterLayout extends XWAbsoluteLayout {
return false;
}
@Override
public BasicTopXCreator getTopXCreator() {
return null;
}
}

5
designer-form/src/main/java/com/fr/design/designer/creator/XWTitleLayout.java

@ -7,7 +7,6 @@ import com.fr.design.designer.beans.LayoutAdapter;
import com.fr.design.designer.beans.adapters.layout.FRTitleLayoutAdapter;
import com.fr.design.form.layout.FRTitleLayout;
import com.fr.design.fun.WidgetPropertyUIProvider;
import com.fr.design.mainframe.widget.topxcreator.BasicTopXCreator;
import com.fr.form.ui.Label;
import com.fr.form.ui.Widget;
import com.fr.form.ui.WidgetTitle;
@ -191,8 +190,4 @@ public class XWTitleLayout extends DedicateLayoutContainer {
return creator.getWidgetPropertyUIProviders();
}
@Override
public BasicTopXCreator getTopXCreator() {
return getEditingChildCreator().getTopXCreator();
}
}

6
designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java

@ -23,8 +23,6 @@ import com.fr.design.mainframe.EditingMouseListener;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.WidgetHelpDialog;
import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.design.mainframe.widget.topxcreator.BasicTopXCreator;
import com.fr.design.mainframe.widget.topxcreator.TopXCreator;
import com.fr.form.event.Listener;
import com.fr.form.ui.CardSwitchButton;
import com.fr.form.ui.LayoutBorderStyle;
@ -515,8 +513,4 @@ public class XWCardMainBorderLayout extends XWBorderLayout {
return true;
}
@Override
public BasicTopXCreator getTopXCreator() {
return new TopXCreator(this);
}
}

1
designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java

@ -90,7 +90,6 @@ public class ComponentTree extends JTree {
public void setSelectionPath(TreePath path) {
// 不管点击哪一项,都要先退出编辑状态(图表、报表块、绝对布局、tab块)
designer.stopEditing(path);
designer.getTopXCreators().refresh();
super.setSelectionPath(path);
}

19
designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java

@ -316,7 +316,6 @@ public class EditingMouseListener extends MouseInputAdapter {
XCreator component = designer.getComponentAt(e);
setCoverPaneNotDisplay(component, e, false);
designer.getTopXCreators().displayCoverPane(e);
if (processTopLayoutMouseMove(component, e)) {
return;
@ -406,16 +405,7 @@ public class EditingMouseListener extends MouseInputAdapter {
}
private void setCoverPaneNotDisplay(XCreator component, MouseEvent e, boolean isLinkedHelpDialog) {
if (xElementCase != null) {
int x = getParentPositionX(xElementCase, 0) - designer.getArea().getHorizontalValue();
int y = getParentPositionY(xElementCase, 0) - designer.getArea().getVerticalValue();
Rectangle rect = new Rectangle(x, y, xElementCase.getWidth(), xElementCase.getHeight());
if (rect.contains(e.getPoint())) {
return;
}
xElementCase.displayCoverPane(false);
}
if (xChartEditor != null) {
xChartEditor.displayCoverPane(false);
}
@ -426,6 +416,15 @@ public class EditingMouseListener extends MouseInputAdapter {
if (xTopLayoutContainer != null) {
xTopLayoutContainer.setMouseEnter(false);
}
//不知道为什么要对XElementCase进行判断,但是直接return会有bug,所以把他放在最后
if (xElementCase != null) {
int x = getParentPositionX(xElementCase, 0) - designer.getArea().getHorizontalValue();
int y = getParentPositionY(xElementCase, 0) - designer.getArea().getVerticalValue();
Rectangle rect = new Rectangle(x, y, xElementCase.getWidth(), xElementCase.getHeight());
if (!rect.contains(e.getPoint())) {
xElementCase.displayCoverPane(false);
}
}
designer.repaint();
}

39
designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java

@ -35,9 +35,8 @@ import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWAbsoluteBodyLayout;
import com.fr.design.designer.creator.XWAbsoluteLayout;
import com.fr.design.designer.creator.XWBorderLayout;
import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.designer.creator.XWParameterLayout;
import com.fr.design.designer.creator.XWTitleLayout;
import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout;
import com.fr.design.designer.creator.cardlayout.XWTabFitLayout;
import com.fr.design.designer.properties.FormWidgetAuthorityEditPane;
import com.fr.design.dialog.FineJOptionPane;
@ -46,7 +45,6 @@ import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.form.util.XCreatorConstants;
import com.fr.design.fun.RightSelectionHandlerProvider;
import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus;
import com.fr.design.mainframe.widget.topxcreator.TopXCreators;
import com.fr.design.menu.MenuDef;
import com.fr.design.menu.ShortCut;
import com.fr.design.menu.ToolBarDef;
@ -65,7 +63,6 @@ import com.fr.form.ui.Widget;
import com.fr.form.ui.WidgetValue;
import com.fr.form.ui.container.WBorderLayout;
import com.fr.form.ui.container.WFitLayout;
import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger;
import com.fr.log.FineLoggerFactory;
@ -837,47 +834,35 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
/**
* 从已选择的组件中找x,y所在的组件
*/
private XCreator xCreatorAt(int x, int y,XCreator root) {
private XCreator xCreatorAt(int x, int y, XCreator root) {
XCreator[] xCreators = selectionModel.getSelection().getSelectedCreators();
for (XCreator creator : xCreators) {
boolean shouldContinue = creator == null
|| !creator.isVisible()
|| !XCreatorUtils.containComponent(root, creator)
|| creator instanceof XWAbsoluteBodyLayout
|| creator instanceof XWFitLayout
|| creator instanceof XWParameterLayout;
|| !XCreatorUtils.containComponent(root, creator);
if (shouldContinue) {
continue;
}
//如果组件为XWCardMainBorderLayout的子组件,直接从XWCardMainBorderLayout中去找
XWCardMainBorderLayout borderLayout = XCreatorUtils.getTopXMainBorderLayout(creator);
if (borderLayout != null) {
return xCreatorAt(x, y, borderLayout, null);
}
if (creator instanceof XLayoutContainer) {
return xCreatorAt(x, y, creator, null);
}
x -= creator.getX();
y -= creator.getY();
Rectangle rect = ComponentUtils.computeVisibleRect(creator);
rect.y += nestTabCount(creator) * WCardMainBorderLayout.TAB_HEIGHT;
// 判断是否处于交叉区域
if (!isIntersectArea(x, y, rect)) {
continue;
}
if (creator instanceof XWTitleLayout) {
return creator.getEditingChildCreator();
}
return xCreatorAt(x, y, creator, null);
return creator;
}
return null;
}
/**
* 计算嵌套的tab层数
*/
private int nestTabCount(Container xCreator) {
if (xCreator == null) {
return 0;
}
if (xCreator instanceof XWTabFitLayout) {
return 1 + nestTabCount(xCreator.getParent());
}
return nestTabCount(xCreator.getParent());
}
/**
* 刷新顶层组件
* */

40
designer-form/src/main/java/com/fr/design/mainframe/widget/topxcreator/BasicTopXCreator.java → designer-form/src/main/java/com/fr/design/mainframe/TopXCreator.java

@ -1,24 +1,29 @@
package com.fr.design.mainframe.widget.topxcreator;
package com.fr.design.mainframe;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.design.utils.ComponentUtils;
import com.fr.stable.CoreGraphHelper;
import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
/**
* @Author: Yuan.Wang
* @Date: 2020/8/31
*/
public class BasicTopXCreator extends JComponent {
private FormDesigner designer;
private XCreator creator;
public class TopXCreator extends JComponent {
private final FormDesigner designer;
private final XCreator creator;
public BasicTopXCreator(XCreator creator) {
this.designer = WidgetPropertyPane.getInstance().getEditingFormDesigner();
public TopXCreator(FormDesigner designer, XCreator creator) {
this.designer = designer;
this.creator = creator;
init();
}
@ -28,30 +33,16 @@ public class BasicTopXCreator extends JComponent {
setBackground(null);
setLayout(null);
setBounds(calculateBounds());
addComponent();
}
//子类可能会重写该方法
protected void resetSize(Rectangle bounds) {
//do nothing
}
protected void addComponent() {
}
/**
* 重新设置组件大小
* */
public void resizeTopXCreator() {
Rectangle bounds=calculateBounds();
setBounds(bounds);
resetSize(bounds);
setBounds(calculateBounds());
}
public void displayCoverPane(MouseEvent e, boolean visible) {}
/**
* 计算显示大小
* */
@ -63,8 +54,15 @@ public class BasicTopXCreator extends JComponent {
return bounds;
}
@Override
public void paint(Graphics g) {
super.paint(g);
ArrayList<JComponent> dbcomponents = new ArrayList<JComponent>();
// 禁止双缓冲
ComponentUtils.disableBuffer(creator, dbcomponents);
creator.paint(g);
// 恢复双缓冲
ComponentUtils.resetBuffer(dbcomponents);
}
}

40
designer-form/src/main/java/com/fr/design/mainframe/widget/topxcreator/TopXCreators.java → designer-form/src/main/java/com/fr/design/mainframe/TopXCreators.java

@ -1,11 +1,10 @@
package com.fr.design.mainframe.widget.topxcreator;
package com.fr.design.mainframe;
import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.beans.models.SelectionModel;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.mainframe.FormDesigner;
import java.awt.event.MouseEvent;
import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout;
import javax.swing.*;
import java.awt.*;
@ -31,7 +30,7 @@ public class TopXCreators extends JComponent {
setBackground(null);
setOpaque(false);
designer.addDesignerEditListener(e -> {
if (e.getCreatorEventID() == DesignerEvent.CREATOR_EDITED) {
if (e.getCreatorEventID() == DesignerEvent.CREATOR_SELECTED) {
refresh();
}
});
@ -52,28 +51,6 @@ public class TopXCreators extends JComponent {
super.paint(g);
}
@Override
public void setVisible(boolean aFlag) {
super.setVisible(aFlag);
for (int i = 0, count = getComponentCount(); i < count; i++) {
if (getComponent(i) instanceof TopXCreator) {
TopXCreator xCreator = (TopXCreator) getComponent(i);
xCreator.displayCoverPane(aFlag);
}
}
repaint();
}
/**
* 依据MouseEvent坐标来设置是否显示蒙层
*/
public void displayCoverPane(MouseEvent e) {
for (int i = 0, count = getComponentCount(); i < count; i++) {
BasicTopXCreator xCreator = (BasicTopXCreator) getComponent(i);
xCreator.displayCoverPane(e, isVisible());
}
}
/**
* 加入被选择的组件
*/
@ -81,10 +58,9 @@ public class TopXCreators extends JComponent {
SelectionModel selectionModel = designer.getSelectionModel();
XCreator[] xCreators = selectionModel.getSelection().getSelectedCreators();
for (XCreator creator : xCreators) {
BasicTopXCreator topXCreator = creator.getTopXCreator();
if (topXCreator != null) {
add(topXCreator);
}
XWCardMainBorderLayout topXMainBorderLayout = XCreatorUtils.getTopXMainBorderLayout(creator);
TopXCreator topXCreator = topXMainBorderLayout == null ? new TopXCreator(designer, creator) : new TopXCreator(designer, topXMainBorderLayout);
add(topXCreator);
}
}
@ -93,7 +69,7 @@ public class TopXCreators extends JComponent {
*/
private void resizeTopXCreators() {
for (int i = 0, count = getComponentCount(); i < count; i++) {
BasicTopXCreator topXCreator = (BasicTopXCreator) getComponent(i);
TopXCreator topXCreator = (TopXCreator) getComponent(i);
topXCreator.resizeTopXCreator();
}
repaint();

49
designer-form/src/main/java/com/fr/design/mainframe/widget/topxcreator/TopXCreator.java

@ -1,49 +0,0 @@
package com.fr.design.mainframe.widget.topxcreator;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.mainframe.CoverReportPane;
import java.awt.*;
import java.awt.event.MouseEvent;
/**
* @Author: Yuan.Wang
* @Date: 2020/8/26
*/
public class TopXCreator extends BasicTopXCreator {
private final CoverReportPane coverPanel;
public TopXCreator(XCreator creator) {
super(creator);
coverPanel = new CoverReportPane();
init();
}
private void init() {
coverPanel.setSize(getSize());
coverPanel.setVisible(false);
add(coverPanel);
}
protected void resetSize(Rectangle bounds) {
coverPanel.setSize(getSize());
}
/**
* 设置是否显示蒙层
* */
public void displayCoverPane(boolean visible) {
coverPanel.setVisible(visible);
}
/**
* 依据鼠标事件和visible设置是否显示蒙层
* */
public void displayCoverPane(MouseEvent event, boolean visible) {
boolean isVisible = visible && getBounds().contains(event.getX(), event.getY());
coverPanel.setVisible(isVisible);
}
}
Loading…
Cancel
Save