0

I need to implement a JFrame of a class into another one when i click a button.

Here is my code :

public class Test6 extends JFrame implements Runnable {
 private static final String DB_PATH = "C:/testtest";
 private static GraphDatabaseService graphDb;
 Graph graph;
 Viewer viewer;
 View view;
 public JPanel contentPane1;

public void run() {
     Transaction tx = graphDb.beginTx();
    try
    {
        contentPane1 = new JPanel();
    contentPane1.setBackground(Color.DARK_GRAY);
    contentPane1.setBorder(new EmptyBorder(5, 5, 5, 5));
    contentPane1.setLayout(new BorderLayout(0, 0));
    setContentPane(contentPane1);
    JPanel panelSettings = new JPanel();
    panelSettings.setBorder(new EmptyBorder(0, 8, 0, 8));
    panelSettings.setBackground(SystemColor.activeCaption);
    panelSettings.setLayout(new BorderLayout(0, 0));
    contentPane1.add(panelSettings, BorderLayout.WEST);
    viewer.enableAutoLayout();
    view = viewer.addDefaultView(false);
    contentPane1.add(view);
    setSize(800, 600);
    setVisible(true);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 }

and the other class code is :

public class GraphTest2 extends JFrame implements ActionListener 
{
public GraphTest2()
{
    Init();

}

public void Init()
{

    contentPane = new JPanel();

    contentPane.setBackground(Color.DARK_GRAY);
    contentPane.setBorder(new EmptyBorder(0,0,0,0));
    contentPane.setLayout(new BorderLayout(8,0));
    setContentPane(contentPane);


    JPanel panelSettings = new JPanel();   
    panelSettings.setLayout(new GridLayout(20,1,0,0));

        panelSettings.add(b1);
        public void actionPerformed(ActionEvent e) {

          if(e.getSource()==b1){
        }

Iam trying to use internal Frame but i didn't know how to implement it in my code. Thank you for your time and help.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Anthony G. Helou
  • 103
  • 1
  • 1
  • 6
  • 1
    What do you mean by *"internal Frame"*. `JFrame` is not a `JInternalFrame` and `JInternalFrame` should be used with a `JDesktopPane`. Do you simply want to show the other frame? – MadProgrammer Mar 13 '13 at 22:44
  • 2
    See [The Use of Multiple JFrames, Good/Bad Practice?](http://stackoverflow.com/a/9554657/418556) – Andrew Thompson Mar 14 '13 at 00:57
  • It's unclear what "JFrame of a class into another one" means. You normally do not put JFrames within other JFrames. If a component will live "inside" a JFrame, consider a JPanel. If you need a new "window" consider the answers from Andrew's comment above. – SeKa Mar 14 '13 at 04:22

0 Answers0