javax.swing.JButton.getParent()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(5.6k)|赞(0)|评价(0)|浏览(154)

本文整理了Java中javax.swing.JButton.getParent()方法的一些代码示例,展示了JButton.getParent()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JButton.getParent()方法的具体详情如下:
包路径:javax.swing.JButton
类名称:JButton
方法名:getParent

JButton.getParent介绍

暂无

代码示例

代码示例来源: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: magefree/mage

public void actionPerformed(java.awt.event.ActionEvent evt) {
    // search combo box near button (must be only one combo in panel)
    JButton button = (JButton) evt.getSource();
    JComboBox combo = findComboInComponent(button.getParent());
    if (combo != null) {
      FastSearchUtil.showFastSearchForStringComboBox(combo, "Select value");
    }
  }
});

代码示例来源:origin: Nilhcem/FakeSMTP

/**
 * Displays a message dialog displaying the error specified in parameter.
 *
 * @param error a string representing the error which will be displayed in a message dialog.
 */
private void displayError(String error) {
  JOptionPane.showMessageDialog(button.getParent(), error,
    String.format(i18n.get("startsrv.err.title"), Configuration.INSTANCE.get("application.name")),
    JOptionPane.ERROR_MESSAGE);
}

代码示例来源:origin: Nilhcem/FakeSMTP

@Override
  public void actionPerformed(ActionEvent e) {
    int answer = JOptionPane.showConfirmDialog(button.getParent(), i18n.get("clearall.delete.email"),
      String.format(i18n.get("clearall.title"), Configuration.INSTANCE.get("application.name")),
        JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
    if (answer == JOptionPane.CLOSED_OPTION) {
      return;
    }
    synchronized (SMTPServerHandler.INSTANCE.getMailSaver().getLock()) {
      // Note: Should delete emails before calling observers, since observers will clean the model.
      if (answer == JOptionPane.YES_OPTION) {
        SMTPServerHandler.INSTANCE.getMailSaver().deleteEmails();
      }
      setChanged();
      notifyObservers();
      button.setEnabled(false);
    }
  }
});

代码示例来源:origin: magefree/mage

break;
default:
  btnPreviousConfiguration2.getParent().requestFocus();
  break;

代码示例来源:origin: magefree/mage

btnSavedConfiguration2.requestFocus();
} else {
  btnSavedConfiguration2.getParent().requestFocus();

代码示例来源:origin: stackoverflow.com

public void actionPerformed(ActionEvent evt)
{
  JButton button = (JButton)evt.getSource();
  Component parent = button.getParent();

  if (button == redBtn)
    parent.setBackground( Color.RED );
  else if (...)
}

代码示例来源:origin: aerospike/aerospike-client-java

@Override
  public void mouseClicked(MouseEvent arg0) {
    Container Frame = exitButton.getParent();
    do {
      Frame = Frame.getParent();
    } while (!(Frame instanceof JFrame));
    ((JFrame) Frame).dispose();
  }
});

代码示例来源:origin: stackoverflow.com

JButton button = (JButtton)event.getSource();
JPanel grandparent = button.getParent().getParent();
grandparent.removeAll();
grandparent.revalidate();
grandparent.repaint();

代码示例来源:origin: stackoverflow.com

JButton button = (JButton)e.getSource();
JPanel parent = (JPanel)button.getParent();
parent.remove(button);
parent.revalidate();
parent.repaint();

代码示例来源:origin: CallForSanity/Gaalop

public void actionPerformed(java.awt.event.ActionEvent e) {
  int status = chooser.showOpenDialog(selectJava.getParent());
  if (status == JFileChooser.APPROVE_OPTION) {
    changed = true;
    tfJava.setText(chooser.getSelectedFile().getAbsolutePath());
  }
}

代码示例来源:origin: biojava/biojava

@Override
 public void actionPerformed(ActionEvent event) {
   Object source = event.getSource();
   JButton but = (JButton)source;
   Container parent = but.getParent().getParent().getParent().getParent().getParent().getParent() ;
   JDialog dia = (JDialog) parent;
   dia.dispose();
  }
});

代码示例来源:origin: biojava/biojava

@Override
  public void actionPerformed(ActionEvent event) {
    Object source = event.getSource();
    JButton but = (JButton)source;
    Container parent = but.getParent().getParent().getParent().getParent().getParent().getParent() ;
    JDialog dia = (JDialog) parent;
    dia.dispose();
  }
});

代码示例来源:origin: biojava/biojava

@Override
  public void actionPerformed(ActionEvent event) {
    Object source = event.getSource();
    JButton but = (JButton)source;
    Container parent = but.getParent().getParent().getParent().getParent().getParent().getParent() ;
    JDialog dia = (JDialog) parent;
    dia.dispose();
  }
});

代码示例来源:origin: biojava/biojava

@Override
public void actionPerformed(ActionEvent event) {
    Object source = event.getSource();
    JButton but = (JButton)source;
    Container parent = but.getParent().getParent().getParent().getParent().getParent().getParent() ;
    JDialog dia = (JDialog) parent;
    dia.dispose();
  }
});

代码示例来源:origin: net.sf.taverna.t2.ui-components/results-view

public void actionPerformed(ActionEvent e) {
    saveButton.getParent().requestFocusInWindow();// so that the button does not stay focused after it is clicked on and did its action
  }
});

代码示例来源:origin: net.sf.taverna.t2.ui-components/results-view

public void actionPerformed(ActionEvent e) {
    renderResult();
    refreshButton.getParent().requestFocusInWindow();// so that the button does not stay focused after it is clicked on and did its action
  }
});

代码示例来源: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: stackoverflow.com

JButton button = (JButton)e.getSource();
JPanel someCustomPanel = (JPanel)button.getParent();
JPanel cardLayoutPanel = (JPanel)someCustomPanel.getParent();
CardLayout layout = (CardLayout)cardLayoutPanel.getLayout();
layout.show(cardLayoutPanel, "...");

相关文章

JButton类方法