I have a login window, which when sucessful will activate a new Applet/JFrame. The problem is that the login window remains in the background under the new JFrame. I want this to diappear. I want to either set the visibility to false, or close it.This is how the new window is started:
if(sucess.equals("flase")){
DBAccess dba = new DBAccess(); dba.setFname(fnameusr); //fnameusr dba.setLname(lnameusr); //lnameusr dba.main(null);
//LogIn.exit(0); }else{ JOptionPane.showMessageDialog(null, "Your credentials were not entered correctly or you may not be authorised to access this system."); System.exit(0); }
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 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)
The program loads, but nothing shows. I did some research and saw that I needed to set the JFrame to visible at the bottom of the frame section. I made the change, but it still does not show anything. Do I need to add everything that I added to the content pane to the frame? From my understanding you add elements to the panel, the panel to the contentPane, then the pane to the frame...
import javax.swing.*; import java.awt.event.*; public class menu { public static void main (String[] args){ JFrame frame = new JFrame("Menu"); frame.setVisible (true);
I need adding a textbox for users to input text onto my JFRame. Also how come the
frame.add(o);
is getting an error under the "add".
Main method class:
import javax.swing.JFrame; public class main { public static void main(String[] args) { JFrame frame = new JFrame(); bot o = new bot();
[Code] ......
Other class (this is where I want the textbox to be)
import javax.swing.JTextArea; import javax.swing.JTextField; public class bot { int x; int y; JTextField f = new JTextField(); JTextArea a = new JTextArea(30, 50); }
I am trying to add scrollbars to my frame containing many different components and appearing when user resizes the window with the mouse adds pictures and admin of this online application adds labels or other components.
I want scrollbars to appear when the frame is resized and has components you don't see under so you can scroll down.
If I have for example this code, how i add the scrollbars when i make frame smaller ?
public class Test extends JFrame { private JPanel contentPane; /** * Launch the application. */ public static void main(String[] args) { EventQueue.invokeLater(new Runnable() {
I decided to write a small Java program to experiment around with BorderLayout, because I'm developing a Java game and I need to have 2 objects placed in a single JFrame at the same time, and everyone I asked said I need BorderLayout to do that.Before you answer: Also, is using BorderLayout the best option for adding multiple video game oriented objects such a sprites to a JFrame?
So the Java program I wrote is supposed to place a JButton on the JFrame and ALSO place a graphic component (a rectangle in this case). The problem is, only the button shows up, as can be seen in the image link below: URL....
Here is the code:
**main.java** --> The main method class + JFrame/JPanel/JButton constructor import java.awt.BorderLayout; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; public class main {
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 facing problem when displaying my applet on jsp. I have convert my applet project into CustomColor.jar. my package is dcs.raj.MyApp
I have import my jar into project property. But still it is showing error on all browser, i have changed the java control panel > Advanced > Java Consol > Show console.
I have a java application in which when starting it a map is opened and a screen is captured. The capturing is in certain time interval. I want to enable the user to change the interval for the automatic capturing the map. I placed a text box in a JPanel. I want to pass the value which was entered in it to the html page which opens a Google map. Since I am new in java programming, I found that I can do it by using applets. I made an applet, and tried to call it in the html file. But now instead of opening the map file in a browser, it opens very quickly only black window.
Here is my applet:
package cege.ui; import java.applet.Applet; import java.io.IOException; import cege.ui.GuiMain; public class AppletTInterval extends Applet { private int TimeInterval=0;
[Code] .....
And the code in the html file where I try to call the applet, i.e. to pass the value which is returned by the applet is:
<script src= <!--"https://www.java.com/js/deployJava.js"></script> <script> var attributes = { id:'AppletTInterval', code:'cege.ui.AppletTInterval', width:1, height:1} ; var parameters = { jnlp_href: 'AppletTInterval.jnlp'} ;
[Code] .....
Can I use this way to pass a value from the java class file (from the JTextField into the html file?
I coded up a simple applet and some html with an applet tag and it tested out OK using the applet viewer. But it doesn't do anything (except draw a grey empty box 100x200) when executed from the application server. For the applicaton server test, I put the applet tag in the HTML Body of the JSP page i.e.
Technically, when you run the program, a gif page appears (that I put as a placeholder) and when you press the letter 'n' JCreator runs the program, displaying a character P on a .txt field made using the Notepad on Windows. You can move it left, right, down, and up andf it will move accordinly. However, each time I make such action, the compiler has to rewrite to whole .txt field with the new position.
My former tutor said that in order for it to be "real-time", we have to use an applet.