本文整理了Java中java.awt.Container.getParent()
方法的一些代码示例,展示了Container.getParent()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Container.getParent()
方法的具体详情如下:
包路径:java.awt.Container
类名称:Container
方法名:getParent
暂无
代码示例来源:origin: libgdx/libgdx
protected static JFrame findJFrame (Component component) {
Container parent = component.getParent();
while (parent != null) {
if (parent instanceof JFrame) {
return (JFrame)parent;
}
parent = parent.getParent();
}
return null;
}
代码示例来源:origin: libgdx/libgdx
protected static JFrame findJFrame (Component component) {
Container parent = component.getParent();
while (parent != null) {
if (parent instanceof JFrame) {
return (JFrame)parent;
}
parent = parent.getParent();
}
return null;
}
代码示例来源:origin: cmusphinx/sphinx4
/** Finds the JViewport enclosing this component. */
private JViewport getViewport() {
Container p = getParent();
if (p instanceof JViewport) {
Container gp = p.getParent();
if (gp instanceof JScrollPane) {
JScrollPane scroller = (JScrollPane) gp;
JViewport viewport = scroller.getViewport();
if (viewport == null || viewport.getView() != this) {
return null;
} else {
return viewport;
}
}
}
return null;
}
代码示例来源:origin: JetBrains/ideavim
private void positionPanel() {
if (parent == null) return;
Container scroll = SwingUtilities.getAncestorOfClass(JScrollPane.class, parent);
int height = (int)getPreferredSize().getHeight();
if (scroll != null) {
Rectangle bounds = scroll.getBounds();
bounds.translate(0, scroll.getHeight() - height);
bounds.height = height;
Point pos = SwingUtilities.convertPoint(scroll.getParent(), bounds.getLocation(), oldGlass);
bounds.setLocation(pos);
setBounds(bounds);
repaint();
}
}
代码示例来源:origin: JetBrains/ideavim
bounds.height = height;
final JRootPane rootPane = SwingUtilities.getRootPane(myParent);
final Point pos = SwingUtilities.convertPoint(scroll.getParent(), bounds.getLocation(), rootPane);
final Window window = SwingUtilities.getWindowAncestor(myParent);
final Point windowPos = window.getLocation();
代码示例来源:origin: JetBrains/ideavim
private void positionPanel() {
final JComponent contentComponent = myEditor.getContentComponent();
Container scroll = SwingUtilities.getAncestorOfClass(JScrollPane.class, contentComponent);
setSize(scroll.getSize());
myLineHeight = myText.getFontMetrics(myText.getFont()).getHeight();
int count = countLines(myText.getText());
int visLines = getSize().height / myLineHeight - 1;
int lines = Math.min(count, visLines);
setSize(getSize().width, lines * myLineHeight + myLabel.getPreferredSize().height +
getBorder().getBorderInsets(this).top * 2);
int height = getSize().height;
Rectangle bounds = scroll.getBounds();
bounds.translate(0, scroll.getHeight() - height);
bounds.height = height;
Point pos = SwingUtilities.convertPoint(scroll.getParent(), bounds.getLocation(),
SwingUtilities.getRootPane(contentComponent).getGlassPane());
bounds.setLocation(pos);
setBounds(bounds);
myScrollPane.getVerticalScrollBar().setValue(0);
if (!Options.getInstance().isSet("more")) {
// FIX
scrollOffset(100000);
}
else {
scrollOffset(0);
}
}
代码示例来源:origin: stackoverflow.com
private JButton btnExit;
...
btnExit = new JButton("Quit");
btnExit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e){
Container frame = btnExit.getParent();
do
frame = frame.getParent();
while (!(frame instanceof JFrame));
((JFrame) frame).dispose();
}
});
代码示例来源:origin: jshiell/checkstyle-idea
private Window parentWindow(final Container window) {
if (window instanceof Window) {
return (Window) window;
}
return parentWindow(window.getParent());
}
}
代码示例来源:origin: ron190/jsql-injection
for (Container p = parent; p != null; p = p.getParent()) {
if (p instanceof JRootPane) {
if (p.getParent() instanceof JInternalFrame) {
continue;
代码示例来源:origin: stackoverflow.com
class SomeSpecialComponent extends JComponent implements HierarchyListener {
private boolean amIVisible() {
Container c = getParent();
while (c != null)
if (!c.isVisible())
return false;
else
c = c.getParent();
return true;
}
public void addNotify() {
super.addNotify();
addHierarchyListener(this);
}
public void removeNotify() {
removeHierarchyListener(this);
super.removeNotify();
}
public void hierarchyChanged(HierarchyEvent e) {
System.out.println("Am I visible? " + amIVisible());
}
}
代码示例来源:origin: bobbylight/RSyntaxTextArea
/**
* Returns the gutter component of the scroll pane containing a text
* area, if any.
*
* @param textArea The text area.
* @return The gutter, or <code>null</code> if the text area is not in
* an {@link RTextScrollPane}.
* @see RTextScrollPane#getGutter()
*/
public static Gutter getGutter(RTextArea textArea) {
Gutter gutter = null;
Container parent = textArea.getParent();
if (parent instanceof JViewport) {
parent = parent.getParent();
if (parent instanceof RTextScrollPane) {
RTextScrollPane sp = (RTextScrollPane)parent;
gutter = sp.getGutter(); // Should always be non-null
}
}
return gutter;
}
代码示例来源:origin: nodebox/nodebox
private void breakFocusCycle() {
Container o = getParent();
while (o != null) {
if (o != null && o.isFocusable())
break;
o = o.getParent();
}
if (o != null)
o.requestFocus();
}
代码示例来源:origin: RaiMan/SikuliX2
@Override
public void actionPerformed(ActionEvent e){
if ( count <= repeatCount){
int x = (int) tfuncx.getValue(count);
int y = (int) tfuncy.getValue(count);
count++;
Rectangle r1 = comp.getBounds();
comp.setActualLocation(x,y);
Rectangle r2 = comp.getBounds();
r1.add(r2);
Container c = comp.getParent();
if (c != null){
c.getParent().getParent().repaint(r1.x,r1.y,r1.width,r1.height);
}
}else{
timer.stop();
}
}
代码示例来源:origin: RaiMan/SikuliX2
@Override
public void actionPerformed(ActionEvent e) {
float r = funcr.getValue(count);
int x = (int) (origin.x + (int) radius * Math.sin(r));
int y= (int) (origin.y + (int) radius * Math.cos(r));
Point p = new Point(x,y);
Rectangle r1 = comp.getBounds();
comp.setLocation(p);
// r1 stores the union of the bounds before/after the animated step
Rectangle r2 = comp.getBounds();
r1.add(r2);
comp.getParent().getParent().repaint(r1.x,r1.y,r1.width,r1.height);
//repaint(r1);
// comp.getParent().invalidate();
// comp.repaint();
if (count == repeatCount)
count = 0;
else
count++;
}
}
代码示例来源:origin: ron190/jsql-injection
for (Container p = contents.getParent() ; p != null ; p = p.getParent()) {
if (p instanceof JWindow || p instanceof Panel) {
代码示例来源:origin: nodebox/nodebox
public void close() {
Container parent = getParent();
if (!(parent instanceof JSplitPane)) return;
JSplitPane split = (JSplitPane) parent;
Component firstComponent = split.getTopComponent();
Component secondComponent = split.getBottomComponent();
Component remainingComponent = firstComponent == this ? secondComponent : firstComponent;
split.setTopComponent(null);
split.setBottomComponent(null);
Container grandParent = parent.getParent();
if (grandParent instanceof JSplitPane) {
JSplitPane grandSplit = (JSplitPane) grandParent;
// Remove the split pane.
if (split == grandSplit.getTopComponent()) {
grandSplit.setTopComponent(remainingComponent);
} else {
grandSplit.setBottomComponent(remainingComponent);
}
} else {
grandParent.remove(parent);
grandParent.add(remainingComponent);
}
grandParent.validate();
}
代码示例来源:origin: ron190/jsql-injection
boolean isCaretAtEnd = this.getProxy().getCaretPosition() == this.getProxy().getDocument().getLength();
JScrollPane v = (JScrollPane) this.getProxy().getParent().getParent();
JScrollBar vertical = v.getVerticalScrollBar();
int extent = vertical.getModel().getExtent();
代码示例来源:origin: vsch/flexmark-java
public static void setRegExError(String error, JTextPane jTextPane, final Font textFont, final BackgroundColor validTextFieldBackground, final BackgroundColor warningTextFieldBackground) {
HtmlBuilder html = new HtmlBuilder();
html.tag("html").style("margin:2px;vertical-align:middle;").attr(validTextFieldBackground, textFont).tag("body");
html.attr(warningTextFieldBackground).tag("div");
html.append(toHtmlError(error, true));
html.closeTag("div");
html.closeTag("body");
html.closeTag("html");
jTextPane.setVisible(true);
jTextPane.setText(html.toFinalizedString());
jTextPane.revalidate();
jTextPane.getParent().revalidate();
jTextPane.getParent().getParent().revalidate();
}
代码示例来源:origin: kaikramer/keystore-explorer
private static JDialog findContainingDialog(JComponent component) {
Container container = component.getParent();
while (container != null) {
if (container instanceof JDialog) {
return (JDialog) container;
}
container = container.getParent();
}
return null;
}
代码示例来源:origin: kaikramer/keystore-explorer
private static JFrame findContainingFrame(JComponent component) {
Container container = component.getParent();
while (container != null) {
if (container instanceof JFrame) {
return (JFrame) container;
}
container = container.getParent();
}
return null;
}
内容来源于网络,如有侵权,请联系作者删除!