Results 1 to 2 of 2
  1. #1
    b2271916 is offline Member
    Join Date
    Jan 2013
    Rep Power

    Default New to Java and completely lost...

    I'm coming from C# and I am completely lost when it comes to Java... I currently have a Java Project with a JFrame (named frmMain) and a JInternalFrame (named frmPanel). I want to be able to add instances of frmPanel during runtime, but cannot figure out how to do it. Here is the code:
    Java Code:
    import java.awt.BorderLayout;
    import java.awt.EventQueue;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.border.EmptyBorder;
    import javax.swing.JDesktopPane;
    import java.awt.SystemColor;
    public class frmMain extends JFrame {
    	private JPanel contentPane;
    	 * Launch the application.
    	public static void main(String[] args) {
    		EventQueue.invokeLater(new Runnable() {
    			public void run() {
    				try {
    					frmMain frame = new frmMain();
    					[B]desktopPane.add(new frmPanel());[/B]
    				} catch (Exception e) {
    	 * Create the frame.
    	public frmMain() {
    		setBounds(100, 100, 796, 546);
    		contentPane = new JPanel();
    		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    		contentPane.setLayout(new BorderLayout(0, 0));
    		JDesktopPane desktopPane = new JDesktopPane();
    		contentPane.add(desktopPane, BorderLayout.CENTER);
    I get the error "desktopPane cannot be resolved".
    Also, how would I remove the title bar of a JInternalFrame?
    Last edited by b2271916; 02-18-2013 at 01:16 AM.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Blog Entries
    Rep Power

    Default Re: New to Java and completely lost...

    Your problem would be no different if you were coding this in C# since it has similar scoping rules as Java does. You declare your desktopPane inside of the frmMain constructor and so the variable is local to the constructor and only visible from within it.

Similar Threads

  1. For Loop Help! Completely Lost
    By whileloop in forum New To Java
    Replies: 8
    Last Post: 04-17-2012, 11:01 AM
  2. Replies: 2
    Last Post: 07-19-2011, 09:07 PM
  3. Calendars in Java are completely unintuitive.
    By caibbor in forum New To Java
    Replies: 2
    Last Post: 06-29-2011, 11:42 PM
  4. Is JAVA completely object-oriented???
    By venkateshk in forum New To Java
    Replies: 2
    Last Post: 11-17-2008, 09:17 AM
  5. Completely new to Java problem
    By Seamo14 in forum New To Java
    Replies: 4
    Last Post: 10-09-2008, 12:50 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts