Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jul 31st, 2006, 2:04 PM   #1
golom
Newbie
 
Join Date: Jul 2006
Posts: 3
Rep Power: 0 golom is on a distinguished road
need help ergently for internalframes

I am a stdent and a assigment requires me to makea internalframe! I can not suss it out, could someone be kind enough to fill in what i need to make the internalframe appear from the liabry menuitem as i can not suss it out. Then I can use it as a rerence example! Your time would be greatfuly apreciated

Here is my main frame

java Syntax (Toggle Plain Text)
  1. package Default;
  2.  
  3. import java.awt.*;
  4. import java.awt.event.*;
  5. import javax.swing.*;
  6.  
  7. public class Frame1
  8. extends JFrame {
  9. JPanel contentPane;
  10. BorderLayout borderLayout1 = new BorderLayout();
  11. JMenuBar jMenuBar1 = new JMenuBar();
  12. JMenu jMenuFile = new JMenu();
  13. JMenuItem jMenuFileExit = new JMenuItem();
  14. JPanel Base = new JPanel();
  15. JPanel jPanel1 = new JPanel();
  16. JScrollPane jScrollPane1 = new JScrollPane();
  17. JEditorPane jEditorPane1 = new JEditorPane();
  18. JLabel Comands = new JLabel();
  19. JMenuItem NProject = new JMenuItem();
  20. JMenuItem Save = new JMenuItem();
  21. JMenuItem SaveAs = new JMenuItem();
  22. JMenuItem Libaray = new JMenuItem();
  23. JMenu jMenu1 = new JMenu();
  24. JMenuItem Comp = new JMenuItem();
  25. JMenuItem Debug = new JMenuItem();
  26. JMenu jMenu2 = new JMenu();
  27. JMenuItem HO = new JMenuItem();
  28. public Frame1() {
  29. try {
  30. setDefaultCloseOperation(EXIT_ON_CLOSE);
  31. jbInit();
  32. } catch (Exception exception) {
  33. exception.printStackTrace();
  34. }
  35. }
  36.  
  37. /**
  38. * Component initialization.
  39. *
  40. * @throws java.lang.Exception
  41. */
  42. private void jbInit() throws Exception {
  43. contentPane = (JPanel) getContentPane();
  44. contentPane.setLayout(borderLayout1);
  45. setSize(new Dimension(553, 470));
  46. setTitle("Horthorn");
  47. jMenuFile.setText("File");
  48. jMenuFileExit.setText("Exit");
  49. jMenuFileExit.addActionListener(new Frame1_jMenuFileExit_ActionAdapter(this));
  50. Base.setBorder(BorderFactory.createRaisedBevelBord er());
  51. Base.setLayout(null);
  52. jPanel1.setBorder(BorderFactory.createLoweredBevel Border());
  53. jPanel1.setBounds(new Rectangle(13, 15, 520, 160));
  54. jScrollPane1.setBounds(new Rectangle(12, 198, 521, 245));
  55. Comands.setBackground(Color.orange);
  56. Comands.setText("Comand box");
  57. Comands.setBounds(new Rectangle(14, 178, 72, 15));
  58. NProject.setText("New project");
  59. Save.setText("Save Project");
  60. SaveAs.setText("Save As");
  61. Libaray.setText("Liabrary");
  62. jMenu1.setText("Test");
  63. Comp.setText("Comp");
  64. Debug.setText("Debug");
  65. jMenu2.setText("Help");
  66. HO.setText("Help Online");
  67. jMenuBar1.add(jMenuFile);
  68. jMenuBar1.add(jMenu1);
  69. jMenuBar1.add(jMenu2);
  70. jMenuFile.add(jMenuFileExit);
  71. jMenuFile.add(NProject);
  72. jMenuFile.add(Save);
  73. jMenuFile.add(SaveAs);
  74. jMenuFile.add(Libaray);
  75. contentPane.add(Base, java.awt.BorderLayout.CENTER);
  76. Base.add(jPanel1);
  77. Base.add(jScrollPane1);
  78. Base.add(Comands);
  79. jScrollPane1.getViewport().add(jEditorPane1);
  80. jMenu1.add(Comp);
  81. jMenu1.add(Debug);
  82. jMenu2.add(HO);
  83. setJMenuBar(jMenuBar1);
  84. }
  85.  
  86. /**
  87. * File | Exit action performed.
  88. *
  89. * @param actionEvent ActionEvent
  90. */
  91. void jMenuFileExit_actionPerformed(ActionEvent actionEvent) {
  92. System.exit(0);
  93. }
  94. }
  95.  
  96. class Frame1_jMenuFileExit_ActionAdapter
  97. implements ActionListener {
  98. Frame1 adaptee;
  99.  
  100. Frame1_jMenuFileExit_ActionAdapter(Frame1 adaptee) {
  101. this.adaptee = adaptee;
  102. }
  103.  
  104. public void actionPerformed(ActionEvent actionEvent) {
  105. adaptee.jMenuFileExit_actionPerformed(actionEvent) ;
  106. }
  107. }
  108.  
  109.  
  110. // here is the cnstruction for may internal frame but i can not work out where im saposed to put the listner as in the example they have put it in the internalframe itself, this does not make sense to me! please add the complete code that i need to make the menu display and i will go through it and work out what is happening
  111.  
  112. //internal frame construction
  113. public class InternalFrameDemo extends JFrame
  114. {
  115. public InternalFrameDemo()
  116. {
  117. final JDesktopPane dPane=new JDesktopPane();
  118. setContentPane(dPane);
  119. //make panel for buttons setLayout Gridlayout
  120. JPanel basebutton = new JPanel();
  121. GridLayout GridBut = new GridLayout(2,0,10,10);
  122. //make scrollpane for images
  123. JScrollpane imscroll = new JScrollPane();
  124. JPanel im = new JPanel();
  125.  
  126. //Buttons for BaseBottom
  127. JButton Hum = new JButton(Human);
  128. JButton Non = new JButton(Monsters);
  129. JButton Bugs = new JButton(Bugs);
  130. JButton Animals = new JButton(Animals);
  131.  
  132. //right side
  133. jButton Vechils = new JButton(Vechles);
  134. JButton Buildings = new JButton(Buildings);
  135. JButton Textures = new JButton(Weapons);
  136. JButton Weapons = new JButton(Weapons);
  137.  
  138. //create cancel anf exept buttons
  139. JButton Accept = new JButton(Accept);
  140. JButton Cancel = new JButton(Cancel);
  141.  
  142.  
  143.  
  144. JMenuItem libarary = new JMenuItem(new AbstractAction ("libarary") { //should this not be in the main frame
  145.  
  146. public void actionPerformed(ActionEvent e)
  147. {
  148. JInternalFrame frame = new JInternalFrame("Libary",true,true);
  149. frame.setVisible(true);
  150. frame.setSize(400,400);
  151. dPane.add(frame);
  152. }
  153.  
  154. });
  155.  
  156. //add components here
  157. BaseButton.setBounds(180, 170, 180, 170);
  158. BaseButton.add(Hum);
  159. BaseButton.add(Non);
  160. BaseButton.add(Bugs);
  161. BaseButton.add(Animals);
  162.  
  163. BaseButton.add(Vechils);
  164. BaseButton.add(Buildings);
  165. BaseButton.add(Textures);
  166. BaseButton.add(Weapons);
  167. contentpane.add(BaseButton,BorderLayout.North); // last of buttons to add
  168.  
  169.  
  170. //siz scrollpane and add to main and add im
  171. imscroll.setBounds(180, 170, 180, 170);
  172. contentpane.add(imscroll,BorderLayout.SOUTH);
  173. im.add(imscroll);
  174. }
  175.  
  176. public static void main(String[] args)
  177. {
  178. InternalFrameDemo d = new InternalFrameDemo();
  179. d.setSize(500,500);
  180. d.setVisible(true);
  181. d.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  182. }
  183. }

Last edited by big_k105; Jul 31st, 2006 at 4:22 PM. Reason: added highlight tag
golom is offline   Reply With Quote
Old Jul 31st, 2006, 2:15 PM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Have you by any chance read the formum's FAQ/Rules? Most people looking to a community for help would at least scope it out and try to form some opinion as to its cultural focii. Somewhat like not walking into a strange church and farting loudly, until one discovers it's quite the thing to do.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Jul 31st, 2006, 2:27 PM   #3
peace_of_mind
Professional Programmer
 
peace_of_mind's Avatar
 
Join Date: Sep 2004
Location: Hell if I know most of the time
Posts: 439
Rep Power: 5 peace_of_mind is on a distinguished road
Send a message via MSN to peace_of_mind Send a message via Yahoo to peace_of_mind
1. Spell check is your friend. My skin will not stop crawling.
2. Use code tags to make things easier to read.
3. See Principal DaWei's post
4. Welcome to the forums.
__________________
Amateurs built the ark
Professionals built the Titanic

peace_of_mind is offline   Reply With Quote
Old Jul 31st, 2006, 4:28 PM   #4
Booooze
Expert Programmer
 
Booooze's Avatar
 
Join Date: Mar 2006
Location: Igloo
Posts: 710
Rep Power: 3 Booooze is on a distinguished road
Send a message via MSN to Booooze
People are stupid.
Booooze is offline   Reply With Quote
Old Jul 31st, 2006, 5:45 PM   #5
stevengs
Professional Programmer
 
stevengs's Avatar
 
Join Date: May 2005
Location: Bad Nauheim, Germany
Posts: 436
Rep Power: 4 stevengs is on a distinguished road
make it quick, make it ergent, ergent... umergency.. so eeeergeeeent.. uumeeeeeergency ..woohooo
__________________
-Steven
"Is this a piece of your brain?" - Basil Fawlty
stevengs is offline   Reply With Quote
Old Jul 31st, 2006, 5:52 PM   #6
big_k105
PFO Founder

 
big_k105's Avatar
 
Join Date: Mar 2004
Location: Fargo, ND
Posts: 1,667
Rep Power: 10 big_k105 is on a distinguished road
Send a message via AIM to big_k105 Send a message via MSN to big_k105 Send a message via Yahoo to big_k105
Come on people. I know the title is bad and so is his spelling but I have put his code in highlight tags. I think someone should still be able to help. Maybe the Original Poster can repost the question with better spelling, if people are having that much trouble. I personally can't help as I don't know much about what you are asking, hopefully someone can give you a straight forward answer. It would probably also help if you told us what you exactly need help with. Like what part of that code are you having problems with? Thanks
__________________
BIG K aka Kyle
Programming Forums
Kyle K Online

Please do not PM or email me programming questions. Post them in the forums instead.
big_k105 is online now   Reply With Quote
Old Jul 31st, 2006, 8:08 PM   #7
azurik
Newbie
 
Join Date: May 2006
Posts: 6
Rep Power: 0 azurik is on a distinguished road
When in doubt, google it.

http://java.sun.com/docs/books/tutor...rnalframe.html

I've heard of JInternalFrame class before, though I've never personally used it. Good luck. I couldn't understand what exactly you were wanting to do with the JInternalFrame, so there's no way I could help.
azurik is offline   Reply With Quote
Old Jul 31st, 2006, 10:55 PM   #8
ReggaetonKing
Sexy Programmer
 
ReggaetonKing's Avatar
 
Join Date: Nov 2005
Location: New Jersey
Posts: 891
Rep Power: 4 ReggaetonKing is on a distinguished road
Send a message via AIM to ReggaetonKing
You must put a JInternalFrame within a JDesktopPane, the JDesktopPane acts as a container for the JInternalFrames.

[PHP]
import java.awt.*;
import javax.swing.*;

public class Desktop
{
public static void main(String args[])
{
JFrame frame = new JFrame("Desktop Test");
JDesktopPane desktop = new JDesktopPane();
for(int x = 0; x <= 5; x++)
{
JInternalFrame intFrame = new JInternalFrame
("Frame " + x, true, true, true, true);
intFrame.setSize(100,100);
intFrame.setLocation(x*2, x*2);
intFrame.setVisible(true);
desktop.add(intFrame);
}
frame.setSize(600,600);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setContentPane(desktop);
frame.setVisible(true);
}
}
[/PHP]
That is an example how to use JInternalFrames and JDesktopPanes. Although your explaination wasn't really clear on what you needed help with. I hope this could lean you in the right direction.
__________________
I would love to change the world, but they won't give me the source code!
ReggaetonKing is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 7:24 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC