Putting method in graphic window instead of console

Hello!
I want my blackjack game to run in a graphical window instead of in the console.
I have already made 2 buttons that starts the method(the blackjack game) and that shuts down the program. But when the program starts the text is printed in the console (which means that I have to write in the console if I want a new card or stand).
Help is very much appreciated!

OK :P
Yeah I got it to compile correctly when I changed:
"public void K�rspel() {"
to
"public String K�rspel() {"
but the problem now is that none of the graphical stuff shows and the program is looping endlessly haha :P
I can publish the whole thing instead :P
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Tjugoett extends JFrame implements ActionListener {
Kortbunt lek = new Kortbunt();
Manniska du = new Manniska(lek);
Dator jag = new Dator(lek,du);
private JButton starta = new JButton("Starta");
private JButton sluta = new JButton("St�ng av");
JLabel a = new JLabel(K�rspel());
public Tjugoett() {
Container c = getContentPane();
c.setLayout(new GridLayout(1,3));
c.add(starta); c.add(sluta); c.add(a);
starta.addActionListener(this);
sluta.addActionListener(this);
setVisible(true);
setSize(300,300);
setDefaultCloseOperation(EXIT_ON_CLOSE);
Container c2 = getContentPane();
c2.setLayout(new GridLayout(1,1));
setSize(350,100);
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
public String K�rspel() {   // changed this from void to String
boolean nyttParti�nskas = true;
lek.nyKortlek();
lek.blanda();
du.spela();
if (du.po�ng() > 21)
System.out.println("Du F�rlorade!");
else if (du.po�ng() == 21)
System.out.println("Du Vann!");
else {
jag.spela();
if (jag.po�ng() <= 21 && jag.po�ng() >= du.po�ng())
System.out.println("Du f�rlorade!");
else
System.out.println("Du Vann!");
return K�rspel(); // when changing from String to void I needed to write a return thing
public void actionPerformed(ActionEvent e) {
if (e.getSource()==starta)
K�rspel();
else if (e.getSource()==sluta)
System.exit(0);
public static void main(String[] arg) {
Tjugoett tj = new Tjugoett();
Do you think it can be because of the containers? That I need to change to JPanel instead? I am going to try it also and see what happens.

Similar Messages

  • Putting condition in Graphic WIndow in SAPSCRIPT

    I created 2 Graphic Windows for Company Logos. Each will appear/ hide according to the company code. I was planning to put a condition onto the window's code but it seems like it doesn't allow edit mode. Just the blue background. Is it possible to edit the graphic code? Are there other alternatives to post the 2 logos?
    POints will be given thanks!

    Hi,
    You need to make use of PERFORM-FORM concept to solve your problem.
    For eg:
    In your text editor of SAP script:
    write the following code:
    PERFORM SET_FLAG IN PROGRAM ZFI1_CHECKFORM
    USING &REGUH-ZBUKR&
    CHANGING &V_FLAG&
    ENDPERFORM
    Now, in the subroutine PROGRAM 'ZFI1_CHECKFORM' write the below code:
    FORM SET_FLAG TABLES in_tab STRUCTURE itcsy
                        out_tab STRUCTURE itcsy.
    Data Declaration
      DATA:zbukrs        TYPE bukrs.
      READ TABLE in_tab INDEX 1.
      zbukrs = in_tab-value.
      READ TABLE out_tab INDEX 1.
    IF NOT zbukrs IS INITIAL.
          out_tab-value = '1'.
        ELSE.
          out_tab-value = '0'.
        ENDIF.
    MODIFY out_tab INDEX 1.
    Try your requirement referring this piece of code.
    Reward points if helpful.
    Thanks,
    Asha

  • I have a pc with windows8.1 and it automatically puts download docuements to windows reader and cannot choose adobe acrobat instead or delete windows reader. How to i make adobe acrobat my download default for docuements instead of the windows reader.

    I have a pc with windows8.1 and it automatically puts download docuements to windows reader and cannot choose adobe  or delete/ get around the reader and the reader is jammed from deletion. How do |I make adobe acrobat my default reader?

    Open Acrobat manually and go to Edit - Preferences - General. Click the "Select Default PDF Handler" button and then select Acrobat from the list and click on OK. The next time you open a PDF it will be opened in Acrobat automatically.

  • Problem in Storing ByteArray(Value) with String (Key) using put method

    Hello Folks:
    I wish to store a byte array with associated with a String. For this I use the put method in Java which stores put(Object key, Object value). I have written a piece of code which works but I am not able to understand it. Its not outputing what I want but something else.
    I guess, I have some ignorance.
    When I compile using
    $javac testing.java propsput.java
    $java testing
    I get the following output.
    Bytes Array:[B@1372a1a
    I understand that B stands for Bytes array. Also, If I change the String I get the same thing. If I modify the code for Integer array
    and store some Integer array I get [I@1372a1a.
    I fail to understand why I am getting this 1372a1a again and again.
    Instead where is my array.
    May be I am not using the method getValue correctly.
    Thank You very much for your help
    Regards
    //testing.java
    import java.io.*;
    import java.util.*;
    public class testing{
    public static void main(String args[]){
    propsput headers=new propsput();
    String s="Let me See how you do it";
    byte buf[]=s.getBytes();
    headers.put("Bytes Array",buf);
    //propsput.java
    import java.util.*;
    import java.io.*;
    public class propsput{
    public void put (String key, byte[] value) throws IllegalArgumentException{
    HashMap _props =new HashMap();
    _props.put(key, value);
    Set set =_props.entrySet();
    Iterator i=set.iterator();
    while(i.hasNext())
    Map.Entry me=(Map.Entry) i.next();
    System.out.print(me.getKey()+":");
    System.out.println(me.getValue());
    ----------------------------------------------------------------

    Hi Thanks for your help.
    But I have included your method in the propsput class and also using it like this in the propsput class.
    while(i.hasNext())
    Map.Entry me=(Map.Entry) i.next();
    System.out.print(me.getKey()+":");
    byte a[]=me.getValue();
    showBytes(a);
    But while compiling with javac I get the following error:
    propsput.java:24: incompatible types
    found : java.lang.Object
    required: byte[]
    byte a[]=me.getValue();
    Please let me know how should I use it so as to print my String.
    Well, its still not clear in the previous code (my First Message) that why I am gettinng "1372a1a" everytime. (Even if I change the String. When I change the array to be an Integer array I get [I@1372a1a )
    Othewise in the case of Strings I get ( [B@1372a1a)
    Bytes Array:[B@1372a1a
    Thanks and Regards                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Graphic window condition

    Hi all,
    following is my requirement....
    1. Display text of designation code selected on the screen from table ZCMT011_DESGN
    2. Fore selected signature code on the screen get details of scanned file from table ZCMT011_SIGN and print scanned image.
    For this what should i do ... wherther i should have multiple graphic windows for each image ... or there is any other way of getting image on screen depending on input condition from the table.
    i hae uploaded the image in SE78 ... also then i have saved this file name in the ztable ......in filename field..
    Please help me its urgent

    Hi,
    whatever the images are there .you have to create the graphic windows and in conditon tab put conditions for all graphs.
    Whenever conditon satisfies particular  graph will display.
      Don't forget to reward if useful...

  • Links open in new windows instead of tabs.

    When browsing the internet, if I'm using a browsing session from a previous day, when I select to open a new link as a new tab, it will open in a new window instead.
    In my case, I put my work computer to sleep yesterday evening and started using it again this morning. Now all my links try to open in a new window even if I specifically choose to "Open Link in New Tab".
    This is extremely annoying.

    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    * Don't make any changes on the Safe mode start window.
    * https://support.mozilla.com/kb/Safe+Mode
    * [[Troubleshooting extensions and themes]]
    If it does work in Safe-mode then disable all extensions and then try to find which is causing it by enabling one at a time until the problem reappears.
    * Use "Disable all add-ons" on the [[Safe mode]] start window to disable all extensions.
    * Close and restart Firefox after each change via "File > Exit" (Mac: "Firefox > Quit"; Linux: "File > Quit")
    In Firefox 4 you can use one of these to start in <u>[[Safe mode]]</u>:
    * Help > Restart with Add-ons Disabled
    * Hold down the Shift key while double clicking the Firefox desktop shortcut (Windows)

  • Links gose to new window instead of adding as tabs even I chose not to in preferences

    Whenever I click any links, it opens new windows instead of new tabs on existing window as used to be even I deselected the "open new window in a new tab instead" at the preferences. It's started from new Firefox 4.0.

    ''Chinamoon [[#question-1046902|said]]''
    <blockquote>
    Because of my work I have to be free to set side by side images and for that I need only windows no tabs - some work resolutions does not work in tabs - I am going crazy trying to do that since all the options I have tried so far are null.
    </blockquote>
    I had that add on and it didn't solve the problem. I cannot put two
    tabs side by side to compare slides. I hate to go back to IE but so far outside no longer supported Safari is the only answer. Thank you anyway.
    China

  • Invoke a method when Close Window is clicked

    Hi,
    How do i invoke a method when "close window" on the global button bar is clicked.
    Can someone please help.
    Thanks in advance.
    Pavan
    Edited by: user12215240 on Feb 23, 2010 9:32 AM

    Is it possible to change the settings so that when the red 'close' button is clicked, the application will hide instead of closing?
    Applications don't "close," windows do. If you are just closing windows but not quitting applications that opened them, it is no wonder that there are hundreds of apps in the Dock.
    A few apps like System Preferences have only one window, so they automatically quit when you close that one window. Most apps do not do this: even after all their windows are closed, they remain running & thus show up in the Dock, in Activity Monitor, & so on. They each require a little (or sometimes more than a little) real memory reserved for their use to remain running -- this subtracts from what is available to do useful tasks, & will slow down your Mac when it results in too much virtual memory use.
    Thus, it is a good idea to quit applications you don't have an immediate need for, especially if they don't require long startup times. If you want easy access to select applications, create a folder & fill it with aliases to those apps, then drag that folder to the right side of the Dock, where it will create a stack. When opened, the stack will allow one click launching of those apps.

  • "DB- put: method not permitted before handle's open method"

    Hi,
    A deadlock caused during a read/update/write circle. After aborting and
    recreating the transaction, I get the error message:
    DB->put: method not permitted before handle's open method
    To produce the error, set a breakpoint to "Set the breakpoint here", start the
    programm, wait until the debuger is there, start the same program a second time,
    now the deadlock occurs.
    Break the deadlock of the first process: "db_deadlock -ao"
    The first process (broken by "db_deadlock" runs into the transaction recovery
    section and creates the error-message.
    System: MinGW
    The below code is simplified:
    #include <malloc.h>
    #include <string.h>
    #include <sys/stat.h>
    #include <db.h>
    #define FLAG_ENV_OPEN DB_CREATE | DB_INIT_MPOOL | DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_TXN | DB_REGISTER | DB_RECOVER
    int main( int argc, char *argv[] )
    const char *environment_directory = "C:\\Temp";
    const char *database_file = "C:\\Temp\\test.db";
    const char *key_data = "key";
    const char *data_data = "there is something";
    DBT key, data;
    // If database does not exists, create a database with one element
    struct stat buffer;
    int status = stat( database_file, &buffer );
    if( status != 0 )
    DB *database_handle = NULL;
    int status = db_create( &database_handle, NULL, 0 );
    status = database_handle->set_flags( database_handle, DB_RECNUM );
    status = database_handle->open( database_handle, NULL, database_file, NULL, DB_BTREE, DB_CREATE, 0644 );
    memset( &key, 0, sizeof(DBT) );
    key.data = (void*)key_data;
    key.size = strlen(key_data);
    key.flags = DB_DBT_USERMEM;
    memset( &data, 0, sizeof(DBT) );
    data.data = (void*)data_data;
    data.size = strlen(data_data);
    data.flags = DB_DBT_USERMEM;
    status = database_handle->put( database_handle, NULL, &key, &data, 0 );
    database_handle->close( database_handle, 0 );
    // Create environment
    DB_ENV *environment = NULL;
    status = db_env_create( &environment, 0 );
    status = environment->set_cachesize( environment, 0, 4 * 1024 * 1024, 0 );
    status = environment->open( environment, environment_directory, FLAG_ENV_OPEN, 0644 );
    // Create transaction
    DB_TXN *transaction = NULL;
    status = environment->txn_begin( environment, NULL, &transaction, 0 );
    // Open the created database
    DB *database_handle = NULL;
    status = db_create( &database_handle, environment, 0 );
    status = database_handle->set_flags( database_handle, DB_RECNUM );
    status = database_handle->open( database_handle, transaction, database_file, NULL, DB_BTREE, DB_CREATE, 0644 );
    // Create a read lock
    memset( &key, 0, sizeof(DBT) );
    key.data = (void*)key_data;
    key.size = strlen(key_data);
    key.flags = DB_DBT_USERMEM;
    memset( &data, 0, sizeof(DBT) );
    data.data = NULL;
    data.flags = 0;
    status = database_handle->get( database_handle, transaction, &key, &data, 0 );
    // Create a write lock
    memset( &key, 0, sizeof(DBT) );
    key.data = (void*)key_data;
    key.size = strlen(key_data);
    key.flags = DB_DBT_USERMEM;
    memset( &data, 0, sizeof(DBT) );
    data.data = (void*)data_data;
    data.size = strlen(data_data);
    data.flags = DB_DBT_USERMEM;
    // Set the breakpoint here:
    status = database_handle->put( database_handle, transaction, &key, &data, 0 );
    // Should be deadlock
    if( status == DB_LOCK_DEADLOCK )
    status = transaction->abort( transaction );
    status = environment->txn_begin( environment, NULL, &transaction, 0 );
    // Here is the problem
    status = database_handle->put( database_handle, transaction, &key, &data, 0 );
    // Close database
    database_handle->close( database_handle, 0 );
    // Close environment
    environment->close( environment, 0 );
    return 0;
    }

    Hi,
    The issue in your test case is the use of a transaction handle in the DB->open call, followed by an abort of that transaction. This aborts the DB->open operation, which is not what you intend.
    It is almost always simplest to pass NULL for the transaction handle to the DB->open call and add the DB_AUTO_COMMIT flag instead. Then if the open call succeeds, you have a database handle that is valid regardless of subsequent transaction aborts.
    Regards,
    Michael Cahill, Oracle.

  • When I right-click a link, and choose "Open in new tab", it opens in a new window instead. How can I fix this?

    So I have Firefox open, and I've tried to open tabs by right clicking and choosing "open in new tabs", but it opens in a new window instead. And yes, there are no problems with being able to open new tabs by pressing the ctrl t.

    The Ask Toolbar is causing that in the Firefox 3.6.13+ versions. Uninstall that extension.
    There are a couple of places to check for the Ask toolbar:
    * Check the Windows Control panel for the Ask Toolbar - http://about.ask.com/apn/toolbar/docs/default/faq/en/ff/index.html#na4
    * Also check your list of extensions, you may be able to uninstall it from there - https://support.mozilla.com/kb/Uninstalling+add-ons

  • How to insert a condition in the Graphic Window of a SAP Script ?

    Hi,
    I need to give a condition inside the Graphic Window for printing the Logo in the  SAP Script. Now, my problem is that the Graphic window is only opening in Display mode. How to make it editable and insert a condition in it?
    OR
    Is there any other way to do it?
    Please Help.
    Thanks in Advance.
    -VRU

    Hi
    I got your point. I'll provide  you solution
    In the logo window goto coding part by pressing F9 and give your coding as
    IF &BKPF-BUKRS& = 'COM1'
    INCLUDE GSPL OBJECT GRAPHICS ID BCOL LANGUAGE DE
    BITMAP 'LOGO1' OBJECT GRAPHICS ID BMAP TYPE BCOL
    ELSEIF &BKPF-BUKRS& = 'COM2'
    BITMAP 'LOGO2' OBJECT GRAPHICS ID BMAP TYPE BCOL
    ELSEIF &BKPF-BUKRS& = 'COM3'
    BITMAP 'LOGO3' OBJECT GRAPHICS ID BMAP TYPE BCOL
    ELSEIF &BKPF-BUKRS& = 'COM3'
    BITMAP 'LOGO4' OBJECT GRAPHICS ID BMAP TYPE BCOL
    ELSEIF &BKPF-BUKRS& = 'COM4'
    BITMAP 'LOGO5' OBJECT GRAPHICS ID BMAP TYPE BCOL
    ENDIF
    <b>Note:</b>But you have to upload all your logos in se78 then only you can upload and give conditions for this
    Regards
    Pavan

  • Universal Worklist items open in new window instead of existing frame

    After our recent upgrade we noticed that workitems in Universal Worklist open in new window instead of existing frame.  Do you know if there is a system or universal setting to make all the workitems open in existing frame?  I know we can change the settings for parameters launchInNewWindow and openInNewWindow to "no" in XML files to fix this.   However, my concern is that I would need to do this for each and every task we use.  (still doable but wondering if there is simpler solution)
    Example: 
        <ItemType name="uwl.task.webflow.TS12300097.SAP_R3_CUSTOM_DEV" connector="WebFlowConnector" defaultView="DefaultView" defaultAction="launchWebDynPro" executionMode="default">
          <ItemTypeCriteria systemId="SAP_R3_CUSTOM_DEV" externalType="TS12300097" connector="WebFlowConnector"/>
          <Actions>
            <Action name="launchWebDynPro" groupAction="" handler="SAPWebDynproLauncher" returnToDetailViewAllowed="yes" launchInNewWindow="yes" launchNewWindowFeatures="resizable=yes,scrollbars=yes,status=yes,toolbar=no,menubar=no,location=no,directories=no">
              <Properties>
                <Property name="WebDynproApplication" value="LeaveRequestApprover"/>
                <Property name="WebDynproDeployableObject" value="sap.com/ess~lea"/>
                <Property name="newWindowFeatures" value="resizable=yes,scrollbars=yes,status=yes,toolbar=no,menubar=no,location=no,directories=no"/>
                <Property name="openInNewWindow" value="yes"/>
                <Property name="display_order_priority" value="5"/>
              </Properties>
              <Descriptions default=""/>
            </Action>
          </Actions>
        </ItemType>

    We downloaded uwl.standard.xml from UWL admin.  Made a copy and renamed file.  Changed all "launchInNewWindow" from "yes" to "no".  Uploaded new file in UWL admin.  Re-registered systems, cleared cache.  Not sure what exact line changed the behavior but the workitems no longer open in new window.
    We are still experimenting with file in our sandbox environment.

  • Preview - displays a blank window instead of the jpg???

    Installed SL yesterday, and now Preview displays a blank window instead of the jpg??? The jpg opens in iPhoto.
    Anyone one else? Any suggestions?
    Thanks.
    Ron...

    Hi Ron,
    Try deleting this file.
    com.apple.Preview.plist
    /Users/YourName/Library/Preferences.
    Drag that file from the Preferences folder to the Trash, emtpy the Trash and restart your Mac.
    If that doesn't help, right or control click that image, then click Get Info.
    In the Get Info window click Open with. You may have to click the discovery triangle.
    Click the pop menu and select the application you want to open that image with... you may have to navigate to your Applications folder to make a selection.
    Carolyn

  • Opening a URL/File in new window instead of new tab

    I think I know the answer to this, but I'd like to check anyway.  When setting an action to Open URL or File for a button/click box/hyperlink/etc, is there a setting in Captivate to open the URL/File in a new WINDOW instead of a new TAB? I know to use the "New" setting along with the Open URL or File action. I assume opening in a new window instead of a new tab by default is going to depend on the settings of whatever browser you use, but like I said, just wanted to check. Thanks!

    If you open it in javascript and specify a height/width or location it should open in a new window.
    window.open("http://www.adobe.com", "_blank", "toolbar=yes, scrollbars=yes, resizable=yes, top=500, left=500, width=400, height=400");

  • When I open a new window, it opens behind the exist ing window instead of in front of it. How can I fix this?

    When I click on a link and I choose the option to open link in a new window, it opens behind the currently open window instead of in front of it. This is a real nuisance. Why is this happening, and how do I fix it?

    Hi alanbala,
    There are several possible reasons why the new window opens in the background and not in the foreground by default.
    # another installed program is causing this
    # the Firefox main window is set to Always on Top
    # probably a Windows 7 bug
    # possibly a Firefox bug [https://bugzilla.mozilla.org/show_bug.cgi?id=790013 https://bugzilla.mozilla.org/show_bug.cgi?id=790013]
    What you can do is
    # update your Windows 7 to the latest security patches
    # open Mozilla Firefox in Safe Mode (see KB article [[Troubleshoot Firefox issues using Safe Mode]])
    # evaluate the other programs installed on your computer
    # open new links on a new tab
    Let us know your progress. I will be following this support thread.

Maybe you are looking for

  • Is there a way to create a flipping book with the flipping 5k adobe software?

    Am I the only one pissed with the f adobe products? Is there a way to create a flipping book with the flipping 5k adobe software? Is it Flash, etc? Thanks

  • How to change dynamically style in smartforms

    Dear All,           I had a requirnment to select different styles in smartforms depending on some condition, can u plz suggest me any solution for this.Thanking you. With best regards Gaurav Lashkari

  • Launch application upon wake from sleep

    Is there an automator that will launch an application when the computer wakes from sleep? I do video chats w/ my elderly mother via iChat. I can wake her computer from my home using WakeOnLan. However, she sometimes quits iChat so it is not always ru

  • Ipod Touch doesn't reproduce track in sequence

    Recently my Ipod Touch 32gb started to close the music application after reproducing a track. Firstly he play the song, but at the end it doesn't play the following one and return to home. Please reply my question.. thanks. Message was edited by: fed

  • IPPP for BIBS or INTERNET ICS service book: wich is necessary?

    Hi I've got a connection problem with a third-party app. The developer tells me that the app need the IPPP for BIBS service books for work on bis. I don't have any connection problem with all other apps like facebook, twitter, ecc, but the dev make m