title: Display class in content pane in java
body: <p>I have a general question about java. Because I want to create StronaGlowna.java (class) where I have place all buttons, check box and other GUI component which I want to display in main class. The first question is this right way, it's correct ? or maybe is better way to do this thing. My code look this:</p>
  
  <pre><code>import java.awt.CardLayout;
  import java.awt.Container;
  import java.awt.Dimension;
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  import java.awt.event.WindowAdapter;
  import java.awt.event.WindowEvent;
  import java.io.FileNotFoundException;
  import java.io.IOException;
  
  import javax.swing.JButton;
  import javax.swing.JFrame;
  import javax.swing.JMenu;
  import javax.swing.JMenuBar;
  import javax.swing.JMenuItem;
  import javax.swing.JPanel;
  
  public class Main extends JFrame {
  
      private static final long serialVersionUID = -4575271483481196192L;
  
      Container pane;
      CardLayout layout;
  
      public Main() throws FileNotFoundException, IOException {
  
          layout = new CardLayout();
          setLayout(layout);
  
          pane = this.getContentPane();
  
          /*Page: Strona główna */
          JPanel newPanel = new JPanel();
          pane.add("New", newPanel);      
          JButton przycisk = new JButton("Przycisk");
          newPanel.add(przycisk);
  
  ...
  </code></pre>
  
  <p>In "pane.add("New", newPanel);" I want to display elements from:</p>
  
  <pre><code>package aplikacja.glowna;
  
  import javax.swing.JButton;
  import javax.swing.JPanel;
  
  public class StronaGlowna {
  
      public void StronaGlownaDisplay() {
          JPanel newPanel = new JPanel();
          JButton przycisk2 = new JButton("Przycisk");
          newPanel.add(przycisk2);
      }
  
  }
  </code></pre>
  
  <p>Can I import/display all class StronaGlowna in main() something like a include in PHP ? What do You thing about my idea, it's correct or I'm wrong ? Thanks for help and discussion.</p>