本文整理汇总了Java中javax.swing.JLayer类的典型用法代码示例。如果您正苦于以下问题:Java JLayer类的具体用法?Java JLayer怎么用?Java JLayer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JLayer类属于javax.swing包,在下文中一共展示了JLayer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: paint
import javax.swing.JLayer; //导入依赖的package包/类
@Override
public void paint(Graphics g, JComponent c) {
super.paint(g, c);
JLayer jlayer = (JLayer) c;
JFormattedTextField ftf = (JFormattedTextField) jlayer.getView();
if (!ftf.isEditValid()) {
Graphics2D g2 = (Graphics2D) g.create();
// Paint the red X.
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
int w = c.getWidth();
int h = c.getHeight();
int s = 8;
int pad = 4;
int x = w - pad - s;
int y = (h - s) / 2;
g2.setPaint(Color.red);
g2.fillRect(x, y, s + 1, s + 1);
g2.setPaint(Color.white);
g2.drawLine(x, y, x + s, y + s);
g2.drawLine(x, y + s, x + s, y);
g2.dispose();
}
}
示例2: paint
import javax.swing.JLayer; //导入依赖的package包/类
@Override
public void paint(Graphics gr, JComponent jc) {
super.paint(gr, jc);
if (jc instanceof JLayer<?>) {
JLayer<?> jlayer = (JLayer<?>) jc;
JTabbedPane tabPane = (JTabbedPane) jlayer.getView();
for (int i = 0; i < tabPane.getTabCount(); i++) {
Rectangle rect = tabPane.getBoundsAt(i);
Dimension dim = button.getPreferredSize();
int x0 = rect.x + rect.width - dim.width - 2;
int y0 = rect.y + (rect.height - dim.height) / 2;
Rectangle r2 = new Rectangle(x0, y0, dim.width, dim.height);
button.setForeground(r2.contains(pt) ? Color.RED : Color.BLACK);
SwingUtilities.paintComponent(gr, button, p0, r2);
}
}
}
示例3: processMouseEvent
import javax.swing.JLayer; //导入依赖的package包/类
@Override
protected void processMouseEvent(MouseEvent event, JLayer<? extends JTabbedPane> jl) {
if (event.getID() == MouseEvent.MOUSE_CLICKED) {
pt.setLocation(event.getPoint());
JTabbedPane tabbedPane = (JTabbedPane) jl.getView();
int index = tabbedPane.indexAtLocation(pt.x, pt.y);
if (index >= 0) {
Rectangle rect = tabbedPane.getBoundsAt(index);
Dimension d0 = button.getPreferredSize();
int x0 = rect.x + rect.width - d0.width - 2;
int y0 = rect.y + (rect.height - d0.height) / 2;
Rectangle r0 = new Rectangle(x0, y0, d0.width, d0.height);
if (r0.contains(pt)) {
tabbedPane.removeTabAt(index);
}
}
jl.getView().repaint();
}
}
示例4: CardCellRenderer
import javax.swing.JLayer; //导入依赖的package包/类
/**
* Creates a {@link CardCellRenderer} that is used by lists containing {@link Card}s.
*/
public CardCellRenderer() {
setVerticalTextPosition(SwingConstants.BOTTOM);
setHorizontalTextPosition(SwingConstants.CENTER);
setHorizontalAlignment(CENTER);
setOpaque(false);
layer = new JLayer<>(this, new CardLayerUI());
}
示例5: installUI
import javax.swing.JLayer; //导入依赖的package包/类
@Override
public void installUI(JComponent c) {
super.installUI(c);
JLayer jlayer = (JLayer)c;
jlayer.setLayerEventMask(
AWTEvent.MOUSE_EVENT_MASK |
AWTEvent.MOUSE_MOTION_EVENT_MASK
);
}
示例6: processMouseMotionEvent
import javax.swing.JLayer; //导入依赖的package包/类
@Override
protected void processMouseMotionEvent(MouseEvent e, JLayer l) {
Point p = SwingUtilities.convertPoint(e.getComponent(), e.getPoint(), l);
mX = p.x;
mY = p.y;
l.repaint();
}
示例7: installUI
import javax.swing.JLayer; //导入依赖的package包/类
@Override
public void installUI(JComponent jc) {
super.installUI(jc);
if (jc instanceof JLayer<?>) {
((JLayer<?>) jc).setLayerEventMask(AWTEvent.MOUSE_EVENT_MASK
| AWTEvent.MOUSE_MOTION_EVENT_MASK);
}
}
示例8: uninstallUI
import javax.swing.JLayer; //导入依赖的package包/类
@Override
public void uninstallUI(JComponent comp) {
if (comp instanceof JLayer<?>) {
((JLayer<?>) comp).setLayerEventMask(0);
super.uninstallUI(comp);
}
}
示例9: processMouseMotionEvent
import javax.swing.JLayer; //导入依赖的package包/类
@Override
protected void processMouseMotionEvent(MouseEvent e0, JLayer<? extends JTabbedPane> jl) {
pt.setLocation(e0.getPoint());
JTabbedPane tabbedPane = (JTabbedPane) jl.getView();
int index = tabbedPane.indexAtLocation(pt.x, pt.y);
if (index >= 0) {
tabbedPane.repaint(tabbedPane.getBoundsAt(index));
} else {
tabbedPane.repaint();
}
}
示例10: createTabPane
import javax.swing.JLayer; //导入依赖的package包/类
/**
* Creates the tab pane that holds all the tabs for the application.
*/
private void createTabPane() {
tabPane = new MainTabPane();
add(new JLayer<JTabbedPane>(tabPane, new CloseableTabbedPaneLayer()));
//add(tabPane);
}
示例11: paint
import javax.swing.JLayer; //导入依赖的package包/类
@Override
public void paint(Graphics g, JComponent c)
{
super.paint(g, c);
JLayer<?> jlayer = (JLayer<?>) c;
JFormattedTextField jFormattedTextField = (JFormattedTextField) jlayer
.getView();
if (jFormattedTextField.getFormatterFactory() != null
&& !jFormattedTextField.isEditValid())
{
Graphics2D g2 = (Graphics2D) g.create();
// Paint a red X
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
int w = c.getWidth();
int h = c.getHeight();
// int pad = 4;
int s = 10;
int pad = 10;
int x = w - pad - s;
int y = (h - s) / 2;
ImageIcon icon = IconBuilder
.build(frame.getMessenger().getConfig(),
IconBuilder.INVALID_FIELD);
g2.drawImage(icon.getImage(), x, y, null);
g2.dispose();
}
}
示例12: installUI
import javax.swing.JLayer; //导入依赖的package包/类
public void installUI(JComponent c) {
// System.out.println("install UI");
super.installUI(c);
JLayer jlayer = (JLayer) c;
// 启动鼠标事件和鼠标移动事件
// jlayer.setLayerEventMask(AWTEvent.MOUSE_EVENT_MASK
// | AWTEvent.MOUSE_MOTION_EVENT_MASK);
}
示例13: ProductSceneViewTopComponent
import javax.swing.JLayer; //导入依赖的package包/类
public ProductSceneViewTopComponent(ProductSceneView view, UndoRedo undoRedo) {
super(view.getRaster());
this.view = view;
this.undoRedo = undoRedo != null ? undoRedo : UndoRedo.NONE;
this.nodeRenameHandler = new NodeRenameHandler();
this.selection = Selection.EMPTY;
setToolTipText(view.getRaster().getDescription());
setIcon(ImageUtilities.loadImage("org/esa/snap/rcp/icons/RsBandAsSwath.gif"));
updateDisplayName();
setName(getDisplayName());
/*
// checkme - this is ugly and not wanted (nf), the node will either passed in or we'll have
// a central node factory, e.g. via an ExtensionObject
Node node = null;
try {
if (raster instanceof Mask) {
node = new MNode((Mask) raster, undoRedo);
} else if (raster instanceof Band) {
node = new BNode((Band) raster, undoRedo);
} else if (raster instanceof TiePointGrid) {
node = new TPGNode((TiePointGrid) raster, undoRedo);
}
} catch (IntrospectionException e) {
Exceptions.printStackTrace(e);
}
if (node != null) {
setActivatedNodes(new Node[]{node});
}
*/
setLayout(new BorderLayout());
add(new JLayer<>(this.view, new ProductSceneViewLayerUI()), BorderLayout.CENTER);
}
示例14: HostFrame
import javax.swing.JLayer; //导入依赖的package包/类
public HostFrame(LumpiApplication<? extends LumpiApplicationContext, ? extends BindableWindow> application) {
this.appRef = new WeakReference<>(application);
this.pca = new PropertyChangeAwareAdapter(this);
this.windowListener = new WindowListener();
this.displayHost = initDisplayHost();
this.layer = new JLayer<>();
init();
}
示例15: processMouseEvent
import javax.swing.JLayer; //导入依赖的package包/类
@Override
protected void processMouseEvent( MouseEvent e, JLayer<? extends JPanel> panel ) {
super.processMouseEvent( e, panel );
if( e.getButton() == MouseEvent.BUTTON1 )
e.consume();
}