Is there a way to add an applet intro a JFrame ? more exactly I have a frame and when a button is pressed it should add to the frame the applet . Here is some sample code for better understanding :
public class principal implements ActionListener{
public static void main(String[] args) {
// code
JButton b1=new JButton("Start");
b1.setLocation(0,height-60);
b1.setSize(width,20);
i have created a frame with a menu bar displaying contents..now i want to set a username and password to that flame through an applet how to add applet to the frame??
here is my code ..
import java.awt.*; import java.awt.event.*; import java.applet.*; class MenuFrame extends Frame{ String msg=""; int flag=0; CheckboxMenuItem debug,test;
I am making a breakout like game in an applet for fun. i have the game working but for the last part of the game i want to make it so each time the game is played it adds the score the player. however, the code that i wrote does not work at all. Here is the code for the game.
I am trying to design a generic RPG game. The issue I am having right now is in my Class I have a subroutine (think that is the correct term) that is basically set up to hold a series of Print Statements. I am really just trying to get some Values that are stored within the Applet, have them assigned to their correct variables and then returned in the print statement. Yet, when I run the applet it just pops up the Applet blank and gives me a long list of errors and I really don't understand when they mean.
Here is the code:
The Class
public class CharacterSheet { final String NL = System.getProperty("line.separator"); public String characterName; int playerStr; int playerCha;
[Code] ....
And the error messages:
Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException: String is null at sun.java2d.SunGraphics2D.drawString(Unknown Source) at TFApplet.paint(TFApplet.java:15) at javax.swing.RepaintManager$3.run(Unknown Source) at javax.swing.RepaintManager$3.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method)
This is my codes in a button that if I click it . that information will send to Jtable but the problem is the jtable is in another frame so how can i connect this ?
DefaultTableModel model = (DefaultTableModel) new admin().tableBagtags.getModel(); if (txtName.getText().equals("")) { JOptionPane.showMessageDialog(null, "Please fill out all fields.", "Error!", JOptionPane.ERROR_MESSAGE);
I created a instance of a class AddItemView, inside StartUpMenuController. I then passed it into the class, the main method is below showing that as well. However when I do this:
else if(e.getSource()==menu.addBtn) { new addItem(); }
I get an error, little red line on the bottom of the text. I am testing the frame at the moment to make sure it is what I want before I move on to the Controller side of it. I just want to display it and go from there.
package mainMenu.Home.DataBase; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import addItemBtn.Home.DataBase.AddItemView; public class StartUpMenuController { StartUpMenu menu; AddItemView addItem;
[code]...
Not sure if this is the issue but the class I am making a new instance of is in a different package. I imported the package though.
i have been struggling with 2 frames.the question here is, how can you let a frame disappear and let another one appear.im making a game and when i click on start it needs to show another frame.got the whole code here:
import java.awt.Color; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; public class RushhourStart { public static void main(String [] args) { JFrame frame = new JFrame(); frame.setSize(700, 700); frame.setTitle("Rushhour"); frame.setLocationRelativeTo(null); frame.setDefaultCloseOperation(JFrame. EXIT_ON_CLOSE); frame.setVisible(true);
I'm trying to understand and learn Java for GUI but I'm stacked around a project. I had done some other "test app" but on this, I can't figure out what I had done. I can't move my circle around the panel.... Where I had made some errors?
Main class package main; // imports import javax.swing.JFrame; import java.awt.Dimension; public class Main { public static final int WIDTH = 320; public static final int HEIGHT = 240; public static final int SCALE = 2;
I'm pretty new at java and I was wondering on how to get all my methods on one world frame?
The code is this:
public class TurtleTester { public static void main (String[] args) { World world= new World(); Turtle turtle= new Turtle(world); turtle.drawRectangle(50,100); turtle.drawHexagon(100);
[Code]...
When I run the main method, it would give me a bunch of world frames with one method in each one. I'm using BlueJ btw.
This is my frame class, now I want to be able to change the name of the frame, and get the name with frame.getName() in another class. But I'm not sure how to do this, i tried making a new frame in that class but i feel it's just another frame and not the one i made, also tried something like
I wrote the following code to get a frame,button in south and a red color circle,which i got.In the "actionPerformed" method i wrote "setContentPane(mp2)" thinking it would put another panel on the frame with a blue circle but when i pushed the button,the button got stuck and the circled did not change.
import java.io.*; import javax.swing.*; import java.awt.*; import java.awt.event.*; class Fra implements ActionListener { MyPanel2 mp2; JFrame frame; JButton button; public static void main(String[] args)
I'm new to Java and I'm trying to pass several values from one frame to another. I've searched around and most codes I've come across are from auto generated GUI code. This what I've been trying to do
Frame1
private class SubmitButtonListener implements ActionListener { public void actionPerformed (ActionEvent e) { Frame2 f2 = new Frame2(); //call setValue from Frame2 f2.setValue(4.0); f2.setVisible(true); } }
Frame2
private double val; public double getvalue() { return val; } public void setValue(double v)
I was following a tutorial on how to make a game when i suddenly got an error concerning moving tiles. i get this error when i tried to use a and d to move:
Exception in thread "Display" java.lang.ArrayIndexOutOfBoundsException: 48600 at com.cherno.graphics.Screen.render(Screen.java:44) at com.cherno.Game.render(Game.java:124) at com.cherno.Game.run(Game.java:87) at java.lang.Thread.run(Unknown Source)
I do not get the error while using w or s but the tiles are still not moving when pressing them.
so i'm working in a chat program and i'm trying to make it so that you are able to open another tab yet still be able to chat.
right now the client that the user download uses the keyadapter to get the keyboard input, but whenever the user un-focus the chat window, the keyadapter no longer gets the keyboard input.so is there another way i can get the keyboard input? so it doesn't matter what window you are focused on, you get the keyboard input either way?
I simply want to paint an image on my frame, just once each time the paint() method is called, but how to call the paint method in any good way. This is how it looks:
I have a guessing game that im working on but it wont add my buttons to the frame, why?
// GuessGame.java // Guess the number import javax.swing.JFrame; public class GuessGame extends JFrame { public static void main(String args[]) { GuessGame panel = new GuessGame(); panel.setSize(400,350);
[Code] ...
The window pull up and even in the design view it shows everything on there but when i run its just a blank window.
i want to know how i can add more than one frame in a single frame means main window or frame will be constant and only components will be chang or vary as in a software or game .