this program in and off itself works. What I am looking to do Is replace the textfield in here with a .java file.import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; public class MyPanel extends JPanel { private JButton jcomp1; private JButton jcomp2; private JButton jcomp3; private JMenuBar jcomp4; private JTextField jcomp5; public MyPanel() { //construct preComponents JMenu fileMenu = new JMenu ("File"); JMenuItem printItem = new JMenuItem ("Print"); fileMenu.add (printItem); JMenuItem exitItem = new JMenuItem ("Exit"); fileMenu.add (exitItem); JMenu helpMenu = new JMenu ("Help"); JMenuItem contentsItem = new JMenuItem ("Contents"); helpMenu.add (contentsItem); JMenuItem aboutItem = new JMenuItem ("About"); helpMenu.add (aboutItem); //construct components jcomp1 = new JButton ("Button 1"); jcomp2 = new JButton ("Button 2"); jcomp3 = new JButton ("Button 3"); jcomp4 = new JMenuBar(); jcomp4.add (fileMenu); jcomp4.add (helpMenu); jcomp5 = new JTextField (5); //adjust size and set layout setPreferredSize (new Dimension (634, 563)); setLayout (null); //add components add (jcomp1); add (jcomp2); add (jcomp3); add (jcomp4); add (jcomp5); //set component bounds (only needed by Absolute Positioning) jcomp1.setBounds (205, 490, 100, 20); jcomp2.setBounds (310, 490, 100, 20); jcomp3.setBounds (245, 520, 140, 20); jcomp4.setBounds (0, 0, 200, 25); jcomp5.setBounds (30, 50, 590, 425); } public static void main (String[] args) { JFrame frame = new JFrame ("MyPanel"); frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); frame.getContentPane().add (new MyPanel()); frame.pack(); frame.setVisible (true); } }
You could say embedding a separate java file in this. the reason for this is because I do not contain the source code for it, but still have the .java file for it.