本文整理汇总了Java中java.awt.event.ComponentEvent.getComponent方法的典型用法代码示例。如果您正苦于以下问题:Java ComponentEvent.getComponent方法的具体用法?Java ComponentEvent.getComponent怎么用?Java ComponentEvent.getComponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.event.ComponentEvent
的用法示例。
在下文中一共展示了ComponentEvent.getComponent方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: componentShown
import java.awt.event.ComponentEvent; //导入方法依赖的package包/类
/**
* May be called for either component or horizontal scrollbar.
*/
public @Override void componentShown(ComponentEvent e) {
// Called when horizontal scrollbar gets visible
// (but the same listener added to component as well so must check first)
// Check whether present caret position will not get hidden
// under horizontal scrollbar and if so scroll the view
Component hScrollBar = e.getComponent();
if (hScrollBar != component) { // really called for horizontal scrollbar
Component scrollPane = hScrollBar.getParent();
if (caretBounds != null && scrollPane instanceof JScrollPane) {
Rectangle viewRect = ((JScrollPane)scrollPane).getViewport().getViewRect();
Rectangle hScrollBarRect = new Rectangle(
viewRect.x,
viewRect.y + viewRect.height,
hScrollBar.getWidth(),
hScrollBar.getHeight()
);
if (hScrollBarRect.intersects(caretBounds)) {
// Update caret's position
dispatchUpdate(true); // should be visible so scroll the view
}
}
}
}
示例2: componentResized
import java.awt.event.ComponentEvent; //导入方法依赖的package包/类
/**
* May be called for either component or horizontal scrollbar.
*/
public @Override void componentResized(ComponentEvent e) {
Component c = e.getComponent();
if (c == component) { // called for component
// In case the caretBounds are still null
// (component not connected to hierarchy yet or it has zero size
// so the modelToView() returned null) re-attempt to compute the bounds.
CaretItem caret = getLastCaretItem();
if (caret.getCaretBounds() == null) {
dispatchUpdate(false);
resetBlink();
if (caret.getCaretBounds() != null) { // detach the listener - no longer necessary
c.removeComponentListener(this);
}
}
}
}
示例3: eventDispatched
import java.awt.event.ComponentEvent; //导入方法依赖的package包/类
/**
* Called when event is dispatched. WindowEvent.WINDOW_OPENED events for
* JFrames are processed here to loadSettings.
*
* @param evt the AWTEvent. Only WINDOW_OPENED events are processed to
* loadSettings
* @see #loadSettings
*/
@Override
public void eventDispatched(AWTEvent evt) {
try {
if (evt.getID() == WindowEvent.WINDOW_OPENED) {
ComponentEvent cev = (ComponentEvent) evt;
if (cev.getComponent() instanceof JFrame) {
// log.info("event: " + evt);
JFrame frame = (JFrame) cev.getComponent();
loadSettings(frame);
}
}
} catch (Exception ex) {
log.warning(ex.toString());
}
}
示例4: componentResized
import java.awt.event.ComponentEvent; //导入方法依赖的package包/类
/**
* May be called for either component or horizontal scrollbar.
*/
public @Override void componentResized(ComponentEvent e) {
Component c = e.getComponent();
if (c == component) { // called for component
// In case the caretBounds are still null
// (component not connected to hierarchy yet or it has zero size
// so the modelToView() returned null) re-attempt to compute the bounds.
if (caretBounds == null) {
dispatchUpdate(true);
if (caretBounds != null) { // detach the listener - no longer necessary
c.removeComponentListener(this);
}
}
}
}
示例5: componentShown
import java.awt.event.ComponentEvent; //导入方法依赖的package包/类
/**
* May be called for either component or horizontal scrollbar.
*/
public @Override void componentShown(ComponentEvent e) {
// Called when horizontal scrollbar gets visible
// (but the same listener added to component as well so must check first)
// Check whether present caret position will not get hidden
// under horizontal scrollbar and if so scroll the view
Component hScrollBar = e.getComponent();
/* The following should already be handled in update()
if (hScrollBar != component) { // really called for horizontal scrollbar
Component scrollPane = hScrollBar.getParent();
boolean needsScroll = false;
List<CaretInfo> sortedCarets = getSortedCarets();
for (CaretInfo caret : sortedCarets) { // TODO This is wrong, but a quick prototype
CaretItem caretItem = caret.getCaretItem();
if (caretItem.getCaretBounds() != null && scrollPane instanceof JScrollPane) {
Rectangle viewRect = ((JScrollPane)scrollPane).getViewport().getViewRect();
Rectangle hScrollBarRect = new Rectangle(
viewRect.x,
viewRect.y + viewRect.height,
hScrollBar.getWidth(),
hScrollBar.getHeight()
);
if (hScrollBarRect.intersects(caretItem.getCaretBounds())) {
// Update caret's position
needsScroll = true;
}
}
}
if (needsScroll) {
resetBlink();
dispatchUpdate(false);
}
}
*/
}
示例6: componentShown
import java.awt.event.ComponentEvent; //导入方法依赖的package包/类
public void componentShown(ComponentEvent e) {
JMenu menu = (JMenu) e.getComponent();
String containerCtx = getContainerContext(menu);
System.err.println("ComponentShown: Menu" + containerCtx + " - " + menu);
populateMenu(containerCtx, menu);
getEngine().notifyMenuShown (containerCtx, menu);
}
示例7: componentShown
import java.awt.event.ComponentEvent; //导入方法依赖的package包/类
@Override
public void componentShown(ComponentEvent e) {
JFrame frame = (JFrame) e.getComponent();
runActualTest(device, latch, frame, result);
frame.setVisible(false);
frame.dispose();
latch.countDown();
}
示例8: getImageCanvas
import java.awt.event.ComponentEvent; //导入方法依赖的package包/类
public ImageCanvas getImageCanvas(ComponentEvent e) {
Component component = e.getComponent();
return component instanceof ImageCanvas ? (ImageCanvas)component :
(component instanceof ImageWindow ? ((ImageWindow)component).getCanvas() : null);
}
示例9: componentHidden
import java.awt.event.ComponentEvent; //导入方法依赖的package包/类
public void componentHidden(ComponentEvent e) {
JToolBar jtb = (JToolBar) e.getComponent();
String ctx = (String) jtb.getClientProperty(KEY_CONTAINERCTX);
depopulateToolbar (ctx, jtb);
}
示例10: componentShown
import java.awt.event.ComponentEvent; //导入方法依赖的package包/类
public void componentShown(ComponentEvent e) {
JToolBar jtb = (JToolBar) e.getComponent();
String ctx = (String) jtb.getClientProperty(KEY_CONTAINERCTX);
populateToolbar (ctx, jtb);
getEngine().notifyToolbarShown(ctx, jtb);
}
示例11: componentHidden
import java.awt.event.ComponentEvent; //导入方法依赖的package包/类
public void componentHidden(ComponentEvent e) {
JMenu menu = (JMenu) e.getComponent();
String containerContext = getContainerContext(menu);
getEngine().notifyMenuHidden (containerContext, menu);
depopulateMenu (containerContext, menu);
}