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();
setBounds(offset,offset,screenSize.width-offset*2,screenSize.height-offset*2);
//Create a new desktop pane and place it on the frame below
desktop = new JDesktopPane();
createToolbar(); // careates the tool bar
createFrame();
setContentPane(desktop);
setJMenuBar(createMenuBar());
desktop.add(jb); //add in the tool bar
desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);

}

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(Container.java:1022)
at javax.swing.JLayeredPane.addImpl(JLayeredPane.java:204)
at java.awt.Container.add(Container.java:351)
at mdiapps.Main.<init>(Main.java:38)
at mdiapps.Main.create(Main.java:105)
at mdiapps.Main.main(Main.java:120)
Java Result: 1
BUILD SUCCESSFUL (total time: 2 seconds)
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!