Noob Programmer Needs some help.
Code :
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.
Re: Noob Programmer Needs some help.
Quote:
Originally Posted by
centralnathan
.... 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.
Quote:
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.
Re: Noob Programmer Needs some help.
Quote:
Originally Posted by
curmudgeon
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
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.
Re: Noob Programmer Needs some help.
Quote:
Originally Posted by
curmudgeon
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
Re: Noob Programmer Needs some help.
Quote:
Originally Posted by
centralnathan
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.
Quote:
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.