I would like to type in an empty ComboBox and when I hit enter, have the item added to the ComboBox. Is this possible?
I'm assuming I would need some sort of Event Listener to change the ComboBoxModel.
Any help would be appreciated thanks.
User Profile
Collapse
-
Thanks everyone, I'm pretty lost on how to check for two carriage returns in a row. -
okay I figured it out by using !cin.eof() for the while condition.
I'm wondering how I can end the program after the user enters in their sentence in terminal. Right now, when I press enter after a sentence, it doesn't end the program and just waits for me to type more.
should I put some sentinel condition in the while loop to end program?Leave a comment:
-
Null cipher question
Hi everyone,
I'm trying to figure out how to encrypt something with a null cipher such as if someone typed "hi", it would put 1 random character in front of 'h' and inbetween 'h' and 'i' and after 'i'.
so I could do something like this:
...Code:int main (int argc, char *argv[], char **env) { int c , count = 1;//atoi(argv[1]) ; srand(time(NULL)) ; c = rand() % 94 ; c += 32 -
After some much needed sleep, I decided to stick with the while loop. It makes my code much more simply and works for my application.
Thanks to everyone for helping, especially Jos
Feel free to help improve this loop.Code:while (x < isbn.length()) { if (isbn[x] == 'X' || isbn[x] == 'x' || isdigit(isbn[x])) x++; else isbn = isbn.erase(x, 1); }Leave a comment:
-
wow its late, I just get caught up in for loops too much and never really think of while loops. Anyways, I decided to scrap the for and while loops and use a recursive method.
...Code:string remove(const string &s) { if (s.size() != 0) { if (s.size() == 1) { if(isdigit(s[0]) || s[0] == 'X' || s[0] == 'x') return s; else return ""; }Leave a comment:
-
Now I'm wondering how I would process the the string if there were less than 10 digits. Seems like I would have to remove all the things I don't want then get the size of the new string, but seems like I would need to know the size of the string with all the things I don't want from the beginning.Leave a comment:
-
advice noted!
any suggestions on how to make it better? I noticed when I entered a number such as 0-13-613950------X, the program would just halt or possibly be in a infinite loop.
//edit
nevermind the last part of it, only occurs when my string has less than 10 digitsLeave a comment:
-
Thanks to both of you for the explanation and solution!
I made my new loop:
Code:string isbn = "0-13-613950-X"; // Go through isbn, remove any non digits int x = 0; while (x < 10) { if (isbn[x] == 88 || isdigit(isbn[x])) x++; else isbn = isbn.erase(x, 1); } cout << isbn << endl;Leave a comment:
-
Help with a loop that's suppose to remove all non-digits
Hi,
I'm having a problem explaining why this loop does what it does.
output is -0-136-15-250-3Code:string isbn = "--0---13-6--15--250-3"; // Go through isbn, remove any non digits for ( int x = 0 ; x < 10 ; x++) { if (!isdigit(isbn[x])) isbn = isbn.erase(x, 1); } cout << isbn << endl;
Why doesn't... -
Thanks for the help!
but...
Do you know where I can read up more of the pack method? It sort of does what I want but I'll have more than 1 button on the window, each button should populate the content pane with new fields. The pack() method displays the field and when I press the button again, it'll duplicate the fields. Also it breaks the set size of the window.Leave a comment:
-
Sorry for the noob question but how would I do that? What would I put in the parameter of the Window header?...Leave a comment:
-
GUI - Change contentpane when button pressed
Hi everyone
I'm trying to change what shows up in the contentpane depending on what button you press. Say you press a button labeled "Customer", it would add textfields to the content pane.
I thought I could just add the action int eh actionPerformed method but doesn't seem to work.
Thanks for your help!
...Code:public class ButtonDemo extends JFrame implements ActionListener { -
Thanks for all your help, I added a serializedid to my class to fix the problemLeave a comment:
-
Do you have any idea what this means?
Error reading file Data/Customers/Will.dat.
java.io.Invalid ClassException: Customer; local class incompatible: stream classdesc serialVersionUI D = -585219468501467 1947, local class serialVersionUI D = -492827965364602 4047
at java.io.ObjectS treamClass.init NonProxy(Object StreamClass.jav a:546)
at java.io.ObjectI nputStream.read NonProxyDesc(Ob jectInputStream .java:1552)
...Leave a comment:
-
So make it Customer[] anotherArray = new Customer[2]; ?
Also I tried to rework the code... I thought this would work, but it doesn't... any idea?
...Code:for (int i = 0; i < 3; i++); { String cusName = null, cusEmail = null, cusPhone = null, cusServ = null; System.out.println("Customer information:"); System.out.print("Name: "); cusName = keyboard.nextLine();Leave a comment:
-
Binary files with array objects help
I know I'm making a mistake, but I'm wondering if someone could tell me the type of mistake I'm making. I know I can write the whole array to a file, but I want to create separate binary files for each Customer. Then I want to readout the binary file... either one or all of them.
Could someone help me? Thanks.
...Code:Customer[] oneArray = new Customer[2]; oneArray[0] = new Customer("John", "[email protected]", -
Thanks JosAH,
That really helped a lot!
And thanks to everyone else!Leave a comment:
-
Thanks for the help, but I'm learning from a book and would like to figure out this recursion method. I know it would be easier to use iterative method or even regular expression.Leave a comment:
-
Help with a recursion method
Hi everyone,
I'm trying to write a recursive method that removes vowels from a string. If someone can help me formulate a pseudocode to do this, that would be great.
So far my code is:
...Code:public static void RemoveVowels(String str) if str.substring(0,1).compareToIgnoreCase("a" == 0) { str.replace("a", ""); RemoveVowels(s.substring(1));
No activity results to display
Show More
Leave a comment: