28 Posted Topics
Hi, I have a program that has a package that is imported in a class called Control.All the files are compiling correctly apart from when I try to import a package. I am importing the package by [CODE]package carpkg;[/CODE] and in my main there is [CODE]GUI gui = new GUI[/CODE] … | |
Hello, I am having some trouble with getting my menu to respond to a mouse click.I have 2 items on my menu, "New" and "Exit", and they are using the actionlistner like so [CODE] newFromMenu = new JMenuItem("New Screen"); newFromMenu.addActionListener(this); [/CODE] and then my action event [CODE] public void actionPerformed(ActionEvent … | |
Hi, I am having a terrible time getting to grips with layout managers, and am hoping someone can shed some light onto my misery.My problem is this: I have created a simple GUI, that contains a button panel, a picture panel and a radio button panel.All these panels are put … | |
Hello, I have created a simple frame, and in it there are 3 panels.I have a button in the bottom panel, and when pressed should display the text "You pressed the button", in the mainPanel.However this is not working.Can anyone shed some light as to what I am doing wrong … | |
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 DaniWeb, Basically like the title suggests I am having trouble generating a random element from my array, and storing it in another array. I am quite new to Java, and the api is a little confusing but from what I can see there is no method for this. Searching … | |
Hi, Like the title says I am having a little difficulty connecting a JSP page to database.Here is my code containing the setDataSource, I am pretty sure that this is whats causing the problem. [CODE] <%@ taglib prefix="sql" uri="htpp:/java.sn.com/jsp/jstl/sql" %> <sql:setDataSource var = "labdb" scope = "session" driver = "sun.jdbc.odbc.JdbcOdbcDriver" … | |
Here is a smaller program I made but the concept is much the same, what I understand( which is obviously not the case ) with this program is: The function returnFunc is called 3 times in main Each time is is called it returns a value from the array Is … | |
Hi all, im wondering if someone could offer a solution to my current problem which is passing and return information using pointer notation. I have created a small program using the class Person, who has a first and last name and methods to add and retrieve this information which looks … | |
Hi, Can anyone help me with this problem.For example i have a text file called food.txt with contents 1 apples 2 oranges 3 mango 4 bananna What i would like to do is enter the choice of fruit into a string and loop through the file until the word is … | |
Hi, Im wondering if someone could clarify a problem im having. Basically im trying to figure out how i can go about having a Class A object as an attribute of Class B,while still using Class A's functions. For example if have a class called clockRadio.In turn i have another … | |
Hi i am wondering if its possible to do the following,say i have 2 integer pointers containing numbers,and i want to add them together to a third integer pointer,is this possible? | |
Hi Im having a problem when it comes to dynamic memory allocation.I have a program that lets me pick the size of my array,and then input numbers into it. That all works well,it is when I try to add another int to this array that im having problems with,could anyone … | |
Hi, I am currently running on windows and have and issue when i try to read/write files,the problem being that it just doesn't happen. I know the code is correct because when I use a linux os and other windoze machines everything is ok..it just seems to be my computer. … | |
Hi i have a question about inputting to char*. For instance,i have made a class "Name",and am passing my constructors in as follows [CODE] Name* n1 = new Name("Nelly the elephant"); [/CODE] [CODE]Name::Name(char* name){ this->name = name; }[/CODE] But i am confused as to how i would code my addName().Ideally … | |
Hi, i am making a program that contains an integer array of an unknown size.The user is prompted to enter numbers into the array,and press 'x' to exit. What i am going to do then,is to pass the array from the main into a class which contains another array,but before … | |
<thread split from [URL="http://www.daniweb.com/forums/thread172315.html"]here[/URL]> Could i have an elaboration on this explanation please? My poblem being that i have wrote 2 objects to a binary file called "data.dat" No problem there. But then i have a function that needs to find the number of objects in the file.I can do … | |
I am trying to make a small program which will write to a binary file,this is my code: [CODE]// program that writes to a binary file #include <iostream> #include <fstream> using namespace std; main() { fstream* bfile = new fstream("file.bin", fstream::out | fstream::binary | fstream::ate); int a = 2; int … | |
Hi,im having trouble with fstreams at the moment,here is my code [CODE]// read contents of file using fstream // using the ->get() function. // Ascii files only. #include <iostream> #include <fstream> using namespace std; main(){ fstream* file = new fstream( "myfile.txt", fstream::in); char aSingleCharacter; //this will read a single char … | |
Hi i am in need of an explanation to the following: I have created a program to take in a string(stored in a character array). With my string,i must pass it into a function and 2 functions i have created are stringLength and toUpperCase.(i know there are string functions to … | |
Hi, I have made a small program to check if character arrays are the same(similar to string compare).This is my code so far: [CODE] // string Compare () #include <iostream> using namespace std; main(){ char a[10] = {'a','b','c','d','e','f','g','h','i','j'}; char b[10] = {'a','b','c','d','e','f','g','h','i','j'}; for(int i = 0; i < 10; i++) … | |
Cant seem to find the solution to this although its probably starting me straight in the face. Iv been at this for a few days now,can anyone help me spot the bug? [CODE]// test the bool #include <iostream> using namespace std; main(){ int turn; int var=2; while(var!=1){ cout << "1 … | |
HI, Today im tying to build a game program,im not really stuck on the coding aspect but its the concept of the 2 players in the game that is confusing me. For a starters, the game has 2 players.Player one goes first,after their go its player twos turn and so … | |
Re: If its a c string you could just print out the first element in the array [CODE]cout << your_array[0]; // prints out first element of array[/CODE] | |
Hi,Im having a hard time understanding the fundamentals of Object oriented programming.Ive made a really simple program that allows a user to enter a number, and then i have a function that doubles this number and returns it. But im still having the same errors that i had when i … | |
Hi, I am trying to write a simple program that stores a user input in a c-string,and will then print out each character (I)diaganolly across screen and (II) each character on a new line. The problem im having with this,and with c strings entirely,is that it keeps printing out random … | |
Hi, Im having a bit of trouble with a problem: Basically, I have an array with a set size,for example [CODE]my_array[40][/CODE] I am trying to figure out how to tell if it has less than 20 characters filled,and if it has more than 20 characters filled. I have tried the … | |
Hi ,im having a problem with my do while loop,basically I want it to loop so long as the users attempt is less than 10. However,it just doesnt want to seem to let me do this.Ive tried putting the "attempts++" several places through the loop as i thought this might … |
The End.