Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: Noob Programmer Needs some help.

  1. #1
    Junior Member
    Join Date
    Oct 2012
    Posts
    9
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Noob Programmer Needs some help.

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
     
    public class MyPanel extends JPanel {
        private JButton jcomp1;
        private JButton jcomp2;
        private JButton jcomp3;
        private JMenuBar jcomp4;
        private JTextField jcomp5;
     
        public MyPanel() {
            //construct preComponents
            JMenu fileMenu = new JMenu ("File");
            JMenuItem printItem = new JMenuItem ("Print");
            fileMenu.add (printItem);
            JMenuItem exitItem = new JMenuItem ("Exit");
            fileMenu.add (exitItem);
            JMenu helpMenu = new JMenu ("Help");
            JMenuItem contentsItem = new JMenuItem ("Contents");
            helpMenu.add (contentsItem);
            JMenuItem aboutItem = new JMenuItem ("About");
            helpMenu.add (aboutItem);
     
            //construct components
            jcomp1 = new JButton ("Button 1");
            jcomp2 = new JButton ("Button 2");
            jcomp3 = new JButton ("Button 3");
            jcomp4 = new JMenuBar();
            jcomp4.add (fileMenu);
            jcomp4.add (helpMenu);
            jcomp5 = new JTextField (5);
     
            //adjust size and set layout
            setPreferredSize (new Dimension (634, 563));
            setLayout (null);
     
            //add components
            add (jcomp1);
            add (jcomp2);
            add (jcomp3);
            add (jcomp4);
            add (jcomp5);
     
            //set component bounds (only needed by Absolute Positioning)
            jcomp1.setBounds (205, 490, 100, 20);
            jcomp2.setBounds (310, 490, 100, 20);
            jcomp3.setBounds (245, 520, 140, 20);
            jcomp4.setBounds (0, 0, 200, 25);
            jcomp5.setBounds (30, 50, 590, 425);
        }
     
     
        public static void main (String[] args) {
            JFrame frame = new JFrame ("MyPanel");
            frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
            frame.getContentPane().add (new MyPanel());
            frame.pack();
            frame.setVisible (true);
        }
    }
    this program in and off itself works. What I am looking to do Is replace the textfield in here with a .java file.
    You could say embedding a separate java file in this. the reason for this is because I do not contain the source code for it, but still have the .java file for it.


  2. #2
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 139 Times in 134 Posts

    Default Re: Noob Programmer Needs some help.

    Quote Originally Posted by centralnathan View Post
    .... What I am looking to do Is replace the textfield in here with a .java file.
    Please explain because this statement doesn't make sense.

    You could say embedding a separate java file in this. the reason for this is because I do not contain the source code for it, but still have the .java file for it.
    Nor does this. Please tell the details, enough to help make it easier to answer your question.

  3. #3
    Junior Member
    Join Date
    Oct 2012
    Posts
    9
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Noob Programmer Needs some help.

    Quote Originally Posted by curmudgeon View Post
    Please explain because this statement doesn't make sense.



    Nor does this. Please tell the details, enough to help make it easier to answer your question.
    I have a program, it makes a giant text box in the middle (and a couple of buttons in a jpanel).
    Where this text box is I want it replaced with say a game or something
    Bowman 2 - Free Online Shooting Games from AddictingGames
    So instead of a text box I want the game on this page there.
    Now I have no Idea how to do this, Im assuming I could just make it open the page, but I only want the game part(so there is no needless scrolling to fit the game in just right)

    Better or no?
    I can photo shop a pic of what I saying

  4. #4
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 139 Times in 134 Posts

    Default Re: Noob Programmer Needs some help.

    If you have the source code for the game, or a Jar file and a very good understanding of the Jar, plus knowledge that it was written with well-behaved Swing code with methods that allow you to do this, then perhaps, but otherwise, you may be asking a bit too much.

    Incidentally, you're throwing around terms such as textfield and text box that make no sense in Java Swing terms. Please be as precise as possible here so our answers can be as well.

  5. #5
    Junior Member
    Join Date
    Oct 2012
    Posts
    9
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Noob Programmer Needs some help.

    Quote Originally Posted by curmudgeon View Post
    If you have the source code for the game, or a Jar file and a very good understanding of the Jar, plus knowledge that it was written with well-behaved Swing code with methods that allow you to do this, then perhaps, but otherwise, you may be asking a bit too much.

    Incidentally, you're throwing around terms such as textfield and text box that make no sense in Java Swing terms. Please be as precise as possible here so our answers can be as well.
    ok did you under stand my example though?, if say starting small I just want to make a java applet that opens up that website in a jpanel with it included inside of it.
    Bowman 2 - Free Online Shooting Games from AddictingGames
    .
    also please note I am very new to this, so I do not know the word Swing in my java vocab
    the textfield is this private JTextField jcomp5;
    and its a user input (but thats where I want the game the "textfield" is just a place holder

  6. #6
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 139 Times in 134 Posts

    Default Re: Noob Programmer Needs some help.

    Quote Originally Posted by centralnathan View Post
    ok did you under stand my example though?, if say starting small I just want to make a java applet that opens up that website in a jpanel with it included inside of it.
    Bowman 2 - Free Online Shooting Games from AddictingGames.
    Again, if you don't have source code for the game, then what you are attempting is difficult if not impossible to do, and I don't think anyone can give you generic advice that would likely help you.

    also please note I am very new to this, so I do not know the word Swing in my java vocab
    the textfield is this private JTextField jcomp5;
    and its a user input (but thats where I want the game the "textfield" is just a place holder
    If you're new, consider beginning a more reasonable newbie project.

Similar Threads

  1. Replies: 7
    Last Post: August 17th, 2013, 07:55 PM
  2. Java Noob needs help!
    By antares330 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: September 24th, 2012, 09:03 AM
  3. Help im a java noob!
    By jonathanfox in forum Collections and Generics
    Replies: 11
    Last Post: July 26th, 2012, 06:04 AM
  4. Noob needs help!
    By kram in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 2nd, 2011, 05:03 AM
  5. helloworld noob
    By LostFury2012 in forum What's Wrong With My Code?
    Replies: 12
    Last Post: July 14th, 2010, 06:29 AM