JOptionPane with Android

edited December 2014 in Android Mode

Hello, good afternoon,

import javax.swing.JOptionPane; 

  void setup(){ 
  size(480,120); 
  background(0); 
  noLoop(); 
}

  void draw(){ 
 String a = JOptionPane.showInputDialog(null, "Hi", "Data", JOptionPane.QUESTION_MESSAGE);  println(a);   
 } 

I want that code to work on android.

I have this mistake: JOptionPane can not be resolved

What I can do?

Where do I can find the .jar file to include?

Regards and thanks in advance.

Answers

  • Hello GoToLoop,

    Thanks for the information.

    I've tried it that way, I managed to compile the app, but fails at startup and does not work.

    I want to show a window where the user can enter text, to use that information. I can do with programming "lowest level" but the result is not so good. Do you have a piece of code that can help me?

    a greeting

  • Answer ✓

    Sorry, I don't even have an Android! (%)

  • In Android, you have access neither to AWT nor to Swing (JOptionPane belongs to the latter), but you can access the native Android graphic components.

  • @anthony20== if you want an input from the user (not only the 3 buttons yes no cancel) like some txt you can try with an editText importing apwidgets library which can do that. code is simple:

                        import apwidgets.*;
                        import android.view.inputmethod.EditorInfo;
                        import android.text.InputType;
                        import android.view.inputmethod.InputMethodManager;
                        import android.content.Context;
                        import android.widget.TextView.OnEditorActionListener;
                        import android.widget.TextView;
    
                        PWidgetContainer widgetContainer; 
                        PEditText textField;
                        String leTexte;
    
                        void setup(){
                        orientation(PORTRAIT);
                        editTextField();
                        };
    
                        void draw(){
    
                        leTexte = textField.getText();
                        };
    
        private void editTextField(){
                         widgetContainer = new PWidgetContainer(this); //create new container for widgets
                          textField = new PEditText(5, 100, 420, 70); //create a textfield from x- and y-pos., width and height
                          widgetContainer.addWidget(textField); //place textField in container
                          textField.setInputType(InputType.TYPE_CLASS_TEXT);
                          textField.setImeOptions(EditorInfo.IME_ACTION_DONE); //Enables a Done button
    
                          textField.setCloseImeOnDone(true); 
                    }
    
Sign In or Register to comment.