3,978 Topics
![]() | |
import java.io.*; import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.util.Random; public class snake1 { public static void main(String args[]) { String name1= JOptionPane.showInputDialog("Enter Player one's name"); Windows myW=new Windows(name1); myW.setSize(800,600); myW.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent event) { System.exit(0); } }); myW.show(); while(true) { myW.repaint(); try{Thread.sleep(60/myW.getLevel());}catch(Exception e){} } } } … | |
Hello friends, I want to overlap two JPanels at same location in the same frame... by clicking button on the same frame. If one panel is setVisible(true) at the same time if I click button and this Panel will be setVisible(false) another will be setVisible(true) but that does not resolve … | |
I am not able to click on the menu choices and have them fill out the form. I also am not certain that it is reading from the text file. Can someone check and let me know what I need to change in this program? [code] import java.awt.*; import java.awt.event.*; … | |
i need to convert this JApplet program into a JFrame, but dont know how to do it, can anybody help me please? [this is extremly urgent as i need to have this done by tuesday] [code=language] /*Game.java 5.5.08 This program, Game.java, is an educational game that tries to allow the … | |
Ok, I'm stumped and asking for a push. I need help adding an instance variable for my timer in my frame class. After that I need to : Instantiate your timer. Pass in the initial time (in seconds) and a reference to your timer display JTextField object. This can be … | |
I'm new to Swing, and still relatively new to Java as a whole, and am having trouble with my first Swing program. I'm trying to make a simple Pong game - it will display the title screen with a "Play" button on it that when pressed starts the game. Here … | |
[code] import java.io.*; import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.util.Random; public class snake1 { public static void main(String args[]) { String name1= JOptionPane.showInputDialog("Enter Player one's name"); Windows myW=new Windows(name1); myW.setSize(800,600); myW.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent event) { System.exit(0); } }); myW.show(); while(true) { myW.repaint(); try{Thread.sleep(60/myW.getLevel());}catch(Exception e){} } } … | |
Now this is an assignment for me, but ive spent the last two weeks writing this code day and night, I just cant get it out of my head, I have to beat it lol. So anyway, two days ago I won and completed my program exactly the way I … | |
[code=java] import java.awt.Color; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.SwingUtilities; public class Testing extends JFrame { public static void main(String[] args){ SwingUtilities.invokeLater(new Runnable() { public void run(){ new Testing(); } }); } private Testing(){ super("tester"); launch(); } private void launch(){ setBounds(200, 200, 300, 300); setDefaultCloseOperation(EXIT_ON_CLOSE); JPanel topPanel = new … | |
how to use AWT to write button tip? i don't want to use Swing. Please help me!:) | |
When I add buttons to a panel, the buttons seem to take a huge amount of space. How do I get rid of the space? For example: [CODE] import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Tester { public static void main(String[] args) { JButton dayButton = new JButton("Day"); JButton … | |
Hi Guys, I was trying to build a library catalogue with GUI (Graphic User Interface) which consists of two text boxes and four buttons. I have actually created the layout, but I dont know how to add actions to the buttons. Could anyone help me please. the Question is: for … | |
I have several files and am receiving errors message when compiling and would appreciate any help. Thank you in advance. Model class file: [CODE]class Model extends Product5 { String genre; //add product to product inventory double restockFee; //fee for restocking //initialize constructor public Model( String genre, String name, int identificationNumber, … | |
Good day to all! I am glad to join this technical forum. I am very new to programming and I am here to learn many technical things from the group. I have been assigned a task of developing an application for a project I am in. I have sought help … | |
Hi I have design a basic JFrame which displays three buttons in a frame. The code is given below: import java.awt.*; import javax.swing.*; public class PaymentFrame { public static void main(String[] args) { JFrame f = new JFrame("Payment Frame "); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setSize(800, 600); Container content = f.getContentPane(); content.setBackground(new Color(240,170,50)); content.setLayout(new … | |
Hello all! I am trying to create a form like structure using Swing to enter data into MySQL database. I have a combo box that has a list of items to be chosen. If the user does not find the option that he needs, he can choose 'Other' as an … | |
Hi all, I am getting Null pointer exception while getting other applet in the same page, can guide what i am doing wrong here is demo code [code] // First applet import java.applet.Applet; public class Applet1 extends javax.swing.JApplet { Applet applet1 = null; public void init() { try { java.awt.EventQueue.invokeAndWait(new … | |
I'm having a little trouble trying to nest two component classes (both extend JComponent) together. When I create the frame in my tester file, instantiate each class, and try to add both of them to the frame, it doesn't come out correctly. For instance, I want my frame to display … | |
Hi Everybody I am in need for help. I have a program which is surppose to allow the user to input a boat and a time and date of hire for that boat. Problem is that the button wont work and i dont know how to get the time in … | |
[CODE]import java.text.DecimalFormat; import javax.swing.JOptionPane; public class PayrollSystemTest { public static void main( String[] args ) { String workerType; String first; String last; String ssn; int month; int day; int year; float salary; float rate; float hourlyWage=0; float hours; float wage; float sales; DecimalFormat twoDigits = new DecimalFormat( "0.00" ); // … | |
hi guys, is there any stand alone GUI designer which could deal with most of Swing components and generate human readable code and also free | |
Hello, I have a simple GUI but when i put another Jframe in an action listener it squishes the main page in with the new Jframe, i know this is probably basic but my text book yeilds no result, here is my code. Maybe i am going about the process … | |
import java.io.*; import java.net.*; import java.awt.*; import java.awt.event.*; public class EmailSender { public static void main(String[] args) throws Exception { // Establish a TCP connection with the mail server. Socket soc = new Socket("gsmtp183.google.com", 25); // Create a BufferedReader to read a line at a time. InputStream is = soc.getInputStream(); … | |
Dear all, I'm newbie in Java/JSP. I have created project with Java Desktop for university lecture subject. But I still have one task, still with Java but in Web environment. I have this class. This class is used to get connection to MySQL. I create it for Java GUI [code=JSP]import … | |
I am trying to get the ST.java (Server Thread) to communicate with the CT.java (Client Thread), i am stuck at this point, i dont know rather it is something to do with the port # and host, or if it has anything to do with the Server thread, please reply … | |
Need help with this code. Anyone with knowledge on java please help. i found some on this forum, but that is also wrong. can anyone give me some help what is want is to smooth the values in an integer array. If its totally wrong please dont yell [code] import … | |
how can i calll a crystal report from a java swing program? can u pls send the answer with an exampl what are the jar files to be down loaded? and the xml files?? thanks in advance | |
Hi All, I am trying to develop an application which would use a combo box to obtain a set of records from a database table. Now on the count of number of records that are available in the table I need to populate a JPanel say Parent with another JPanel … | |
Here is my code. It will compile but will not execute. The error is Exception in thread "main" java.lang.NullPointerException at Calculator2.<init>(Calculator2.java.33) at Calculator2.main(Calculator2.java.91) [code] import java.awt.*; import javax.swing.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; class Calculator2 extends JFrame implements ActionListener { private JPanel panelAdder; private JLabel labela; private JLabel labelt; private JLabel … | |
hello all, I created a program that connected to database!.... I've done to display all records from database in JTable..... but when I'm deleting a row it can't delete automatically it needs to close the program to update the JTable!.... here's my program!.... package classes; import javax.swing.*; import java.awt.*; import … | |
I've tried searching the web and cant find anything to help me. I'm trying to create a 2D java maze application and have come up with the code below. It generates the maze and GUI no problem, and I've worked the code out to create a xPosition and a yPosition … | |
Hello, I strongly need your assistance what is needed to modify in order the board to inherit the complete functionality of the game. The clienthandler class contains all the methods for playing the game on the terminal [please check the code] Thanks in advance for any help ! [CODE=java] import … | |
[code] import javax.swing.JFrame; import java.awt.*; import java.awt.event.*; import javax.swing.ButtonGroup; import javax.swing.JButton; import javax.swing.JDialog; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JRadioButton; import javax.swing.JTextField; import javax.swing.UIManager; public class GUINew extends JDialog implements ActionListener { public static void main (String [] args) { protected JButton ok; protected JButton cancel; protected ButtonGroup type; protected JTextField … | |
I am in the middle of a program and have a quick question and not sure how i do this... "have the Frame display in the center of the monitor " [code=java] //import packages import java.awt.*; import java.awt.event.*; import java.awt.datatransfer.*; import java.text.DecimalFormat; import javax.swing.JOptionPane; //create a subclass at the fram … | |
following masijade advice i tried busting my head abit. i have written the following code import java.awt.event.*; import java.awt.*; import javax.swing.*; import javax.swing.border.*; public class Game extends JApplet implements ActionListener { //Creating a new JPanel called panel1 JPanel panel1 = new JPanel(); //Creating a JLabel for panel1 JLabel header = … | |
I'm able to set UIManager for UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel") and UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel") but for UIManager.setLookAndFeel("com.sun.java.swing.plaf.metal.MetalLookAndFeel") I get an error like this : java.lang.ClassNotFoundException: com.sun.java.swing.plaf.metal.MetalLookAndFeel What's wrong with my code ?? Thanks, Kusno. | |
Hey I am a newbie in java and I was wondering if someone can help me. Where would I place [QUOTE]int [] qDifference = new int [3]; for(int i = 0; i < 3; i++) { qDifference[i] = q[i + 1] - q[i]; }[/QUOTE] in the code below to show … | |
Hi all, How it is possible to make curved vertex of a swing container like JDialog. Say I the property setUndecratoed() to true, so there is just a rectangular shape window I have. I want to curved a vertex there. Any suggestions really appreciate. | |
I was sick the day on our review for this programming assignment so I am in kind of a dillema with a jerk for a professor...What I am going to do is after each section show you guys what I have and I don't think I should have too many … | |
So i'm a java student in 9th grade and my code gives me an error i have never encountered before... time is off the essence, so quick help is loved!: it says: Play.java:5: Play is not abstract and does not override abstract method keyReleased(java.awt.event.KeyEvent) public class Play extends JApplet implements … | |
//Below i am trying to display a map onto my grid layout using the ImageViewer and I keep //getting a error cannot find symbol class ImageViewer. I really need to use this //ImageViewer because i need to use the x and y coordinate. I don't know any image //viewer display … | |
I basically have the entire program done except for one little problem my maxDepth output is wrong! But the rest of the assignment is after your program gets the correct answers, add static variables calls, depth, and maxDepth to your class and add code to your implementation of Z to … | |
hey guys I've been trying to connect this jsp site with MySQL database for a school assignment and I just can't seem to get it to work. It's getting really really frustrating because I have copied my friend's code(which does work on his pc) and for some odd reason it … | |
[code] public void addRowsAntGrouping(){ Vector vectorAddRow = new Vector(); vectorAddRow.add(""); vectorAddRow.add(""); ((DefaultTableModel)jTableAntGrouping.getModel()).addRow(vectorAddRow); } [/code] Hi, I am in need of replacing the textfield of a table with combobox. the rows in the table are declared as vectors. there are two fields in the table. the first field is text and … | |
Dear all, I have these code below (netbeans) : All cells in columns "saldo Awal" are set to 58000000000.00, but appear in cell is 5.8E9 What should I fix in my code ? Thanks, Kusno import javax.swing.DefaultCellEditor; import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.DefaultTableModel; import java.awt.Component; import java.text.NumberFormat; import javax.swing.JTable; import javax.swing.JOptionPane; import … | |
I have to write an applet that asks the user to enter two floating-point numbers, obtains the two numbers from the user and draws their sum, product, difference and quotient. This is what I have so far. Can anyone make sure I am on the right track. import java.awt.Graphics; // … | |
Well this is a lab assignment, the problem I'm having is that the sample code he gave us is suppose to run as is, but it doesn't. I email him and he thought that most likely there might be a problem with the CLASSPATH for java or that I might … | |
Problem Description: You are to write a golf game that allows the user to play one hole, a 280 metre par 5. For each swing, the player chooses a club and then the program generates the distance hit for each shot, updating the distance to the hole accordingly. Play proceeds … | |
Devlope a Pedel boat class and a Rowing boat class and mark a boat as hired, storing the customer name and time, return a boat's details as a String, including customer name and time of hire if it currently hired out, calculate the amount due on a hired boat, given … | |
please help me in finding the proble in the following code import java.awt.*; import java.awt.image.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; class button extends JButton { public button(String s) { setName(s); setVisible(true); } } class label extends JLabel { public label (String s) { setText(s); setVisible(true); } } class loginform … |
The End.