本文整理匯總了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);
}