本文整理汇总了Java中javax.swing.JLayer.getView方法的典型用法代码示例。如果您正苦于以下问题:Java JLayer.getView方法的具体用法?Java JLayer.getView怎么用?Java JLayer.getView使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JLayer
的用法示例。
在下文中一共展示了JLayer.getView方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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();
}
}
示例5: 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();
}
}