Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JToolBar on a JDesktop Pane  RSS feed

Suman Mummaneni
Ranch Hand
Posts: 97
Android Java Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I want to place a tool bar on a JDesktopPane i am using the following code to add the tool bar. There is no error during complile time but a run time error is created

public Main() {
super("The Open XP Editor");

int offset=50;
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
//Create a new desktop pane and place it on the frame below
desktop = new JDesktopPane();
createToolbar(); // careates the tool bar
desktop.add(jb); //add in the tool bar


I am getting the following exception while i am executing the program
xception in thread "main" java.lang.IllegalArgumentException: illegal component position
at java.awt.Container.addImpl(
at javax.swing.JLayeredPane.addImpl(
at java.awt.Container.add(
at mdiapps.Main.<init>(
at mdiapps.Main.create(
at mdiapps.Main.main(
Java Result: 1
BUILD SUCCESSFUL (total time: 2 seconds)
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!