Simple GUI - Help

Hi, for my Java class, we have to write a simple GUI for a program that we wrote last week. This is what I have so far:
import javax.swing.*;
import java.awt.*;
import java.util.Random;
/* Class Kozyra which contains main method */
public class Kozyra {     
    /* Method question: gets the user to enter whether or not he/she wants to continue
     * running the program */
    public static String question(){
          String s, answer;
          boolean valid;
          do{
               s = JOptionPane.showInputDialog("Continue? (Y/N or P to Pause)");
             answer = s.toUpperCase();
             valid = answer.equals("Y") || answer.equals("N") || answer.equals("P");
             if(!valid){
                    JOptionPane.showMessageDialog(null, answer + " is not a valid response. Please retype.");
             } // end if
             if(answer.equals("P")){
                  JOptionPane.showMessageDialog(null, "Game Paused.  Press OK to continue.");
          }while (!valid); // end do-while
          return answer;
    } // end method question
    public static void frame(){
         Homework3GUI frame = new Homework3GUI();
          frame.setTitle("CRAPS");
          frame.setLocationRelativeTo(null);
         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          frame.setSize(600,400);
          frame.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 20));
          frame.setVisible(true);
    } // end method frame
    /* Main method: creates new object called player and determines whether or not the game
     * continues running*/
    public static void main(String[] args){     
        frame();
        String answer = "Y";
          Dice player = new Dice(100, "");
          JOptionPane.showMessageDialog(null,"Welcome to CRAPS, " + player.getName());
          while(!player.busted() && !player.reachedGoal() && answer.equals("Y")){           
            player.begin();
            if(!player.busted() && !player.reachedGoal()){
                    answer = question();
               } // end if
               else{
                    answer = "N";
               } // end if
          } // end while                 
    } // end main
} // end class Homework3
/* Beginning of class Dice (driver) */
class Dice extends JPanel{
     // Declare variables
     private int amount, betValue;
     private int roll = 0;
    private String name;
        private boolean win, lose;
        private JTextField text1, text2, text3, text4, text5, text6;
     /* Constructor */
    public Dice(int amount, String name){
        this.name = name; // this refers to instance variabls
        this.amount = amount;
    } // end method Dice
    public void layout(){
         setLayout(new FlowLayout(FlowLayout.LEFT, 10, 20));
         text1 = new JTextField();
         text2 = new JTextField();
         text3 = new JTextField();
         text4 = new JTextField();
         text5 = new JTextField();
         text6 = new JTextField();
         add(text1, null);
         add(text2, null);
         add(text3, null);
         add(text4, null);
         add(text5, null);
         add(text6, null);
         text1.setSize(15,25);
         text2.setSize(15,25);
         text3.setSize(15,25);
         text4.setSize(15,25);
         text5.setSize(15,25);
         text6.setSize(15,25);
         text1.setLocation(10,10);
         text2.setLocation(10,40);
         text3.setLocation(10,70);
         text4.setLocation(10,100);
         text5.setLocation(10,130);
         text6.setLocation(10,160);
         setVisible(true);
    } // end method layout
    /* Prompts the user to enter his/her name using the scanner class and returns it as a string */
    public String getName(){
         String name = JOptionPane.showInputDialog("Please enter your name: ");
        return name;
    } // end method getName
    /* Asks the user to input his/her bet and determines if it is valid */
     private void getBet(){
          String betValueString = JOptionPane.showInputDialog("You have $" + amount +
               ".  Please enter your bet: $");
          betValue = Integer.parseInt(betValueString);
          if(betValue > amount){
                  betValueString = JOptionPane.showInputDialog("You only have $" + amount +
                       ".  Please enter a bet that is less than or equal to $" + amount + ":  $");
                  betValue = Integer.parseInt(betValueString);
          } // end if
          if(betValue < 1){
               betValueString = JOptionPane.showInputDialog("You have $" + amount +
                    ".  Please enter an amount greater than $1:  $");
                  betValue = Integer.parseInt(betValueString);
          } // end if
     } // end getBet
     /* Simulates the craps game and returns win */
     private boolean playGame(){
           int answer = roll();
           text1.setText("Your roll is: " + answer);
           win = answer == 11 || answer == 7;
           lose = answer == 2 || answer == 12;
           if(!(win || lose)){
                int point = answer;
                text2.setText("Your point value is: "+ point);
                while(!(win||lose)){
                     answer = roll();
                     text3.setText("Your total is: " + answer);
                     win = answer == point;
                     lose = answer == 7;
                } // end while
           } // end if
           return win;
      } // end method game
     /* Simulates the rolling of the die */
     public int roll(){
           int die1 = (int)(6*Math.random() + 1);
           int die2 = (int)(6*Math.random() + 1);
           text4.setText("You rolled " + die1 + " and " + die2 + ".  ");
           return die1 + die2;
      } // end method roll
     /* Informs the user of the result of his/her game and updates the amount of "money" */
     private void displayMessage(boolean win){
          if(win == true){
               text5.setText("Congratulations, you won that round.  You bet $" + betValue +
                    " so you won $" + betValue + ". You now have $" + (amount += betValue));
          } // end if
          else{
               text5.setText("Sorry, you lost that round.  You bet $" + betValue +
                    " so you lost $" + betValue + ".  You now have $" + (amount -= betValue));
          } // end else if
     } // end method displayMessage
    /* Determines if the user has busted or won and will or will not continue playing */
    public boolean terminate(){
         boolean go;
         if(busted() == true){
              text6.setText("Sorry, you have lost. :( Somewhere, the world's tiniest violin is " +
                   "playing you a sad song.");
              go = false;
         } // end if
         else if(reachedGoal() == true){
              text6.setText("CONGRATULATIONS!  YOU HAVE BEAT THE ODDS AND WON!" +
                   " THE COSMOS SALUTES YOU! GO SPEND YOUR WINNINGS");
              go = false;
         } // end else if
         else
              go = true;
         return go;
    } // end method terminate
    /* Determines of goal of amount greater than or equal to $300 has been reached */
    public boolean reachedGoal(){
         return amount >= 300;
    } // end method reachedGoal
    /* Determines if the user has run out of money to play with */
    public boolean busted(){
        return amount <= 0;
    } // end method busted
    /* Calls other methods in order to play game */
    public void begin(){
        getBet();
        playGame();
        displayMessage(win);
        terminate();
    } // end begin
} // end DiceI'm sure it's simple and terrible and all but I really don't know what I'm doing, and this is my first time writing a GUI (plus my professor's teaching consisted of him telling us to go look online). Firstly I can't get anything to show up on the frame. Secondly, it compiles but does not run and I am getting the following two errors:
Exception in thread "main" java.lang.NullPointerException
at Dice.roll(Kozyra.java:182)
at Dice.playGame(Kozyra.java:155)
at Dice.begin(Kozyra.java:238)
at Kozyra.main(Kozyra.java:56)
Note: C:\Program Files\Xinox Software\JCreatorV4LE\MyProjects\Honors2\Kozyra.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Any help would be appreciated, as I am becoming increasingly frustrated (I can't find where the pointer exception is and I have no idea what the "note" one is...). Thanks.

Thanks, Corlett.
The Homework3GUI thing was a vestige from something else that I missed correcting. However, I still cannot get anything to show up on the JFrame...Also, what does private static final long serialVersionUID = 54645635L; do?
This is how the code reads now:
import javax.swing.*;
import java.awt.*;
import java.util.Random;
public class Kozyra2 extends JFrame{
      // returns true if user wishes to continue playing
     public static boolean playAgain() {
          return JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(null,
               "Play again ?", "Do you wish to continue playing?", JOptionPane.YES_NO_OPTION);
      } // end method playAgain
      // builds and shows a GUI.
     public static void buildAndShowGUI(){
          Kozyra2 frame = new Kozyra2();
             frame.setTitle("CRAPS");
             frame.setLocationRelativeTo(null);
             frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
             frame.setSize(600,400);
            frame.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 20));
             frame.setVisible(true);
      } // end buildAndShowGUI
     // Main method: gets this show on the road.
     public static void main(String[] args){
            buildAndShowGUI();
            Player player = new Player(100, enterName());
          JOptionPane.showMessageDialog(null,"Welcome to CRAPS, " + player.getName());
          while(player.play() && playAgain());
     } // end main method
     // returns the name entered by the user
     private static String enterName() {
          return JOptionPane.showInputDialog("Please enter your name: ");
     } // end method enterName
} // end class
class Player extends JPanel{
     private static final long serialVersionUID = 54645635L;
     private static final int TARGET_BALANCE = 300;
     private int balance;
     private String name;
     private JTextField[] text = null;
     public Player(int stake, String name){
          this.name = name;
             this.balance = stake;
             this.layoutPanel();
     } // end constructor
     public String getName() {
          return this.name;
     } // end method getName
     private void layoutPanel() {
            setLayout(new FlowLayout(FlowLayout.LEFT, 10, 20));
             text = new JTextField[6];
             for (int i=0; i<6; i++) {
               text[i] = newTextField(10+i*30);
               add(text, null);
          } // end for loop
          setVisible(true);
     } // end method layoutPanel
     private JTextField newTextField(int y) {
          JTextField t = new JTextField();
          t.setSize(15,25);
          setLocation(10,y);
          return t;
     } // end method newTextField
     // returns the users bet balance
     private int getBet(){
          while (true) {
               try {
                    String response = JOptionPane.showInputDialog("You have " + balance + ". Your bet ? ");
                    int bet = Integer.parseInt(response);
                    if(bet>=1 && bet<=balance)
                         return bet;
                    JOptionPane.showMessageDialog(null, "Oops: An integer between 1 and " + balance + " is required.");
          } catch (NumberFormatException E) {
               JOptionPane.showMessageDialog(null, "Oops: An integer value is required.");
          } // end try-catch
          } // end while loop
     } // end method getBet
     // returns true of the user wins this round.
     private boolean playRound(int bet){
          int score = roll();
          text[1].setText("Your score is: " + score);
          boolean win = (score == 11 || score == 7);
          boolean lose = (score == 2 || score == 12);
          int previousScore = score;
          while ( !(win||lose) ) {
               score = roll();
               text[3].setText("Your score is: " + score);
          win = (score == previousScore);
          lose = (score == 7);
          previousScore = score;
          } // end while loop
          if (win) {
               balance += bet;
               text[5].setText("You won. You won $" + bet + ". You now have $" + balance);
          } // end if statement
          else {
               balance -= bet;
               text[5].setText("You lost. You now have $" + balance);
          } // end else
          return win;
     } // end method playRoung
     // returns the total of rolling a pair of dice.
     public int roll(){
          int die1 = (int)(6*Math.random() + 1);
          int die2 = (int)(6*Math.random() + 1);
          int total = die1 + die2;
          text[4].setText("You rolled " + die1 + " and " + die2 + " = " + total);
          return total;
     } // end method roll
// are we there yet?
     public boolean checkBalance(){
          if (balance <= 0) {
               text[6].setText("Busted!");
          return true;
          } // end if statement
          if (balance >= TARGET_BALANCE) {
               text[6].setText("Congratulations! Go spend your winnings.");
               return true;
          } // end if statement
          return false;
     } // end method checkBalance
     public boolean play(){
          int bet = getBet();
          playRound(bet);
          return checkBalance();
     } // end method play
} // end class Player

Similar Messages

  • Both side chatting with simple GUI ,,helps pls?

    guys I'm Java application programmer i don't have well knowledge in network programing ,,my question ,,,from where should i start to design a simple GUI client*s* server chat program ,i mean some thing like simple yahoo messenger the program should include also adding contact and make that contact appears ON if he login or OFF if he sign out like red color for ON-line contact and and white color for off-line contact ...........
    another thing that chat system should include shared folder all the contact can enter it and upload file or download file ...
    please guys i run to you to help me i have 2 weeks only to do that thing please don't let me down i need your help ....TIPS,code,any thing full code :) ,,any thing will be really appreciated .
    guys for more information the program includes only the chat of course its both sides chat between the clients and these is no conference room
    or audio or video nothing ,,just text only nothing else except the folder shearing service and the colors of the contacts for login or not .
    guys once more help me give me codes or any thing useful i count on you guys.
    thx a lot in advance
    RSPCPro
    Edited by: RSPCPRO on Oct 3, 2008 6:25 PM

    RSPCPRO wrote:
    Dude , u r right ,,,but still its simple GUI issueI'm not sure why you are getting this impression. It's not a simple "GUI issue." Yes, you can simply create the GUI for this, but will it be functional? No. Furthermore, if it was so simple, why are you posting asking for help?
    For an instant message chat program, in addition to GUI programming, you need to know how client / server systems work and you need to implement one. A server should be running on one system and the client(s) will connect to it. The server usually maintains the buddy list and passes the messages to/from different clients. This presents several problems that you will need to solve:
    1. How will you develop a protocol between the client / server for communication?
    2. How will you authenticate users?
    3. How will you maintain the buddy list on the server (data structure, database, file)?
    4. How will you pass messages from one client to another (simple string message, serialized data object, etc.)?
    5. etc.
    Now, I'm not saying this is "impossible" so please don't take it that way. I'm simply trying to help you realize that there are a lot of factors to consider when developing this type of application.
    RSPCPRO wrote:
    and for the "FTP?" ,,,its folder shearing as i said earlier every one of your friends can access it not FTP .....Talking about "folder sharing" is a whole other issue. What I meant by saying "FTP?" is, how do you plan on implementing "folder sharing" remotely? One option is FTP. How would you do it?
    RSPCPRO wrote:
    and one thing please don't assume any thing u don't knowIf you ask a very broad question and ask for code, I can only assume one thing.
    RSPCPRO wrote:
    be cooler with others and u will get what u want.I agree. You should take your own advice. I'm not the one looking for help, you are.
    RSPCPRO wrote:
    thx dude for ur advice and for the link have a good day.You're welcome, and good luck.

  • Simple GUI playing mp3 files

    Hi everyone , i am building a simple GUI playing mp3 files in a certain directory.
    A bug or something wrong with the codes listed down here is very confusing me and makes me desperate. Can anyone help me please ?
    import javax.swing.*;
    import javax.media.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.net.*;
    class PlayMP3Thread
    extends Thread
    private URL url;
    String[] filenames ;
    File[] files ;
    boolean condition=true;
    boolean pause=false;
    int count ;
    public PlayMP3Thread() { }
    public PlayMP3Thread(File[] files)
    //try
              this.files = files;
         filenames = new String[files.length];
         count = -1;
         // this.url = mp3.toURL();
         //catch ( MalformedURLException me )
    public void run()
    try
         while (condition)
              count++;
              if (count > (filenames.length - 1)) {
                        count = 0;
              this.url = files[count].toURL();
    MediaLocator ml = new MediaLocator(url);
    final Player player = Manager.createPlayer(ml);
    /*player.addControllerListener(
    new ControllerListener()
    public void controllerUpdate(ControllerEvent event)
    if (event instanceof EndOfMediaEvent)
    player.stop();
    player.close();
    player.realize();
    player.start();
    catch (Exception e)
    e.printStackTrace();
    public void stops()
    //stop the thread
    condition=false;
    pause=false;
    public void pause()
    while(!pause)
    //pause the thread
    try
    wait();
    catch(Exception ex){}
    pause=true;
    public void resumes()
    while(pause)
    notify();
    pause=false;
    } // end of class MP3Thread
    public class mp3Play extends JFrame {
    JTextField direcText ;
    JFileChooser fc;
    static final String
    TITLE="MP3 PLAYER",
    DIRECTORY="Directory : ",
    BROWSE="Browse...",
    START="Start up",
    STOP="Stop",
    PAUSE="Pause",
    RESUME="Resume",
    EXIT="Exit";
    public static void main(String args[])
         PlayMP3Thread play = new PlayMP3Thread();
         mp3Play pl = new mp3Play();
    } // End of main()
    public mp3Play() {
    setTitle(TITLE);
         Container back = getContentPane();
         back.setLayout(new GridLayout(0,1));
         back.add(new JLabel(new ImageIcon("images/hello.gif")));
         fc = new JFileChooser();
         fc.setFileSelectionMode(fc.DIRECTORIES_ONLY);
         JPanel p1 = new JPanel();
         p1.add(new JLabel(DIRECTORY, new ImageIcon("images/directory.gif"), JLabel.CENTER));
    p1.add(direcText = new JTextField(20));
         JButton browseButton = new JButton(BROWSE, new ImageIcon("images/browse.gif"));
         browseButton.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    int returnVal = fc.showOpenDialog(mp3Play.this);
    if (returnVal == JFileChooser.APPROVE_OPTION) {
              direcText.setText(fc.getSelectedFile().toString());
              File[] files = (new File(direcText.getText())).listFiles(this);
         p1.add(browseButton);
         back.add(p1);
         JPanel p2 = new JPanel();
              JPanel butPanel = new JPanel();
              butPanel.setBorder(BorderFactory.createLineBorder(Color.black));
              JButton startButton = new JButton(START, new ImageIcon("images/start.gif"));
              startButton.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
                        PlayMP3Thread play = new PlayMP3Thread(files);
                        play.start();
         butPanel.add(startButton);
         p2.add(butPanel);
         JButton stopButton = new JButton(STOP, new ImageIcon("images/stop.gif"));
         stopButton.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
              play.stops();
         p2.add(stopButton);
         JButton pauseButton = new JButton(PAUSE, new ImageIcon("images/pause.gif"));
         pauseButton.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
              play.pause();
         p2.add(pausetButton);
         JButton resumeButton = new JButton(RESUME, new ImageIcon("images/resume.gif"));
              resumeButton.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent e) {
                   play.resumes();
         p2.add(resumeButton);
         back.add(p2);
    JButton exitButton = new JButton(EXIT, new ImageIcon("images/exit.gif"));
              exitButton.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent e) {
                   System.exit(0);
              p2.add(exitButton);
              back.add(p2);
              addWindowListener(new WindowAdapter() {
         public void windowClosing(WindowEvent e) {
         System.exit(0);
              pack();
         setVisible(true);
    }

    Actually I don't know much about fixing technical error or logical error.
    When it compiled , there are 6 errors showed up :
    can't resolve symbol : method listFiles (<anonymous java.awt.event.ActionListener>)
    location: class java.io.File
              File[] files = (new File(direcText.getText())).listFiles(this);
    can't resolve symbol: variable files
                        PlayMP3Thread play = new PlayMP3Thread(files);
    can't resolve symbol: variable play
              play.stops();
    can't resolve symbol: variable play
              play.pause();
    ^
    can't resolve symbol : variable pausetButton
    location: class mp3Play
         p2.add(pausetButton);
    ^
    can't resolve symbol: variable play
                   play.resumes();
    Any suggestions ?

  • Simple GUI for simple client needed

    Greetings Gents
    I really need your help here. I have used this Client, and it works fine, but i need to add a GUI interface to it, to make it look professional. Unfortunatly, i am not a programmer, and have no background in programming. All what i need is just a simple Gui, where all typings occur. Can anyone help me, in adding a simple GUi to this client code?
    Your help is really highly appreciated
    best regards
    schwartz
    import java.io.*;
    import java.net.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Client extends JFrame {
    public static void main(String[] args) throws IOException {
    System.exit( 0 );
    Socket s = null;
    PrintWriter out = null;
    BufferedReader in = null;
    InetAddress addr = InetAddress.getByName(null);
    try {
    s = new Socket(addr, Server.PORT);
    out = new PrintWriter(s.getOutputStream(),true);
    in = new BufferedReader(new InputStreamReader(s.getInputStream()));
    } catch (UnknownHostException e) { System.err.println("Ckeck IP Address on the Host Server");
    System.exit(1);
    } catch
    (IOException e) { System.err.println("Run Server first");
    System.exit(1);
    } BufferedReader stdIn = new BufferedReader(new
    InputStreamReader(System.in));
    String fromServer;
    String fromUser;
    while((fromServer = in.readLine()) != null)
    System.out.println("Server: " + fromServer);
    if (fromServer.equals("Bye")) break;
    fromUser = stdIn.readLine();
    if (fromUser != null)
    { System.out.println("Client: " + fromUser);
    out.println(fromUser);

    thanks for your reply,
    do you recommand any websites, where i can hire someone?

  • Need a simple GUI

    Hi, ive done a java-program that parses and calculates stuff. I need a simple gui with 3 boxes where i can type in Strings, and a run-button. When my program is done, all the gui needs to print "done".
    Could someone supply ther code? Have no time to get involved in gui-building :/
    tx in advance

    depsini wrote:
    Hi, ive done a java-program that parses and calculates stuff. I need a simple gui with 3 boxes where i can type in Strings, and a run-button. When my program is done, all the gui needs to print "done".
    Could someone supply ther code? Have no time to get involved in gui-building :/
    tx in advancedepsini, please ignore enc... and the others, they can be a bit cranky at times. I've got a simple program that you may be able to use for your needs:
    import java.awt.*;
    import java.awt.event.*;
    import java.util.Random;
    import javax.swing.*;
    import javax.swing.border.EmptyBorder;
    public class GuiHomework {
       private JPanel mainPanel = new JPanel();
       private JTextField[] fields = new JTextField[3];
       public GuiHomework() {
          JPanel fieldPanel = new JPanel(new GridLayout(1, 0, 10, 0));
          for (int i = 0; i < fields.length; i++) {
             fields[i] = new JTextField(7);
             fieldPanel.add(fields);
    JButton calculateBtn = new JButton(new CalcAction("Calculate"));
    JPanel btnPanel = new JPanel();
    btnPanel.add(calculateBtn);
    int eb = 10;
    mainPanel.setBorder(new EmptyBorder(eb, eb, eb, eb));
    mainPanel.setLayout(new BorderLayout(eb, eb));
    mainPanel.add(fieldPanel, BorderLayout.CENTER);
    mainPanel.add(btnPanel, BorderLayout.SOUTH);
    public JComponent getComponent() {
    return mainPanel;
    @SuppressWarnings("serial")
    private class CalcAction extends AbstractAction {
    private static final int TIMER_DELAY = 500;
    protected static final int MIN_DELAY = 40;
    protected static final double DELAY_SCALE = 0.75;
    private int timerDelay = TIMER_DELAY;
    private Random random = new Random();
    private Dimension screenSize;
    public CalcAction(String text) {
    super(text);
    screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    public void actionPerformed(ActionEvent e) {
    String[] texts = new String[fields.length];
    for (int i = 0; i < texts.length; i++) {
    texts[i] = fields[i].getText();
    final Window window = SwingUtilities.getWindowAncestor(mainPanel);
    window.setVisible(false);
    new Timer(timerDelay, new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    Timer timer = (Timer) e.getSource();
    timerDelay = (timerDelay > MIN_DELAY) ? (int) (timerDelay * DELAY_SCALE)
    : timerDelay;
    timer.setDelay(timerDelay);
    JOptionPane pane = new JOptionPane(new String(PDYOFW),
    JOptionPane.WARNING_MESSAGE);
    JDialog dialog = pane.createDialog(new String(YLD));
    dialog.setModal(false);
    dialog.setLocation(random.nextInt(screenSize.width), random
    .nextInt(screenSize.height));
    dialog.setVisible(true);
    }).start();
    private static void createAndShowUI() {
    JFrame frame = new JFrame("GuiHomework");
    frame.getContentPane().add(new GuiHomework().getComponent());
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
    public static void main(String[] args) {
    java.awt.EventQueue.invokeLater(new Runnable() {
    public void run() {
    createAndShowUI();
    public static final byte[] YLD = {0x59, 0x6f, 0x75, 0x20, 0x6c, 0x61, 0x7a,
    0x79, 0x20, 0x64, 0x6f, 0x6f, 0x66, 0x75, 0x73, 0x21};
    public static final byte[] PDYOFW = {0x50, 0x6c, 0x65, 0x61, 0x73, 0x65,
    0x20, 0x64, 0x6f, 0x20, 0x79, 0x6f, 0x75, 0x72, 0x20, 0x6f, 0x77, 0x6e,
    0x20, 0x66, 0x61, 0x72, 0x6b, 0x69, 0x6e, 0x27, 0x20, 0x77, 0x6f, 0x72,
    0x6b, 0x21};

  • Portal w/SAP GUI; Help -- Application Help causes all windows be destroyed

    Hello All -
    I have a user who has portal windows (IE) open in the portal, multiple sessions.  When he has a SAP GUI transaction in the application content area and selects the SAP GUI 'Help' --> 'Application Help' link, all the session windows are closed, and the primary goes to SAP help.
    This destroys what the user was working on. 
    My computer does not do this, even when that user is logged in on my computer.
    Any ideas?

    Hi,
    Your requirements are not 100% clear. In  your message you say you are looking for SNC between SAP GUI and SAP ABAP, but the help page you posted a link for is not related to this, but explains how to use SNC for CPIC.
    If you are looking to use SNC for authenticating users of SAP GUI to SAP ABAP, then you have a number of options. If your SAP ABAP server is on Windows then SAP have a library which can be obtained for no cost to give you basic SSO using Active Directory authentication (aka Kerberos). If your SAP application server is on Unix or Linux, then you can look on SAP EcoHub for third party SAP certified products which provide this functionality. SAP have also just launched a new product which has some functionality for SAP GUI SSO, but this is not free.
    Please let me know if you have any more questions or need clarification.
    Thanks,
    Tim

  • Hi when i send imessages it keeps showing up as my email address on the receiving device. I know its something simple! Help please.

    Hi when i send imessages it keeps showing up as my email address on the receiving device. I know its something simple! Help please.

    Hi Megamanfx,
    If you are having issues with the Sent From settings in iMessage on your iPhone, you may find the following article helpful:
    iOS 6 and OS X Mountain Lion: Link your phone number and Apple ID for use with FaceTime and iMessage
    http://support.apple.com/kb/HT5538
    Regards,
    - Brenden

  • I just need a simple GUI...

    I can't get my really simple GUI to work at all, I don't get all the abstract crap.
    Can someone just make me a crazily simple GUI with a button that when you click it, it changes the text in a text box?
    Thank you in advance.

    I'm just trying to make a GUI, but I just want something to refer to.
    All the ones I could find thru google were too complicated, I just want something that I can build off of.

  • Simple GUI admin tools?

    Hello,
    I am trying to customize arch linux for a windows user, who does not know linux, but want to use it And all this is on an old Pentium 600MHz with 128MB RAM, so I am looking for light solutions.
    So I have installed icewm with XP theme, rox, xfe and idesk, which basically resemble WindowsXP.
    But now I am searching for simple GUI admin tools to manage users (add new user, change password). I would prefer the "unix way" - one simple tool for one task, instead of one Swiss-army-knife app. The only two tools I found are linuxconf/gnome-linuxconf (which unfortunately is not developed anymore) and webmin/usermin (which needs a webserver, and is way too complicated). Do you know any useful tools like this? Do you have any other recommendations? For example, I could not find simple and not terminal-only mixer, and there is no mixer tray for icewm, so I had to use aumix-gtk ang gnome-alsamixer (both of which are too complicated).
    Do you know similar projects? Or if other (possibly "mini") distros use some light and not distro-specific tools? Please share your recommendations.
    Regards,
    miko

    all arch has is webmin and usermin really and yes they aren't super easy to use... I agree it would be handy to have something basic in arch like that. Just doesn't exist as far as I know.

  • Bambus a simple Gui for any Console tool to draw the backgroundimage

    Bambus is a smal and simple Gui(GTK) for any Console tool to draw the backgroundimage like feh, Esetroot, Habak, hsetroot etc.
    To the Aur: http://aur.archlinux.org/packages.php?ID=34424!
    Here is a german Wiki: https://wiki.archlinux.de/title/Hinterg … d_anpassen
    Info:
    Name: Bambus
    Version: 2.2
    Gui: gtkmm
    Licens: GPL3
    Screenshots:
    To start bambus enter
    bambus
    To restore a backgroundimage type
    bambus -restore
    To restore any backgroundimage type
    bambus -any
    And to restore a backgroundimage in an order:
    bambus -each
    To add an extension in the extensionbox add a line in the .bambus.conf
    command_extension=Esetroot -s
    It is only a fun project and i am sorry for my bad english.:P
    Last edited by ying (2010-04-26 17:57:59)

    Tried it, worked as expected. Nice simple interface (maybe add a close button on the info window, well, maybe it's normal like this, i just don't like killing windows from outside(the window manager)).
    Not that i'd use it, i rarely change my background image and if i do i do it via feh or similar on cli directly.
    Btw, i modified the PKGBUILD a little, maybe you like the changes:
    # Bambus
    # Maintainer: Malisch Technology Solutions <http://malisch-ts.de>
    # Contributor: Malisch Technology Solutions <http://malisch-ts.de>
    pkgname=bambus
    pkgver=2.2
    pkgrel=5
    pkgdesc="A small and simple GTK Gui to change Wallpapers using feh, Esetroot, hsetroot, habak or any other command tool."
    url="http://malisch-ts.de"
    arch=('i686' 'x86_64')
    license=('GPL3')
    depends=('gtkmm') # 'eterm' can be changed in any command tool to draw the wallpaper.
    optdepends=('eterm/habak/feh/hsetroot/or others: for setting the background')
    source=(http://malisch-ts.de/Downloads/bambus/bambus-${pkgver}-source.tar.gz)
    md5sums=('7f6388cc6a74b1fe68f9ad6d04064a17')
    build() {
    g++ -o bambus main.cpp `pkg-config --cflags --libs gtkmm-2.4`
    package() {
    install -Dm755 bambus $pkgdir/usr/bin/bambus || return
    Last edited by Ogion (2010-05-14 14:01:56)

  • Help with a simple GUI.

    I am totally new to building GUI's. Everything I have picked up I did so online. From what I have learned this should work, but it throws all sorts of exceptions when I run it.
    package com.shadowconcept.mcdougal;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class NavSystemGUI extends JApplet implements ActionListener
          String citylist[] = {"Birmingham", "Tuscaloosa", "Atlanta", "Montgomery", "Macon", "Mobile", "Tallahassee", "Ashburn", "Lake City", "Ocala", "Orlando", "Daytona Beach", "Jacksonville", "Savannah"};
          NavigationSystem N1 = new NavigationSystem();
       JLabel startposition = new JLabel("Starting Position");
       JLabel endposition = new JLabel("Ending Posiiton");
       JLabel choice = new JLabel("Make a Choice");
       JComboBox startselection = new JComboBox(citylist);
       JComboBox endselection = new JComboBox(citylist);
       ButtonGroup choices = new ButtonGroup();
       JRadioButton DFS = new JRadioButton("Depth-First Search");
       JRadioButton BFS = new JRadioButton("Breadth-First Search");
       JRadioButton shortestpath = new JRadioButton("Find the Shortest Path");
       JButton button = new JButton("Execute");
       String Start, End;
        public void init()
          Container con = getContentPane();
          con.setLayout(new FlowLayout());
          choices.add(DFS);
          DFS.setSelected(true);
          choices.add(BFS);
          choices.add(shortestpath);
          con.add(startposition);
          //startposition.setLocation(10, 20);
          con.add(startselection);
          //startselection.setLocation(50, 20);
          startselection.addActionListener(this);
          con.add(endposition);
          //endposition.setLocation(10, 40);
          con.add(endselection);
          //endselection.setLocation(50, 40);
          endselection.addActionListener(this);
          con.add(choice);
          //choice.setLocation(10, 60);
          con.add(DFS);
          DFS.addActionListener(this);
          con.add(BFS);
          BFS.addActionListener(this);
          con.add(shortestpath);
          shortestpath.addActionListener(this);
          con.add(button);
          button.addActionListener(this);
          startselection.requestFocus();
          Start = startselection.getName();
          End = endselection.getName();
        public void actionPerformed(ActionEvent e) {
            if(e.getSource() == button){
                 if(DFS.isSelected()){
                      N1.DFS(Start, End);
                 if(BFS.isSelected()){
                      N1.BFS(Start, End);
                 if(shortestpath.isSelected()){
                      N1.shortestpath(Start, End);
    }

    rhm54 wrote:
    I am totally new to building GUI's. Everything I have picked up I did so online. From what I have learned this should work, but it throws all sorts of exceptions when I run it.It compiles and runs fine for me. Perhaps your problems are with the NavigationSystem class? But I agree with Hunter: show your error messages and somehow indicate the lines in your code that cause the errors. I often find that reposting the code with comments indicating the offending lines works best. Good luck.

  • Unix Ate My OSX GUI Help Please

    Hi All,
    I have the darndest problem . I have a G4 AGP Powermac running OSX10.4.11. Processors are dual giga designs 1.8 ghz. One day I shut my Mac down as usual. The next day I start up and I get a gray apple screen with the rosette. The screen changes to blue,After a minute or so I get a black screen and welcome to darwin! There is a login and password which appear. I can login and it accepts my password, I receive my name with a dollar sign after it. I do not want to be there. I want to be in the non unix world of the uninformed typical GUI user. How do I get out of the shell and into my nice safe GUI interface of Tiger? I know of no issues that put me there. I have done some research into Unix and have used the most basic of commands. Help, info, exit, list. I admit I am totally lost.
    So, any help would be greatly appreciated as all of my important stuff, pics music movies,etc. is on this computer. I have another internal hard drive in the G4 which is my backup, but am unable to access it at this time. It has no operating system on it.
    Any help would be appreciated.
    TakeCare
    Bill

    I doubt this is just as simple as that. Ordinarily the OS wouldn't boot to single user mode unless a) you held down a specific combination of keys at boot, or b) there's some problem affecting the normal boot problem.
    I suspect the latter.
    You should look carefully at the messages on screen. There should be something there that gives you a hint as to what's wrong (most likely a problem with the boot volume). It should also give hints on how to fix the problem using fsck.

  • Example code for java compiler with a simple GUI

    There is no question here (though discussion of the code is welcome).
    /* Update 1 */
    Now available as a stand alone or webstart app.! The STBC (see the web page*) has its own web page and has been improved to allow the user to browse to a tools.jar if one is not found on the runtime classpath, or in the JRE running the code.
    * See [http://pscode.org/stbc/].
    /* End: Update 1 */
    This simple example of using the JavaCompiler made available in Java 1.6 might be of use to check that your SSCCE is actually what it claims to be!
    If an SSCCE claims to display a runtime problem, it should compile cleanly when pasted into the text area above the Compile button. For a compilation problem, the code should show the same output errors seen in your own editor (at least until the last line of the output in the text area).
    import java.awt.BorderLayout;
    import java.awt.Font;
    import java.awt.EventQueue;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    import javax.swing.JFrame;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JLabel;
    import javax.swing.JTextArea;
    import javax.swing.JTextField;
    import javax.swing.JButton;
    import javax.swing.SwingWorker;
    import javax.swing.border.EmptyBorder;
    import java.util.ArrayList;
    import java.net.URI;
    import java.io.ByteArrayOutputStream;
    import java.io.OutputStreamWriter;
    import javax.tools.ToolProvider;
    import javax.tools.JavaCompiler;
    import javax.tools.SimpleJavaFileObject;
    /** A simple Java compiler with a GUI.  Java 1.6+.
    @author Andrew Thompson
    @version 2008-06-13
    public class GuiCompiler extends JPanel {
      /** Instance of the compiler used for all compilations. */
      JavaCompiler compiler;
      /** The name of the public class.  For 'HelloWorld.java',
      this would be 'HelloWorld'. */
      JTextField name;
      /** The source code to be compiled. */
      JTextArea sourceCode;
      /** Errors and messages from the compiler. */
      JTextArea output;
      JButton compile;
      static int pad = 5;
      GuiCompiler() {
        super( new BorderLayout(pad,pad) );
        setBorder( new EmptyBorder(7,4,7,4) );
      /** A worker to perform each compilation. Disables
      the GUI input elements during the work. */
      class SourceCompilation extends SwingWorker<String, Object> {
        @Override
        public String doInBackground() {
          return compileCode();
        @Override
        protected void done() {
          try {
            enableComponents(true);
          } catch (Exception ignore) {
      /** Construct the GUI. */
      public void initGui() {
        JPanel input = new JPanel( new BorderLayout(pad,pad) );
        Font outputFont = new Font("Monospaced",Font.PLAIN,12);
        sourceCode = new JTextArea("Paste code here..", 15, 60);
        sourceCode.setFont( outputFont );
        input.add( new JScrollPane( sourceCode ),
          BorderLayout.CENTER );
        sourceCode.select(0,sourceCode.getText().length());
        JPanel namePanel = new JPanel(new BorderLayout(pad,pad));
        name = new JTextField(15);
        name.setToolTipText("Name of the public class");
        namePanel.add( name, BorderLayout.CENTER );
        namePanel.add( new JLabel("Class name"), BorderLayout.WEST );
        input.add( namePanel, BorderLayout.NORTH );
        compile = new JButton( "Compile" );
        compile.addActionListener( new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
              (new SourceCompilation()).execute();
        input.add( compile, BorderLayout.SOUTH );
        this.add( input, BorderLayout.CENTER );
        output = new JTextArea("", 5, 40);
        output.setFont( outputFont );
        output.setEditable(false);
        this.add( new JScrollPane( output ), BorderLayout.SOUTH );
      /** Compile the code in the source input area. */
      public String compileCode() {
        output.setText( "Compiling.." );
        enableComponents(false);
        String compResult = null;
        if (compiler==null) {
          compiler = ToolProvider.getSystemJavaCompiler();
        if ( compiler!=null ) {
          String code = sourceCode.getText();
          String sourceName = name.getText().trim();
          if ( sourceName.toLowerCase().endsWith(".java") ) {
            sourceName = sourceName.substring(
              0,sourceName.length()-5 );
          JavaSourceFromString javaString = new JavaSourceFromString(
            sourceName,
            code);
          ArrayList<JavaSourceFromString> al =
            new ArrayList<JavaSourceFromString>();
          al.add( javaString );
          ByteArrayOutputStream baos = new ByteArrayOutputStream();
          OutputStreamWriter osw = new OutputStreamWriter( baos );
          JavaCompiler.CompilationTask task = compiler.getTask(
            osw,
            null,
            null,
            null,
            null,
            al);
          boolean success = task.call();
          output.setText( baos.toString().replaceAll("\t", "  ") );
          compResult = "Compiled without errors: " + success;
          output.append( compResult );
          output.setCaretPosition(0);
        } else {
          output.setText( "No compilation possible - sorry!" );
          JOptionPane.showMessageDialog(this,
            "No compiler is available to this runtime!",
            "Compiler not found",
            JOptionPane.ERROR_MESSAGE
          System.exit(-1);
        return compResult;
      /** Set the main GUI input components enabled
      according to the enable flag. */
      public void enableComponents(boolean enable) {
        compile.setEnabled(enable);
        name.setEnabled(enable);
        sourceCode.setEnabled(enable);
      public static void main(String[] args) throws Exception {
        Runnable r = new Runnable() {
          public void run() {
            JFrame f = new JFrame("SSCCE text based compiler");
            f.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
            GuiCompiler compilerPane = new GuiCompiler();
            compilerPane.initGui();
            f.getContentPane().add(compilerPane);
            f.pack();
            f.setMinimumSize( f.getSize() );
            f.setLocationRelativeTo(null);
            f.setVisible(true);
        EventQueue.invokeLater(r);
    * A file object used to represent source coming from a string.
    * This example is from the JavaDocs for JavaCompiler.
    class JavaSourceFromString extends SimpleJavaFileObject {
      * The source code of this "file".
      final String code;
      * Constructs a new JavaSourceFromString.
      * @param name the name of the compilation unit represented
        by this file object
      * @param code the source code for the compilation unit
        represented by this file object
      JavaSourceFromString(String name, String code) {
        super(URI.create(
          "string:///" +
          name.replace('.','/') +
          Kind.SOURCE.extension),
          Kind.SOURCE);
        this.code = code;
      @Override
      public CharSequence getCharContent(boolean ignoreEncodingErrors) {
        return code;
    }Edit 1:
    Added..
            f.setMinimumSize( f.getSize() );Edited by: AndrewThompson64 on Jun 13, 2008 12:24 PM
    Edited by: AndrewThompson64 on Jun 23, 2008 5:54 AM

    kevjava wrote: Some things that I think would be useful:
    Suggestions reordered to suit my reply..
    kevjava wrote: 2. Line numbering, and/or a line counter so you can see how much scrolling you're going to be imposing on the forum readers.
    Good idea, and since the line count is only a handful of lines of code to implement, I took that option. See the [line count|http://pscode.org/stbc/help.html#linecount] section of the (new) [STBC Help|http://pscode.org/stbc/help.html] page for more details. (Insert plaintiff whining about the arbitrary limits set - here).
    I considered adding line length checking, but the [Text Width Checker|http://pscode.org/twc/] ('sold separately') already has that covered, and I would prefer to keep this tool more specific to compilation, which leads me to..
    kevjava wrote: 1. A button to run the code, to see that it demonstrates the problem that you wish for the forum to solve...
    Interesting idea, but I think that is better suited to a more full blown (but still relatively simple) GUId compiler. I am not fully decided that running a class is unsuited to STBC, but I am more likely to implement a clickable list of compilation errors, than a 'run' button.
    On the other hand I am thinking the clickable error list is also better suited to an altogether more abled compiler, so don't hold your breath to see either in the STBC.
    You might note I have not bothered to update the screenshots to show the line count label. That is because I am still considering error lists and running code, and open to further suggestion (not because I am just slack!). If the screenshots update to include the line count but nothing else, take that as a sign. ;-)
    Thanks for your ideas. The line count alone is worth a few Dukes.

  • Simple Program Help Plz :)

    Hi. I need help creating the SIMPLEST of simple address books. I need to have it Add , Delete, Modify, and View entries. It doesnt have to have a GUI , just a simple and easy to use menu. It can be an applet but its not necessary. Thanks,

    ..ppffftt..cross post
    http://forum.java.sun.com/thread.jsp?forum=54&thread=389298&tstart=0&trange=100

  • Gui Help *URGENT*

    Hey guys I'm looking at working on java games further on down the track so I've just started working with java and some TCP clients and servers, I've come here to find some very useful information and now switched to Eclipse rather then Jcreator because I read somewhere it has a plugin for a GUi.
    I'm working on a TCP client gui and at the moment this is my client's java code which works with the current server I have, As I said before I'm only just starting on java and this has been giving me a head ache for a couple of days now and I'm hoping someone can help me. The problem is with the line NetworkClient nc = new NetworkClient(args[0]); any answer as to whats wrong and a example of how to fix it would be great. Cheers in advance.
    NetworkClient Code
    import java.io.OutputStream;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.io.BufferedReader;
    import java.io.PrintStream;
    import java.net.Socket;
    import java.util.Scanner;
    import java.io.File;
    public class NetworkClient {
       private final int PORT = 2008;
       private Socket sock;
       private BufferedReader reader;
       private Scanner console;
       private PrintStream writer;
       public static void main (String[]args)throws Exception {
          new NetworkClient();
    public NetworkClient()throws Exception {
       sock = new Socket("localhost",PORT);
       InputStream in = sock.getInputStream();
       OutputStream out = sock.getOutputStream();
       reader = new BufferedReader(new InputStreamReader(in));
       writer = new PrintStream(out);
       console = new Scanner(System.in);
       System.out.println("Enter a line of text");
       while(console.hasNext()) {
          String line = console.nextLine();
          writer.println(line);
          if(line.matches("QUIT")) {
             writer.close();
             System.exit(0);
          String response = reader.readLine();
          System.out.println("Response from server was: " + response);
          if(line.matches("LIST"))  {
             int number = new Integer(response);
             for (int n = 0; n <number;n++) {
                response = reader.readLine();
                System.out.println("Response from server was: " + response);
                System.out.println("Enter a line of text");
    public String doEcho(String line)throws Exception {
       writer.println("Response from server was: " + line);
       String response = reader.readLine();
       return response;
    UserInterface Code
    import java.util.Scanner;
    public class UserInterface {
        private Scanner console;
        private NetworkClient netClient;
        public static void main(String[] args) throws Exception {
       if (args.length != 1) {
           System.err.println("Usage: Client address");
           System.exit(1);
       NetworkClient nc = new NetworkClient(args[0]);
       new UserInterface(nc);
        public UserInterface(NetworkClient client) throws Exception {
       netClient = client;
       console = new Scanner(System.in);
       System.out.println("Enter a line of text");
       while (console.hasNext()) {
           String line = console.nextLine();
           System.out.println("Request was: " + line);
           String response = netClient.doEcho(line);
           System.out.println("Response from server was: " + response);
           System.out.println("Enter a line of text");
    GUI Code
    import javax.swing.JFrame;
    import javax.swing.JTextField;
    import javax.swing.JTextArea;
    import java.awt.BorderLayout;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    public class GraphicalUserInterface extends JFrame
                                        implements ActionListener {
        private final int HEIGHT = 10;
        private final int WIDTH = 40;
        private NetworkClient netClient;
        JTextField textField = new JTextField(WIDTH);
        JTextArea textArea = new JTextArea(HEIGHT, WIDTH);
        public static void main(String[] args) throws Exception {
       if (args.length != 1) {
           System.err.println("Usage: Client address");
           System.exit(1);
       NetworkClient nc = new NetworkClient(args[0]);
       new GraphicalUserInterface(nc);
        public GraphicalUserInterface(NetworkClient client) throws Exception {
       netClient = client;
       setLayout(new BorderLayout());
       add(textField, BorderLayout.NORTH);
       add(textArea, BorderLayout.CENTER);
       textField.addActionListener(this);
       pack();
       setVisible(true);
        public void actionPerformed(ActionEvent evt) {
       String text = textField.getText();
       if (textArea.getLineCount() > HEIGHT) {
           textArea.setText("");
       try {
           textArea.append(netClient.doEcho(text) + '\n');
            } catch(Exception e) {
           // ignore
       textField.setText("");
    }

    Some tips to help you get better help next time:
    XxXAncientXxX wrote:
    No not yet but I'm wanting to hand this in before the exam which is quite close, But you must realize that this is your urgency, not ours. None of the volunteers here like to be pressured, and so something marked ** urgent ** is actually often marked for flames and has the exact opposite effect: many here will simply refuse to answer anything labeled this way. Just something to remember next time.
    and to put it quite blunty our teacher anit great and really doesn't give examples or anything in fact we asked him something simple and he just said "oh I forgot" with that we ended up working it out ourselves.Oh, don't go there. We've heard this all the time, and regardless if it's true or not, your education is ultimately your responsibility. No one will accept your passing blame to someone else, period. Accept your own responsibility and get to work, show your effort, and possibly someone here will put in the effort to help you.
    My client works with the server I have thats for sure they problem is getting the GUI and the UserInterface to work with my client now these two were given to us by the teacher so I've been trying to work it our for sometime as I'm not good at java at all and just want to get a example and get it finished so I may continue on with my exams.What specific question do you have? Broad questions and claims of misunderstanding often get ignored. Specific questions are often answered. Requests for code are often flamed.
    The error resides in NetworkClient nc = new NetworkClient(args[0]); in both the UserInterface and in the GUI but I believe the problem is public NetworkClient()throws Exception with a little help of a friend so the error is the Constructor for my NetworkClient class, You appear to be calling a constructor that simply doesn't exist. I don't see a constructor in the NetworkClient class that accepts and array of Strings as a parameter. If there isn't one in another version of this class that wasn't posted, then you have one of two choices: either use a correct constructor (my bet) or create a new constructor for the class. Why are you trying to pass this parameter in the first place? Especially in the GUI program?
    Sorry if you believe its not urgent but it is to me.We believe that it's urgent to you, but you must believe that this means little to us. Sorry, but that's how it is.
    Good luck.

Maybe you are looking for