32,204 Topics
| |
I am having problems with the output of my program. The progam should Design a class named Employee. The class should keep the following information in fields: Employee name Employee number in the format XXX-L, where each X is a digit within the range 0-9 and [INDENT]the L is a … | |
i want to read file data as below. [ int, double, double] 1234 12.30 45.60 2345 23.40 67.50 3456 45.60 67.80 . into multiple arrays of type int, double and double. any help will be appreciated. | |
Ok here is my problem thus far. My program I have created is horrible lol...I am adult enough to admit it. My issue is the output I am getting that I will post after my code. It has weird characters at the top and I am not sure why. The … | |
As the title states, I can't get the background of my JFrame window to change. I would've bet that just .setBackground(Color.RED) would've worked but no luck. Here's my code: [CODE]import javax.swing.JFrame; import javax.swing.*; import java.awt.*; public class win { public static void main(String[] args) { JFrame guiWindow = new JFrame("Calculator"); … | |
Hi! Is it possible to dynamically update a text of items in JList? Let's say there is JList defined as follows: [CODE] list1.setModel(new AbstractListModel() { Object[] values = listOfTasks.toArray(); public int getSize() { return values.length; } public Object getElementAt(int i) { return "Task " + i; } }); [/CODE] As … | |
I can't figure out for the life of me why the names of the square and rectangle won't show up....can anyone help? [code] public class Square extends NamedShape implements Shape { public void Length() { System.out.printf("Please Enter Length Value: ", this.getLength()); } public Square(String name) { super(name); System.out.printf("Shape:", this.getName()); } … | |
Hi would you be able to clarify If you use a J list selection to access one of a number of StringArrays in a class. What needs to happen. Is it the selection of an 'name' in the JList can then can act as a reference The part I am … | |
Every time I think I am really making progress in understanding object oriented programming, I run into something that makes me have to go back and start all over again... This time its "subclassing". I believe that I understand the basics inheritance and overriding, but when I start to develop … | |
Hi all, I want to parse the elements in my arraylist to double. May I know how to implement that? [CODE]import java.io.*; import java.util.*; public class Array2 { static ArrayList myDouble = new ArrayList(); static String[] temp; static String[][] finalTemp; static String[] arr; static int rows; public static void main(String … | |
Hi everyone, I am having a little(lot of..) trouble figuring out how to combine a GUI I have made and the code that goes with it. I am vaugley familiar with action listener process, and I understand this is how to give functionality to buttons etc. However, the part I … | |
Hello gentlemen. I have a question over here. with the following piece of code i want to extract data from a document. The question is how can i assign the values [B]Sentences, Words[/B] in the Array. [CODE] String data[][]; //[files][sentences][words] public void ScanSearch() { for (int i = 0; i … | |
This file is saved as Employee.java [CODE]// Employee.java //Employee Class with a construuctor to initialize the first name, last . public class Employee { private String FirstName; //first name for this Employee private String LastName ; //last name for this Employee private double MonthlySalary; //Monthly salary for this Employee //constructor … | |
[CODE]java.lang.NoClassDefFoundError: Main Caused by: java.lang.ClassNotFoundException: Main at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:248) Could not find the main class: Main. Program will exit. Exception in thread "main" Java Result: 1[/CODE] after i had done my system. this error message pop up and restricted me … | |
Ok, well Ive pretty much finished my program and now all thats left is this error that keeps coming up and I dont know how or where to fix it. The error comes up under the bracket. Iam guess Iam missing a bracket at the end, but when I put … | |
Hi all I made this animation app and I think its all correct however i get a error message which is: Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 2, Size: 2 at java.util.ArrayList.RangeCheck(Unknown Source) at java.util.ArrayList.get(Unknown Source) at Animation.getScene(Animation.java:56) at Animation.getImage(Animation.java:49) at MainAnimation.draw(MainAnimation.java:64) at MainAnimation.movieLoop(MainAnimation.java:53) at MainAnimation.run(MainAnimation.java:34) at MainAnimation.main(MainAnimation.java:10) I cant … | |
[code]private void Search(java.awt.event.ActionEvent evt) { int rows = ((DefaultTableModel)jTable1.getModel()).getRowCount(); int index1 = 0; int index2 = 0; try { index1 = Integer.valueOf(jTextField1.getText()); index2 = Integer.valueOf(jTextField1.getText()); } catch (NumberFormatException e) { e.printStackTrace(); } if (index1 < 0 || index2 < 0 || index1 >= jTable1.getRowCount() || index2 >= jTable1.getRowCount()) { JOptionPane.showMessageDialog(jTable1, … | |
Hi all, I have a GUI and working programs, however I need to put the program into the GUI to make it work, but im experiencing the problem that my GUI codes are all in a class and my codes are in man different classes, is there a way to … | |
First off, yeah I know there are many codes out there for this, but how can one learn without doing. Ok So we need to write a code to see whether two words are anagrams of one another. Here is what I have, it compiles but does not work. The … | |
[CODE] class example { public static void main(string args []) { Sysytem.out.printIn (This is a simple Java program....); } } [/CODE] I am using Windows Vista Ultimate I tried to rum this program in DOS shell...... Error 1 :Exception in thread "main" java.land.NoClassDefFoundError : example I tried to remove it...by … | |
HEY GUYS I'M WORKING ON A CALCULATOR USING THE SCANNER CLASS. HOWEVER THERE IS A CATCH TO IT I CAN ONLY USE ADDITION AND SUBTRACTION TO CALCULATE ANSWERS. I HAVE TO MAKE IT INTERACTIVE AND ASK THE USER WHAT FUNCTION THEY WOULD LIKE TO DO(1.ADDITION,2.SUBTRACTION,3.DIVISION,4,MULTIPLICATION) I'M GOING TO USE A … | |
This is the sample code my proffessor posted online [CODE]import java.applet.*; import java.awt.*; public class AnAppletSubclass extends Applet { public void init() { System.err.println("Hello from AnAppletSubClass.init - the current value of n is " + n); color = Color.green; } public void paint(Graphics g) { setBackground(color); System.err.println("Hello from AnAppletSubClass.paint-- the … | |
hey guys, i have a little problem i have got a method that removes the line of text in a file. for example if i specify a name and the name is on one of the lines in the file.txt it would remove it. what i want is that once … | |
Hi there, i just joined this forum in hope improving my Programming skills. Currently i have a college assignmnt. It is to create a dice game "There is a little known dice game which is played with a pair of dice and has the following rules: the player keeps rolling … | |
I need to create a large integer array but I am not able to increase its size beyond max int value. How do I create larger arrays? | |
Hi! I'm trying to create String array from ArrayList. This task seems to be trivial, however I have a problem because of using "interface". The code and error message are shown below. Please, give me some advices to solve this problem. Thanks! [CODE]public class Class1 { public List<myInterface> getAllTasks() { … | |
hey everybody ... well im facing this difficulty .. i made one project .. and im not able to .. create a jar for it my project consists of the following files a package Prj that contains all the classes along with it i have 2 files.. with contain some … | |
Hi! Does somebody know how to get the total number of MenuItems in JPopupMenu? I'm searching for something like, popupmenu1.getNumberOfMenuItems(). I need it for the FOR statement [CODE](for int i=0; i<popupmenu1.getNumberOfMenuItems(); i++) { ... } [/CODE] Thanks! | |
[CODE] import javax.swing.*; import javax.swing.JFrame; public class Ejer1 { public static void main(String [] args){ JFrame frame = new JFrame (Box); frame.setVisible(true); frame.setSize(300,300); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JLabel label = new JLabel(); JPanel panel = new JPanel(); frame.add(panel); frame.add(label); System.out.println("*********"); System.out.printf("%s\n%s\n%s\n%s\n%s\n", "* *","* *","* *", "* *", "* *","*", "* *","* *","* *","* … | |
Need idea for start this program.....? Consider the following Student class specification: public Student() //CONSTRUCTOR Initialized the attributes public String name () This Student’s name public String address() This Student’s address public String matric () This Student’s matric number public int creditHours () Number of credit hours this Student enrolled … | |
Hello Members, How do I change the code below sothat I can have the JLabel at the center of the JFrame and the two JButtons directly below the JLabel? Thank you! [CODE]import java.awt.*; import javax.swing.*; public class Layout { public static void main (String args[]) { JFrame m = new … |
The End.