zack
8 years ago
8 changed files with 195 additions and 51 deletions
@ -0,0 +1,13 @@
|
||||
package com.fr.design.mainframe; |
||||
|
||||
/** |
||||
* Coder: zack |
||||
* Date: 2016/11/3 |
||||
* Time: 10:43 |
||||
*/ |
||||
public interface HelpDialogHandler { |
||||
/** |
||||
* 销毁 |
||||
*/ |
||||
void destroyHelpDialog(); |
||||
} |
@ -0,0 +1,44 @@
|
||||
package com.fr.design.mainframe; |
||||
|
||||
/** |
||||
* 帮助信息的面板由于需要滚动条所以采用了很挫的dialog做,dialog很多情况下不能主动关闭,这边控制一下 |
||||
* Coder: zack |
||||
* Date: 2016/11/2 |
||||
* Time: 16:34 |
||||
*/ |
||||
public class HelpDialogManager { |
||||
private static HelpDialogManager THIS; |
||||
private HelpDialogHandler handler; |
||||
|
||||
private HelpDialogManager() { |
||||
|
||||
} |
||||
|
||||
public HelpDialogHandler getPane() { |
||||
return handler; |
||||
} |
||||
|
||||
public void setPane(HelpDialogHandler dialog) { |
||||
if (dialog == this.handler) { |
||||
return; |
||||
} |
||||
//只允许一个dialog存在
|
||||
if (this.handler != null) { |
||||
handler.destroyHelpDialog(); |
||||
} |
||||
this.handler = dialog; |
||||
} |
||||
|
||||
public static HelpDialogManager getInstance() { |
||||
if (THIS == null) { |
||||
THIS = new HelpDialogManager(); |
||||
} |
||||
return THIS; |
||||
} |
||||
|
||||
public void destroyDialog() { |
||||
if (handler != null) { |
||||
handler.destroyHelpDialog(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,97 @@
|
||||
package com.fr.design.mainframe; |
||||
|
||||
import com.fr.design.gui.ibutton.UIButton; |
||||
import com.fr.design.icon.IconPathConstants; |
||||
import com.fr.general.IOUtils; |
||||
import com.fr.general.Inter; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
|
||||
/** |
||||
* Created with IntelliJ IDEA. |
||||
* User: zx |
||||
* Date: 14-7-24 |
||||
* Time: 上午9:09 |
||||
*/ |
||||
public class CoverPane extends JPanel { |
||||
|
||||
private UIButton editButton; |
||||
private AlphaComposite composite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 60 / 100.0F); |
||||
|
||||
public CoverPane() { |
||||
setLayout(getCoverLayout()); |
||||
setBackground(null); |
||||
setOpaque(false); |
||||
|
||||
editButton = new UIButton(Inter.getLocText("Edit"), IOUtils.readIcon(IconPathConstants.TD_EDIT_ICON_PATH)) { |
||||
@Override |
||||
public Dimension getPreferredSize() { |
||||
return new Dimension(60, 24); |
||||
} |
||||
}; |
||||
editButton.setBorderPainted(false); |
||||
editButton.setExtraPainted(false); |
||||
editButton.setBackground(new Color(176, 196, 222)); |
||||
add(editButton); |
||||
} |
||||
|
||||
public AlphaComposite getComposite() { |
||||
return composite; |
||||
} |
||||
|
||||
public void setComposite(AlphaComposite composite) { |
||||
this.composite = composite; |
||||
} |
||||
|
||||
public UIButton getEditButton() { |
||||
return editButton; |
||||
} |
||||
|
||||
public void setEditButton(UIButton editButton) { |
||||
this.editButton = editButton; |
||||
} |
||||
|
||||
protected LayoutManager getCoverLayout() { |
||||
return new LayoutManager() { |
||||
|
||||
@Override |
||||
public void removeLayoutComponent(Component comp) { |
||||
} |
||||
|
||||
@Override |
||||
public Dimension preferredLayoutSize(Container parent) { |
||||
return parent.getPreferredSize(); |
||||
} |
||||
|
||||
@Override |
||||
public Dimension minimumLayoutSize(Container parent) { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public void layoutContainer(Container parent) { |
||||
int width = parent.getParent().getWidth(); |
||||
int height = parent.getParent().getHeight(); |
||||
int preferWidth = editButton.getPreferredSize().width; |
||||
int preferHeight = editButton.getPreferredSize().height; |
||||
editButton.setBounds((width - preferWidth) / 2, (height - preferHeight) / 2, preferWidth, preferHeight); |
||||
} |
||||
|
||||
@Override |
||||
public void addLayoutComponent(String name, Component comp) { |
||||
} |
||||
}; |
||||
} |
||||
|
||||
|
||||
public void paint(Graphics g) { |
||||
Graphics2D g2d = (Graphics2D) g; |
||||
Composite oldComposite = g2d.getComposite(); |
||||
g2d.setComposite(composite); |
||||
g2d.setColor(Color.white); |
||||
g2d.fillRect(0, 0, getWidth(), getHeight()); |
||||
g2d.setComposite(oldComposite); |
||||
super.paint(g); |
||||
} |
||||
} |
Loading…
Reference in new issue