本文整理了Java中javax.swing.JLabel.getParent()
方法的一些代码示例,展示了JLabel.getParent()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JLabel.getParent()
方法的具体详情如下:
包路径:javax.swing.JLabel
类名称:JLabel
方法名:getParent
暂无
代码示例来源:origin: chewiebug/GCViewer
public void removeEntry(String name) {
TwoLabelsContainer labelContainer = labelMap.get(name);
assert labelContainer != null : "labelContainer for '" + name + "' is null -> was it registered?";
assert labelContainer.nameLabel != null : "Name label for '" + name + "' is null.";
assert labelContainer.nameLabel.getParent() != null : "Parent for name label for '" + name + "' is null.";
labelContainer.nameLabel.getParent().remove(labelContainer.nameLabel);
assert labelContainer.valueLabel != null : "Value label for '" + name + "' is null.";
assert labelContainer.valueLabel.getParent() != null : "Parent for value label for '" + name + "' is null.";
labelContainer.valueLabel.getParent().remove(labelContainer.valueLabel);
}
代码示例来源:origin: stanfordnlp/CoreNLP
public void useProgressBar(boolean useProgressBar) {
if (useProgressBar) {//make sure we're in progress bar mode
if (progressBar == null) {
progressBar = new JProgressBar(JProgressBar.HORIZONTAL);
Container dad = foundStats.getParent();
useProgressBarHelper(dad, progressBar, foundStats);
}
} else {//make sure we're in found stats mode
if (progressBar != null) {
Container dad = progressBar.getParent();
useProgressBarHelper(dad, foundStats, progressBar);
progressBar = null;
}
}
}
代码示例来源:origin: stackoverflow.com
private int PanelContains(JPanel panel) {
JLabel Value;
for (Entry<Integer, JLabel> entry : Blackbox.entrySet()) {
Value = entry.getValue();
if (Value.getParent() == panel) {
return 1;
}
}
return 0;
}
代码示例来源:origin: stackoverflow.com
//label1 and label2 are JLabel's
//panel1 and panel2 are JPanel's
doActionsForLabel(label1);
doActionsForLabel(label2);
public void doActionsForLabel(JLabel label)
{
if (label.getParent() == panel1)
{
//do action #1
}
else if (label.getParent() == panel2)
{
//do action #2
}
}
代码示例来源:origin: stackoverflow.com
public void doActionsForLabel(JLabel label)
{
boolean flag = true;
Component parent = label;
while (flag)
{
parent = parent.getParent();
if ((parent != null) && (parent instanceof JPanel))
{
if (label.getParent() == panel1)
{
//do action #1
}
else if (label.getParent() == panel2)
{
//do action #2
}
}
else
{
flag = false;
}
}
}
代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-bu
public Container getParent()
{
if((delegate_==this)||(delegate_==null))
return super.getParent();
return delegate_.getParent();
}
代码示例来源:origin: lbalazscs/Pixelitor
public static void selectLayerIfIconClicked(MouseEvent e) {
// By adding a mouse listener to the JLabel, it loses the
// ability to automatically transmit the mouse events to its
// parent, and therefore the layer cannot be selected anymore
// by left-clicking on this label. This is the workaround.
JLabel source = (JLabel) e.getSource();
LayerButton layerButton = (LayerButton) source.getParent();
layerButton.setSelected(true);
}
代码示例来源:origin: baishui2004/common_gui_tools
public void mouseReleased(MouseEvent e) {
// 当前点击Label的父Panel
int closeIndex = tabbedPane.indexOfTabComponent(((JPanel) ((JLabel) e.getSource()).getParent()));
tabbedPane.remove(closeIndex);
// 移除插件在当前TabPanel的位置的记录
pluginsTabIndex.remove(tabPluginsId.get(closeIndex));
// 清空原TabPanel位置的插件记录,重新记录
tabPluginsId.clear();
// remove插件面板后调整索引位置
for (Integer i : pluginsTabIndex.keySet()) {
Integer index = pluginsTabIndex.get(i);
if (index > closeIndex) {
pluginsTabIndex.put(i, index - 1);
}
tabPluginsId.put(pluginsTabIndex.get(i), i);
}
}
代码示例来源:origin: igniterealtime/Spark
@Override
public void stateChanged(ChangeEvent e) {
_preview.setBackground(new Color(_sliderarray[0].getValue(), _sliderarray[1].getValue(), _sliderarray[2]
.getValue(), _sliderarray[3].getValue()));
_preview.setForeground(new Color(_sliderarray[0].getValue(), _sliderarray[1].getValue(), _sliderarray[2]
.getValue(), _sliderarray[3].getValue()));
_preview.invalidate();
_preview.repaint();
_preview.revalidate();
Container c = _preview.getParent();
if (c instanceof JPanel) {
c.repaint();
c.revalidate();
}
}
代码示例来源:origin: stackoverflow.com
System.out.println("label to inner: " + SwingUtilities.convertPoint(label, new Point(0, 0), inner));
System.out.println("label to outter: " + SwingUtilities.convertPoint(label, new Point(0, 0), outter));
System.out.println("label.parent to inner: " + SwingUtilities.convertPoint(label.getParent(), new Point(0, 0), inner));
System.out.println("label.parent to outter: " + SwingUtilities.convertPoint(label.getParent(), new Point(0, 0), outter));
System.out.println("label to frame: " + SwingUtilities.convertPoint(label, new Point(0, 0), frame));
System.out.println("label.getParent to frame: " + SwingUtilities.convertPoint(label.getParent(), new Point(0, 0), frame));
System.out.println("outter to label: " + SwingUtilities.convertPoint(outter, new Point(0, 0), label));
System.out.println("label to below: " + SwingUtilities.convertPoint(label, new Point(0, 0), below));
代码示例来源:origin: stackoverflow.com
public void mouseClicked(MouseEvent ae) {
JLabel src = (JLabel) ae.getSource();
src.setLocation(src.getLocation().x + delta_x, src.getLocation().y + delta_y);
src.getParent().repaint();
}
代码示例来源:origin: com.eas.platypus/platypus-js-forms
@ScriptFunction
@Override
public void setLeft(int aValue) {
if (super.getParent() != null && super.getParent().getLayout() instanceof MarginLayout) {
MarginLayout.ajustLeft(this, aValue);
}
super.setLocation(aValue, getTop());
}
代码示例来源:origin: com.eas.platypus/platypus-js-forms
@ScriptFunction
@Override
public void setTop(int aValue) {
if (super.getParent() != null && super.getParent().getLayout() instanceof MarginLayout) {
MarginLayout.ajustTop(this, aValue);
}
super.setLocation(getLeft(), aValue);
}
代码示例来源:origin: cytoscape.coreplugins/attribute-browser
private void wrapLabelText(final JLabel label, final String text) {
final FontMetrics fm = label.getFontMetrics(label.getFont());
final Container container = label.getParent();
final int containerWidth = container.getWidth();
final BreakIterator boundary = BreakIterator.getWordInstance();
boundary.setText(text);
final StringBuilder trial = new StringBuilder();
final StringBuilder real = new StringBuilder("<html>");
int start = boundary.first();
for (int end = boundary.next(); end != BreakIterator.DONE; start = end, end = boundary.next()) {
final String word = text.substring(start, end);
trial.append(word);
int trialWidth = SwingUtilities.computeStringWidth(fm, trial.toString());
if (trialWidth > containerWidth) {
trial.setLength(0);
trial.append(word);
real.append("<br>");
}
real.append(word);
}
real.append("</html>");
label.setText(real.toString());
}
}
代码示例来源:origin: edu.stanford.nlp/stanford-corenlp
public void useProgressBar(boolean useProgressBar) {
if (useProgressBar) {//make sure we're in progress bar mode
if (progressBar == null) {
progressBar = new JProgressBar(JProgressBar.HORIZONTAL);
Container dad = foundStats.getParent();
useProgressBarHelper(dad, progressBar, foundStats);
}
} else {//make sure we're in found stats mode
if (progressBar != null) {
Container dad = progressBar.getParent();
useProgressBarHelper(dad, foundStats, progressBar);
progressBar = null;
}
}
}
代码示例来源:origin: org.opencadc/cadc-download-manager
transLabel.getParent().remove(transLabel);
transLabel = null;
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-web-inspect
lookup.setView(pageModel.getCSSStylesView());
} else {
boolean noStylesLabelShown = noStylesLabel.getParent() != null;
boolean runFilePanelShown = runFilePanel.getParent() != null;
if ((lastRelatedFileObject == null) ? !noStylesLabelShown : !runFilePanelShown) {
内容来源于网络,如有侵权,请联系作者删除!