Results 1 to 2 of 2
- 02-18-2013, 01:11 AM #1
Member
- Join Date
- Jan 2013
- Posts
- 4
- Rep Power
- 0
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:
I get the error "desktopPane cannot be resolved".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(); frame.setVisible(true); [B]desktopPane.add(new frmPanel());[/B] } catch (Exception e) { e.printStackTrace(); } } }); } /** * Create the frame. */ public frmMain() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 796, 546); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); contentPane.setLayout(new BorderLayout(0, 0)); setContentPane(contentPane); JDesktopPane desktopPane = new JDesktopPane(); desktopPane.setBackground(SystemColor.menu); contentPane.add(desktopPane, BorderLayout.CENTER); desktopPane.setLayout(null); } }
Also, how would I remove the title bar of a JInternalFrame?Last edited by b2271916; 02-18-2013 at 01:16 AM.
-
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
-
For Loop Help! Completely Lost
By whileloop in forum New To JavaReplies: 8Last Post: 04-17-2012, 11:01 AM -
Completely Uninstall Java from my Computer - Then Reinstall
By Javabeans in forum New To JavaReplies: 2Last Post: 07-19-2011, 09:07 PM -
Calendars in Java are completely unintuitive.
By caibbor in forum New To JavaReplies: 2Last Post: 06-29-2011, 11:42 PM -
Is JAVA completely object-oriented???
By venkateshk in forum New To JavaReplies: 2Last Post: 11-17-2008, 09:17 AM -
Completely new to Java problem
By Seamo14 in forum New To JavaReplies: 4Last Post: 10-09-2008, 12:50 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks