Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

y i cannot create a MDI???  RSS feed

 
Anthony Levis
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i want create a program that click a button and then show the internalframe at the main frame (JFrame) but i duno y my program cannot run it...

below the simple program that i create....
can any ppl tell me how to do it and y my program cannot run...

thank you!!!

=====================================================================

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.event.*;

public class a extends JFrame implements ActionListener{
JButton button_1;
JDesktopPane J;
private i I;

public a() {
JDesktopPane J= new JDesktopPane();
aLayout customLayout = new aLayout();

getContentPane().setFont(new Font("Helvetica", Font.PLAIN, 12));
getContentPane().setLayout(customLayout);

button_1 = new JButton("button_1");
getContentPane().add(button_1);
getContentPane().add(J, BorderLayout.CENTER);

addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});

button_1.addActionListener(this);
}

public void actionPerformed(ActionEvent ae){

J.add(new i());

}

public static void main(String args[]) {
a window = new a();
window.setTitle("a");
window.pack();
window.show();
}
}
 
sasi kala
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Levis,

For every internal frame programer has to set size and visibility.
and to display a button on desktop pane use
button.setBounds(x,y,width,heigth).

Modified code is given below.



Hope this helps you.

All The Best
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!