Check if JButtons are within a particular JPanel
<p>I am creating a GUI application using Java. There are different sections in the main frame, each having a particular functionality. The header panel contains the buttons Submit, Undo, Shuffle, Help and Quit. Here is the sample code:  </p>

<pre><code>JPanel header = new JPanel();  

JButton submit = new JButton("Submit");  
header.add(submit);  

JButton undo= new JButton("Undo");  
header.add(undo); 

JButton shuffle= new JButton("Shuffle");  
header.add(shuffle);

JButton help= new JButton("Help");  
header.add(help); 

JButton quit = new JButton("Quit");  
header.add(quit); 
</code></pre>

<p>Further down my code, I need to check that the button clicked is not in the header panel (there are buttons in other panels too).  </p>

<pre><code>public void actionPerformed(ActionEvent e)
   {
      String clicked = e.getActionCommand();

      if(!clicked.equals("Submit") &amp;&amp; !clicked.equals("Undo") &amp;&amp; !clicked.equals("Help")&amp;&amp; !clicked.equals("Quit") &amp;&amp; !clicked.equals("Shuffle")){  


      //some code here
</code></pre>

<p>Is there any alternate neater way to check that the button clicked is not in the header panel? I will need to do something similar in another panel which contains more buttons. Using IF statements to check for each button is inefficient and untidy, I believe.</p>