[Help] Learn How To Create InputDialog

I still learn how to create a component.
I want to create a simple input dialog which modeled after JOptionPane.showInputDialog, but i can't get the value, it's always show null. Anybody know where i doing wrong?
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class kotakPesan extends JFrame implements ActionListener {
     String jdlPesan;
     String isiPesan;
     JPanel p = new JPanel();
     JButton bOk = new JButton("Ok");
     JTextField tIsi = new JTextField();
     JLabel lIsi = new JLabel();
     String A;
     public String inputPesan (String Judul, String Isi) {
          this.jdlPesan = Judul;
          this.isiPesan = Isi;
          tampilInputPesan();
          return A;          
     public void tampilInputPesan () {
          setTitle(jdlPesan);
          lIsi.setText(isiPesan);
          p.setLayout(new GridLayout(3, 1));
          p.add(lIsi);
          p.add(tIsi);
          p.add(bOk);
          getContentPane().add(p);
          setDefaultCloseOperation(EXIT_ON_CLOSE);
          pack();
          setVisible(true);
          bOk.addActionListener(this);
     public void actionPerformed (ActionEvent aE) {
          A = tIsi.getText();
}Main Method:
public class Sim {
     public static void main (String[] args) {
          kotakPesan p = new kotakPesan();
          String A = p.inputPesan("Masuk", "Angka");
          System.out.println(A);
}

I'm also learning java and I'm not quite sure what are you trying to do. Are you trying to read your pre-defined input in the text field?
I've created a simple window with a text field, a button and the program will produce a sample output. I hope it will help you a bit.
import javax.swing.*;
import java.awt.event.*;
public class TestWindow extends JFrame
     //Window attributes - references
     private JPanel panel;
     private JLabel inputLabel, outputLabel, resultLabel;
     private JTextField inputField;
     private JButton clickButton;
     //Window size - in pixels
     private final int WINDOW_WIDTH = 300;
     private final int WINDOW_HEIGHT = 450;
     //Constructor
     public TestWindow ()
          setTitle ("This is a simple window.");
          setSize (WINDOW_WIDTH, WINDOW_HEIGHT);
          setDefaultCloseOperation ( JFrame.EXIT_ON_CLOSE );
          createPanel ();
          add (panel);
          setVisible (true);
     private void createPanel ()
          inputLabel = new JLabel ("Enter an integer of your choice: ");
          outputLabel = new JLabel ("Your number is: ");
          resultLabel = new JLabel ("---------------");
          inputField = new JTextField (5);
          clickButton = new JButton (" dum dum dum ");
          clickButton.addActionListener (new TempListener ());
          panel = new JPanel();
          panel.add (inputLabel);
          panel.add (inputField);
          panel.add (outputLabel);
          panel.add (resultLabel);
          panel.add (clickButton);
     //Action listener for the button.
     private class TempListener implements ActionListener
          public void actionPerformed (ActionEvent event)
               int textToInt;
               String inputFieldTempOut = "";
               String text = inputField.getText ();
               textToInt = Integer.parseInt (text);
               if (textToInt % 2 == 0)
                    if (textToInt == 0)
                         inputFieldTempOut = "Neither even nor odd.";
                    else
                         inputFieldTempOut = "An even number.";
               else
                    inputFieldTempOut = "An odd number.";
               resultLabel.setText (inputFieldTempOut);
public class TestWindowDemo
   public static void main(String[] args)
      TestWindow tw = new TestWindow();
}

Similar Messages

  • Requesting all to help me how to create lsmw using idoc method

    hi
    thanx for ur answer
    requesting every body in the forum to help me how to create lsmw using idoc method.
    regards,
    balaji

    Hi Balaji,
    LSMW using IDOC is similar to using flat file method. Here you are getting data from IDOC container and mapping data with Idoc segments insted of flatfile column.
    Hope this is what you are looking for. If helpful then don’t forget to reward me for that
    Darshan

  • I want to learn how to create an app.  Where do I begin?

    I want to learn how to create an app.  Where do I begin?

    Have a look at these pages:
    https://developer.apple.com/ipad/sdk/
    https://developer.apple.com/library/ios/#DOCUMENTATION/iPhone/Conceptual/iPhone1 01/Articles/00_Introduction.html

  • Javascript error on - Help - Learn how to use Numbers with this online...

    I am trying to find out more about Numbers. I am using iTunes 9.1.1 on a Vista PC. I get a Javascript error in Internet Explorer 8 when I try to access:
    Help - Learn how to use Numbers with this online resource.
    http://help.apple.com/numbers/1.0
    The link redirects to the following page:
    http://help.apple.com/iwork/safari/interface/#tan727163ed
    The above page is blank except for boxes for Keynote Help, Pages Help, Numbers help, and a blank input field that seems to do nothing. Here is the Javascript error message from Internet Explorer 8:
    Webpage error details
    User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.30729; .NET CLR 3.0.30729)
    Timestamp: Tue, 1 Jun 2010 20:55:54 UTC
    Message: This command is not supported.
    Line: 1
    Char: 41589
    Code: 0
    URI: http://help.apple.com/iwork/safari/interface/javascript.js

    Link also does not work for me in WIN 7 with IE8. However, it does work in Chrome in WIN 7. It also works in Safari on my G4. Suggest you try Chrome or it may work in another browser like FireFox or Safari in Vista.

  • Need to learn how to create a slideshow in Flash

    Hello All,
    I'm new to Flash and I need to learn how to do a slideshow with exactly the same features as can be found in this link:
    http://www.esppromo.com/index.asp
    Just like at the link above, it needs to play through the slides automatically once the page is loaded, each slide needs to link to a specific URL, and I need controls similar to the boxes at the bottom so the viewer can click on any specific slide they wish to view (I'd like to have numbers in the boxes though). The transitions don't have to slide across like this. If a fade is easier, that would be fine.
    Since I've looked online, but can't find any tutorials for doing this in Flash Professional, I think I'll pick up a book on Flash. There are some online tutorials that are close but nothing that is exactly what I'm looking for.
    I'm just wondering if anyone can recommend a particular book that covers creating this type of slide show with the links and controls exactly as I need it to be. I see these types of slide shows on a lot of sites now, so I'm hoping that maybe someone else on this forum has had to learn how to do this and can recommend a book they used?
    I was looking at Adobe Flash Professional CS5 Classroom in a Book and it looked like it may be what I'm after, but I am rather cautious, as I don't want to end up with instructions that are close to what I am looking for, but not quite right.
    Actually, I thought I'd be able to do this fairly easily with Flash Catalyst, so I updated to Adobe CS5 Design Premium. I found that Flash Catalyst can be used to create a slide show like this, but unfortunately it won't play automatically when the page loads and the viewer has to manually click through the slides, which is not what I need. I could be wrong, but from what I've read, I need Flash Builder to add code so the slide show will play automatically if I create it in Flash Catalyst. Since it's not an option for me to buy more software at this time, I've decided to learn how to do this in Flash Professional.
    I really want to learn how to do this. I expect to go on and create more using Flash, but for now I just REALLY need to figure this slide show out.
    If anyone can help out, I'd really appreciate it!
    Thanks,
    William

    Edit:
    i'm sorry. it is a huge work to type this and will be confusing as hell. i'm already up to 1 full word page of explanation. Though i am able to do it, explaning it in full lengh is ... well.. very hard. Way harder than it is to make your flash itself.
    I can however point you to some element you should read about how to make them:
    - How to use timeline in flash cs4
    - how to create a button in flash cs4
    - How to make "CLASSIC TWEEN" in flash cs4
    - How to use ActionScript 2 ( AS2) basic command like : GetUrl, Gotoandplay, Stop and how to put those script in the right location. ( AS2 allow you to put script directly on the button itself. however it is best to put it in the Action Layer that you will have to build in the timeline.
    - How to import thing in library.
    keep in mind that what you want to make is mostly a Logic probleme...
    - Image 1 click = GetURL X,
    - After Y time, Switch image 1 to image 2 with animation. Do the same for the button.
    - If you click on button 1 while being on image 3, you have to set all the reverse animation in the timeline, and use a lot of Gotoandplay.
    Hope this help you a little.
    I'm sorry. i really wanted to help you do it, but it is just a monstruous job to write all this.

  • Please help. How to create reports including charts in pdf format .

    Please help.
    I have two problems.
    Any help will be highly appreciated.
    1. I need to query database through JDBC (which is easy) using servlet or JSP and then create a report in pdf format (which I do not know how to). If anyone knows how to create a report in pdf format, I would highly appreciate.
    2. I need to generate charts and embed them in these reports. I do not know how to make charts. If anyone knows and helps me out, I would highly appreciate. I have to make charts and embed them in the pdf reports.
    Thanks a lot in advance.
    Indrasish.

    Ok ibasuroy, but i don�t speak ingles.
    first problem:
    http://sourceforge.net/projects/jfreereport/
    JFreeReport is a Java class library for generating reports. It provides a flexible printing functionality for Java applications and supports output to Printers and PDF, Excel, HTML and XHTML, PlainText, XML and CSV files.
    second problem:
    http://sourceforge.net/projects/jfreechart/
    JFreeChart is a class library, written in Java, for generating charts. Utilising the Java2D APIs, it currently supports bar charts, pie charts, line charts, XY-plots and time series plots.
    write my. I have a class JDBCAdpater and a BridgeJFreeReport
    [email protected]

  • Help! how to create a repository correctly of owb?

    I have installed oracle11 in the directory c:\app\***\product\11.1.0\db_1 and installed owb in the directory c:\app\***\product\11.1.0\owb11gr1. When i tried to Create a Repository Using the Repository Assistant, the system gives out an error message:OWBSYS is not granted access to owb home/owb/bin/admin/rtrepos.properties:Please run UnifiedRepos/reset_owbcc_home.sql specifiying the path of the Oracle Home from which the Control Center Service is being run.
    Then I run the script reset_owbcc_home.sql and put in "C:/app/***/product/11.1.0/owb11gr1" according to the prompt.
    But it still can not work, it gives out another error,"there is no table or views"
    Can anyone tell me how to create a repository correctly?
    Thanks!

    With your database 11g install OWB is already installed under the ORACLE_HOME's owb directory. You should/could have just used it.
    I'd suggest a cleanout and start again, here are the steps:
    1. Close any open OWB
    2. from db home,
    Stop runtime service - cd owb/rtp/sql sqlplus OWBSYS/OWBSYS @stop_service
    3. drop your target user, design user
    4. cleanout OWBSYS, recreate:
    cd owb/UnifiedRepos
    sqlplus using your sysdba
    @clean_owbsys
    @cat_owb <tablespace_of_your_choice)
    Now run reposinst.bat from your database Oracle home
    Cheers
    David

  • Does anyone want to learn how to create 3D cartoon images/Plus advanced Editing Techniques???PM Me.

    i can show anyone how to create jaw dropping 3D cartoon images,Zombie Character/Etc.Plus a ton of other editing tips and trick.Just PM me.

    i can show anyone how to create jaw dropping 3D cartoon images,Zombie Character/Etc.Plus a ton of other editing tips and trick.Just PM me.

  • Please can anybody help me  how to create the job by using HR_JOB_API?

    hi,
    actually i tried by using this,but iam not able to do that.
    1.should we create job definition before job creation?
    2. should we create flexfield segment values before job definition?
    3. what are the parameters we have to give mandatatory?
    up to my knowledge when we crate job from front end then automatically job definition and job will be created.
    but here how to do that please let me know.
    and if u have any sample code please send me as soon as.
    if jobdefinition and flexfield vlues must be defined before job creation then let me know how to create jobdefinition and flexfield values.

    ever thought about attending a training? When you think this is not needed, please read the flex guide, then the hr guide, and then scan some metalink notes on hrms api's.
    good luck,
    thierry

  • Where to learn how to create a "virtual book"

    I'm a writer looking to design a webpage so that the content
    looks like it is inside a regular book that you would "flip"
    through...is there a specific tutorial i should use for this?
    Anyone have any tips?

    Hi,
    If you need more shapes than a particular Microsoft Office Visio template provides, you have a couple of options. You can either search Visio and the Web for shapes that Microsoft has developed, or you can search the Web for shapes that were developed by
    others,
    https://support.office.com/en-us/article/Find-more-shapes-and-stencils-123f0550-ab4b-4803-ae74-4e9c73fff4ca
    And create custom shapes in Visio.
    http://office.microsoft.com/en-001/visio-help/create-a-shape-HP001231200.aspx
    http://office.microsoft.com/en-001/visio-help/create-save-and-share-custom-stencils-HA102749233.aspx
    http://blogs.office.com/2013/09/24/learn-to-create-3-d-shapes-in-visio/
    Best regards,
    Greta Ge
    TechNet Community Support
    It's recommended to download and install
    Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office
    programs.

  • HELP!How to create HD disc that will play back in HD DVD or Blu-Ray player?

    Footage comes from Panasonic HVX200 as DVCPRO HD 1080i60, all appropriate settings made in FCP5 to edit. Have already made SD DVD, whoopie.
    Now client is interested in real HD version that they can play back on HD DVD or Blu-Ray set top unit. Of all my research, I've discovered little about how to make a "real" HD video disc. OSX doesn't support Blu-Ray burning, OK. What about HD DVD burning support? And what drive to purchase for this application?
    I understand DVD Studio will allow me to author a disc with HD content...that I can burn onto DVD5. Useless to the client. Need to burn on either Blu-Ray or HD DVD media.
    Aside from encoding in Compressor, what do I do when I need to make this HD disc happen? Compressor step seems easy enough to figure out. Just very unclear on how to burn out appropriate video disc.
    Thanks for your help.

    For Blu-Ray creation:
    I'm curious if DVDit! works in parallels too, though it will certainly work in BootCamp. The question is what format should FCP/Compressor output to in order for DVDIt, etc. on BC or Parallels need in order to create the disc?
    MPEG-2 and H.264 should work, but who knows?
    In the meantime, I have HDV source footage that I edit. I print the final edit back to HDV for archiving, and burn a HD-DVD on a DL DVD+R red laser disc to show on my Toshiba HD-DVD player using DVDSP. It works, and I can get about 40 minutes of MPEG-2/HDV on there without transcoding at 1080i and it looks fantastic.
    In the future, I hope to be able to dump the HDV final edit onto a Blu-Ray disc. I'm guessing Adobe Encore will be needed on the Mac for that.
    The point here is there certainly are options that work. I do wish Apple added Blu-Ray burning capability.
    There's still room for that, however... FCS 1 (and even now 2, with AVCHD support, albeit non-native) have histories of adding new support for codecs, etc. in free updates.

  • Help! - How to create nested comps with AEGP suites

    I want to be able to create a nested composition....I know that when you create, let's say, comp 1 and then a separate comp 2 and then drag comp2 into comp1, comp2 becomes one layer in comp1. Comp2 would be called a "precomposition"
    So I want to be able to do this in my program, using AEGP calls...I tried just adding a composition as a layer to another (parent) composition, like footage is added as a layer to the current comp.
    There was another post that talked about using the Collection suite, but I'm not sure how to actually use it to implement a nested comp.
    I tried getting a collection from the comp I want to be nested, setting the current (parent) comp's selection to be the nested comp's collection, and tried the DoCommand(2071) to precompose the collection, but obviously this didn't work because it doesn't really make sense to do that, haha.
    Intuitively I wanted to call AddLayer from the current comp, passing in a child comp to be added as a layer. Adobe told me item cannot be added as source to layer so the way to do this must be more subtle than I thought.
    If I have to use collections, do I make a collection out of the current comp and add subsequent comps to the collection? That doesn't make sense either. How is a nested comp added as a layer to another comp?
    Can anyone help me? Email me if you have any suggestions: [email protected]
    Thanks!!

    Hi Sara,
    I responded to your email, but just to follow up on the forum:
    Say you've created two comps using AEGP_CreateComp.  That gives you two AEGP_CompHs.  To nest one comp in another, you'll first need to get the AEGP_ItemH for the nested comp, so use AEGP_GetItemFromComp.  You can now add the AEGP_ItemH of the nested comp as a layer using AEGP_AddLayer.  That should do the trick.  And AEGP_ReorderLayer if needed.
    Cheers,
    Zac

  • Help! How to Create Wall Barrier for Maze Game

    Hi - I'm working on a simple maze program that has ball which is controlled by the up, down. left, right arrow keys.  I made a maze image in Photoshop and brought it into the Flash CS6 and CC (AS3). I made one wall barrier called wallDet1_mc to test before creating other wall barriers. It doesn't work. The ball goes through the wall everytime I test it.  Any help on this would be greatly appreciated.  If anyone has a basic maze with arrow keys control where their object do not cross over the wall please let me know how to do this. Thanks.

    Still doesn't work, and I was working on it and I cannot get the object (carP_mc) to not go through the wall. There has to be a code or math equation to stop it from doing this.  If the wall detection picks up the car at the wall then it should keep it away by the same amount of pixels.  What do you think?  Below is a revamped program and thanks again for your help:
    import flash.events.KeyboardEvent;
    stop();
    /* Move with Keyboard Arrows
    Allows the specified symbol instance to be moved with the keyboard arrows.
    Instructions:
    1. To increase or decrease the amount of movement, replace the number 5 below with the number of pixels you want the symbol instance to move with each key press.
    Note the number 5 appears four times in the code below.
    wallDet1_mc.enabled= false;
    var upPressed:Boolean = false;
    var downPressed:Boolean = false;
    var leftPressed:Boolean = false;
    var rightPressed:Boolean = false;
    carP_mc.addEventListener(Event.ENTER_FRAME, fl_MoveInDirectionOfKey_3);
    stage.addEventListener(KeyboardEvent.KEY_DOWN, fl_SetKeyPressed_3);
    stage.addEventListener(KeyboardEvent.KEY_UP, fl_UnsetKeyPressed_3);
    stage.addEventListener(Event.ENTER_FRAME, everyFrame);
    function fl_MoveInDirectionOfKey_3(event:Event)
        if (upPressed)
            carP_mc.y -= 5;
        if (downPressed)
            carP_mc.y += 5;
        if (leftPressed)
            carP_mc.x -= 5;
        if (rightPressed)
            carP_mc.x += 5;
    function fl_SetKeyPressed_3(event:KeyboardEvent):void
        switch (event.keyCode)
            case Keyboard.UP:
                upPressed = true;
                break;
            case Keyboard.DOWN:
                downPressed = true;
                break;
            case Keyboard.LEFT:
                leftPressed = true;
                break;
            case Keyboard.RIGHT:
                rightPressed = true;
                break;
    function fl_UnsetKeyPressed_3(event:KeyboardEvent):void
        switch (event.keyCode)
            case Keyboard.UP:
                upPressed = false;
                break;
            case Keyboard.DOWN:
                downPressed = false;
                break;
            case Keyboard.LEFT:
                leftPressed = false;
                break;
            case Keyboard.RIGHT:
                rightPressed = false;
                break;
    function everyFrame(event:Event):void {
    var mazehit:Boolean = false;
    if (upPressed) {
    //for(var i:int = 0; i < speed; i++) {
    if(carP_mc.hitTestObject(wallDet1_mc)) {
    carP_mc.y -= 5;
    mazehit = true;
    //break;
    if (downPressed) {
    //for(var i:int = 0; i < speed; i++) {
    if(carP_mc.hitTestObject(wallDet1_mc)) {
    carP_mc.y += 5;
    mazehit = true;
    //break;
    if (leftPressed) {
    //for(var i:int = 0; i < speed; i++) {
    if(carP_mc.hitTestObject(wallDet1_mc)) {
    carP_mc.x -= 5;
    mazehit = true;
    //break;
    if (rightPressed) {
    //for(var i:int = 0; i < speed; i++) {
    if(carP_mc.hitTestObject(wallDet1_mc)) {
    carP_mc.x += 5;
    mazehit = true;
    //break;
    //End of program. Not using the codes below
    /**onClipEvent(enterFrame){
        if(this.hitArea(carP_mc._x,carP_mc._y, true)){                   
            carP_mc._x=carP_mc._x;
            carP_mc._y=carP_mc._y;
    //Keyboard Listener on stage
    //stage.addEventListener(KeyboardEvent.KEY_DOWN, theKeysDown);
    //stage.addEventListener(KeyboardEvent.KEY_UP, theKeysUp);
    //Makes MazeArt follow the movement of the path_mc
    /*addEventListener(Event.ENTER_FRAME, onNewFrame01);
    function onNewFrame01(e:Event):void{
        maze_mc.x=wallDet1_mc.x;
        maze_mc.y=wallDet1_mc.y
    function Car_P(e:KeyboardEvent):void
        //maze_mc.addEventListener(KeyboardEvent, wallDet1_mc);
        //wallDet1_mc.addEventListener(KeyboardEvent.KEY_DOWN, maze_mc);

  • Can someone pls Help me: How to create a Fake target table(Dummy)  in DAC

    Hi There,
    Can someone pls Help me in creating a Fake target table(Dummy) in DAC?
    Thanks,
    Raghu

    Raghu
    You need to create a task so that you can hook sources and targets together.
    First, Design --> Tables tab --> New --> Below 'Edit' -->Table Type (Source) for your source tables.
    Design --> Tables tab --> New --> Below 'Edit' -->Check warehouse and Table Type (Fact or Fact Temporary) for your target tables.
    Points if helpful
    Kris

  • Need help learning how to update my system

    Hey guys!
    I need to update my system, so I went ot the wiki and learned that I have to type:
    pacman -Syu
    in the terminal, but I get a weird output that I am unsure how to answer:
    replace kernel26-firmware with core/linux-firmware? [Y/n]
    I am unsure what the difference is and am afraid of answering the wrong answer. I would really appreciate it if someone could tell me what the difference between the two are and which one I should pick. Thanks!

    I think we'll start before 'updating the system' with something else. Try googling the line you pasted, or searching the forums with that line. Ask back if you don't understand.

Maybe you are looking for

  • Address Book: Importing vcards with embedded photos

    Hi folks, This question would perhaps be more at home in the Apple Developer Connection Forums, but as I can't access those without a paid ADC account, I thought I'd try here on the off chance someone knows. In short, I'm writing an application that

  • Need help on how forms developer is used

    to everyone: im actually new at forms developer 2000,at really wondering how to use it though i have a background in SQL.If you have any data that you can share to me explaining the whole environment of Developer 200 please send it to me. Any help is

  • RME Baseline Templates compliance and deploy regular expression

    Hi: I have a large number of 3750 stacks consisting of a variable amount  , from 1 to 6, switches. I need to add to all FastEthernet interfaces from 2/0/1 to n/0/24 a command , under the interface. That is on the 1st and if only one switch do nothing

  • What happened to the automatic spelling in my messaging/tests?

    What happened to the automatic spelling in my messaging/texts?

  • CRM 5.0 Internet Sales B2C Logon is Invalid

    I have successfully configured CRM Internet Sales B2B and B2C. I am able to log into B2B but not B2C. The B2C app seems to work fine except when you try to log in. The error is "Logon is Invalid; check your entries". I haven't been able to find a goo