Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

what am i doing wrong? on this java gui  RSS feed

 
Richard Scott
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have this working in dos but I thought I would try to make it a gui but now having trouble.
here is the error in eclipse,

Multiple markers at this line
- Syntax error, insert "]" to complete ArrayAccess
- Syntax error, insert ")" to complete
SingleMemberAnnotation
- Syntax error on token "]", invalid (
- Syntax error on token "void", @ expected
- Syntax error, insert "class Identifier" to complete
ClassHeader
and also
selection does not contain a main type

here is my code:
package dearbranditest;

import javax.swing.JOptionPane;
import java.util.Scanner;
public static void main (String[] args){
{
Scanner Keyboard = new Scanner(System.in);
JOptionPane.showMessageDialog(null, "Please enter your name.");
String name = Keyboard.next();
name = "Brandi";
JOptionPane.showMessageDialog(null, "Welcome " + name + " ! Please select an option.");
int choice = 0;
while (choice!=9){
JOptionPane.showMessageDialog(null, 0 );
JOptionPane.showMessageDialog(null, "(1): Love Poem");
JOptionPane.showMessageDialog(null, "(2): Love Letter");
JOptionPane.showMessageDialog(null, "(3): Awesome ASCII Art");
JOptionPane.showMessageDialog(null, "(4): More Awesome ASCII Art");
JOptionPane.showMessageDialog(null,"(9): enter text here");
JOptionPane.showMessageDialog(null, 0);
JOptionPane.showMessageDialog(null,"Pick a number please: ");
choice = Keyboard.nextInt();
if (choice == 1) {
JOptionPane.showMessageDialog(null,"My First, My Last, My Valentine");
JOptionPane.showMessageDialog(null,"by Sokea Meas");
JOptionPane.showMessageDialog(null,"I've never imagined that there can be this day.");
JOptionPane.showMessageDialog(null,"A day that love will find its way.");
JOptionPane.showMessageDialog(null,"Out of my heard and into your soul.");
JOptionPane.showMessageDialog(null,"These feelings I have are beyond my control.");
JOptionPane.showMessageDialog(null,"All my life I have waited patiently.");
JOptionPane.showMessageDialog(null,"For a goddess like you, so beautiful, so lovely.");
JOptionPane.showMessageDialog(null,"Words can not express the way I feel.");
JOptionPane.showMessageDialog(null,"These feelings towards you are for real.");
JOptionPane.showMessageDialog(null,"You are the reason that I go on.");
JOptionPane.showMessageDialog(null,"Eternity Can't separate this special bond.");
JOptionPane.showMessageDialog(null,"This heart of mine is reserved for you.");
JOptionPane.showMessageDialog(null,"Forever it is yours, this love is true.");
JOptionPane.showMessageDialog(null,"I will be your first and you will be my last.");
JOptionPane.showMessageDialog(null,"My world, my everything, till my time has passed.");
JOptionPane.showMessageDialog(null,"I will always love you until the end of time.");
JOptionPane.showMessageDialog(null,"MY LOVE, MY BUTTERFLY, MY VALENTINE!");
} else if (choice == 2){
JOptionPane.showMessageDialog(null,"My Dearest " + name + "! I love you with all my heart!");
JOptionPane.showMessageDialog(null,"I hope you know that you mean the world to me and always have.");
JOptionPane.showMessageDialog(null,"In our lives there has been ups and downs and I want you to know that");
JOptionPane.showMessageDialog(null,"I will never give up on you or our relationship.");
JOptionPane.showMessageDialog(null,"You are the most beautiful, loving, caring, sexy, and smartest person ever");
JOptionPane.showMessageDialog(null,"Lots of love from your puppy, Richard.");
} else if (choice == 3) {
JOptionPane.showMessageDialog(null," @@@@@@ @@@@@@");
JOptionPane.showMessageDialog(null," @@@@@@@@@@ @@@@@@@@@@");
JOptionPane.showMessageDialog(null," @@@@@@@@@@@@@@ @@@@@@@@@@@@@@");
JOptionPane.showMessageDialog(null," @@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@");
JOptionPane.showMessageDialog(null," @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
JOptionPane.showMessageDialog(null,"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
JOptionPane.showMessageDialog(null,"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
JOptionPane.showMessageDialog(null,"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
JOptionPane.showMessageDialog(null," @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
JOptionPane.showMessageDialog(null," @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
JOptionPane.showMessageDialog(null," @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
JOptionPane.showMessageDialog(null," @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
JOptionPane.showMessageDialog(null," @@@@@@@@@@@@@@@@@@@@@@@@@@@");
JOptionPane.showMessageDialog(null," @@@@@@@@@@@@@@@@@@@@@@@");
JOptionPane.showMessageDialog(null," @@@@@@@@@@@@@@@@@@@");
JOptionPane.showMessageDialog(null," @@@@@@@@@@@@@@@");
JOptionPane.showMessageDialog(null," @@@@@@@@@@@");
JOptionPane.showMessageDialog(null," @@@@@@@");
JOptionPane.showMessageDialog(null," @@@");
JOptionPane.showMessageDialog(null," @");
} else if (choice == 4) {
JOptionPane.showMessageDialog(null," ..8888888.. ..8888888..");
JOptionPane.showMessageDialog(null," .8:::::::::::8. .8:::::::::::8.");
JOptionPane.showMessageDialog(null," .8:::::::::::::::8:::::::::::::::8.");
JOptionPane.showMessageDialog(null," .8:::::::::::::::::::::::::::::::::8. ");
JOptionPane.showMessageDialog(null," 8:::::: ::::' ':::' ':::: : :::::8 ");
JOptionPane.showMessageDialog(null," 8:::::: ::: ' ::: : :::::8 ");
JOptionPane.showMessageDialog(null," 8:::::: ::: ::: : :::::8 ");
JOptionPane.showMessageDialog(null," '8::::: ::::. .:::: : ::::8' ");
JOptionPane.showMessageDialog(null," '8:::: ::::::. .:::::: : :::8' ");
JOptionPane.showMessageDialog(null," '8::: ::::::::.::::::::. .::8' ");
JOptionPane.showMessageDialog(null," '8:::::::::::::::::::::::::8' ");
JOptionPane.showMessageDialog(null," '8:::::::::::::::::::::8' ");
JOptionPane.showMessageDialog(null," '8:::::::::::::::::8' ");
JOptionPane.showMessageDialog(null," '8:::::::::::8' ");
JOptionPane.showMessageDialog(null," '8:::::8' ");
JOptionPane.showMessageDialog(null," '8' ");
} else if (choice == 9) {
JOptionPane.showMessageDialog(null,"enter text here");
} else {
JOptionPane.showMessageDialog(null,"That is not a choice lol");
}
}

}
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If that is your real code, you're missing the entire class declaration. You can't have a main method outside a class. And if it's not real code, PostRealCode.

I also suggest you use proper indentation, so you'll be able to match your {'s with your }'s a lot better. And please UseCodeTags next time.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!