G4P's GTextField with P2D renderer?

edited July 2015 in Library Questions

Hello, First of all, I'm just a beginner in Processing anfd G4P so probably this is a silly question. My doubt is if I can use the control GTextField from G4P library using the P2D renderer. In my installation:

  • Ubuntu Linux
  • G4P 3.5.3
  • Processing 2.2.1

When I use it with P2D, I see the control on my windown but I can't type anything. However, if I change the renderer to the default one (JAVA2D), the control works fine. I don't know if I have to install any extra library in my Linux box to have fully P2D support. What is more strange to me is other components (gdroplist, gwindow, gbutton) do not present any problem.

The following sketch illustates that behaviour:

import g4p_controls.*;

void setup()  {

  //size(WIDTH, HEIGHT, P2D); // fail  
  size(WIDTH, HEIGHT, JAVA2D); // ok!  
  GWindow window = new GWindow(this, "XXX", 500,50,500,170, false, P2D or JAVA2D);   
  GTextField textField = new GTextField(window.papplet, 235, 22, 160, 20, G4P.SCROLLBARS_NONE);  

void draw() {

Might it be possible it was an issue with the drive of my graphic card?

Thanks in advanced.

PS: I can't use Java2D renderer because I need to use PShape object and as far as I know, Java2D is not yet supported


  • edited July 2015

    Processing doesn't support more than 1 Frame using OpenGL at the same time!
    We can have as many JAVA2D as we need, but only 1 of them can be isGL(). :-B


  • edited July 2015

    Hi GoToLoop,
    Thanks for your quick answer. What I do not know is why other controls works fine as Gdroplist but with GTextField does not let me type anything.

    Reading your answer I presume that I cannot create new Gwindow objects from a GPanel without having visual issues as I described above.

    • For displaying texts, JAVA2D renderer is much better than their OPENGL counterparts.
    • Since we can only have 1 window which isn't JAVA2D, you need to choose which 1 is gonna use an OPENGL-based renderer.
    • I presume PShape doesn't need to show up in all windows, do they?
  • The application which I want to develop has a main window with a toolbox (using GPanel object from G4P library). In this toolbox there is a button which opens a Gwindow object with a GTextField object. PShape only is shown in the main window (the one with the toolbox).

    Regarding having only a 1 window which isn't JAVA2D, if the main window and the one created are JAVA2D or P2D the application works (except the GTextField). If I mix renderers (for ex JAVA2D in main window and P2D in Gwindow) the application doesn't work. In case one non JAVA2D windows is allowed, then I think that I'm doing something wrongly or my approach to do a toolbox which opens windows does not fit with Processing philosophy

  • OK so let us be clear

    a) you want the main window to be P2D so you can use Shape
    b) the main window will have a GPanel control with a button on it
    c) when the user clicks on the button it creates a secondary window
    d) the secondary window uses Java2D and has a GTextfield object on it.

    From your experiments you say

    Main     Secondary    Gtextfield works
    JAVA2D     JAVA2D         Y
    JAVA2D     P2D            N
    P2D        JAVA2D         N
    P2D        P2D            Y        

    Please confirm these statements are correct or not.

    Unfortunately for you I won't have access to Processing for the next 12 days or so. It means that you will have to try the things I suggest and report the results here.

    TEST 1
    Load one of the examples that use GTextfield that come with G4P and run it. Does the textfield work? Now change the renderer to P2D, does the textfield work?

    TEST 2
    Using the code you posted above, make the main window P2D and the GWindow JAVA2D. After creating the textfield add the following line
    window.papplet.loop ();
    Does the textfield work?

    Let me know how you get on :)

    For displaying texts, JAVA2D renderer is much better than their OPENGL counterparts.

    Although that is certainly true G4P overcomes this by ,using internal JAVA2D buffers for drawing the controls to text G4P text rendering is not dependent on the sketch renderer. One of the many improvements that shipped with V3 of G4P :D

  • Hi Quark,
    Thanks for your answer. All your sentences a), b), c) and d) are right. These are my experiments:

    Main Secondary Gtextfield works
    P2D P2D N
    JAVA2D P2D Y
    P2D JAVA2D N

    NOTE: I gave wrong information on my previous post about the GtextField behaviour. My mistake. This table is the good one.

    It seems that if the main window is JAVA2D, then the GtextField works fine regardless what render uses the secondary window. ¿? I have tested with a GTextArea and the behaviour is the same as GtextField .

    I have loaded the sample G4P_EditTestControls and if I replace the renderer to P2D, the sample still works fine.

    I'm afraid but GTextField does not work.

    Thank you very much for your help

  • Thanks for reporting back.

    I don't know why P2D main / JAVA2D secondary doesn't work it makes no sense at all but unfortunately I can't test any thing for you at the moment.

    I would have expected

    Main     Secondary    Gtextfield works
    JAVA2D     JAVA2D         Y
    JAVA2D     P2D            Y
    P2D        JAVA2D         Y
    P2D        P2D            N

    We need to confirm it is not your setup. I suggest you post the basic code for P2D main / JAVA2D secondary with textfield (in this thread) and ask other forum members to test it out usung PS2.2.1 and report back here what they find.

    The second thing you can try is to install the GUI Builder tool, start a new sketch and use the tool to create the same sketch and see if that works. It can be installed form the Tools menu.

  • edited July 2015

    Hi Quark,
    Don't worry. Your help is much appreciated.

    The setup of the main window is really simple:

    public void setup() {
      size(WIDTH, HEIGHT, P2D); // or  JAVA2D  
      initializeCamera(WIDTH, HEIGHT, "usr", "pwd");  
      toolbox = new Toolbox(this);  

    The constructor of the toolbox, just creates a GPanel and add GButtons. One of these create a new window:

    // pApplet is the PApplet object from the main window  
    window = new GWindow(pApplet, "Title", 500, 50, 500, 170, false, PConstants.JAVA2D);    
    gTextfield = new GTextField(window.papplet, 235, 22, 160, 20, G4P.SCROLLBARS_NONE);

    I have been looking for if there is anything special to do when dealing with P2D window but I found nothing. Simply a tutorial for P3D (https://www.processing.org/tutorials/p3d/) and as far as it is concerned, they only need to specify the type in size command.

    Just for testing, I have replaced the GWindow window (secondary) by another written in Swing and it happens the same. JTextField / JTextArea do not accept typing (only if the main window is P2D) which let me to think than the problem is not in Gtextfield.

    I did a simple sketch with the GUI (I have already been using to design my windows) and happens the same. But default (JAVA2D) every works fine until the rederer of the main cwindow changes to P2D. Then the GTextField inside the GWindow stops working.

    Thank you!

  • edited July 2015

    I have execute:

    PGraphicsOpenGL pg = (PGraphicsOpenGL)g;

    And the output is:

    Intel Open Source Technology Center Mesa DRI Intel(R) Haswell Desktop 3.0 Mesa 10.3.0 1.30 GL_ARB_multisample GL_EXT_abgr GL_EXT_bgra GL_EXT_blend_color GL_EXT_blend_minmax GL_EXT_blend_subtract GL_EXT_copy_texture GL_EXT_polygon_offset GL_EXT_subtexture GL_EXT_texture_object GL_EXT_vertex_array GL_EXT_compiled_vertex_array GL_EXT_texture GL_EXT_texture3D GL_IBM_rasterpos_clip GL_ARB_point_parameters GL_EXT_draw_range_elements GL_EXT_packed_pixels GL_EXT_point_parameters GL_EXT_rescale_normal GL_EXT_separate_specular_color GL_EXT_texture_edge_clamp GL_SGIS_generate_mipmap GL_SGIS_texture_border_clamp GL_SGIS_texture_edge_clamp GL_SGIS_texture_lod GL_ARB_framebuffer_sRGB GL_ARB_multitexture GL_EXT_framebuffer_sRGB GL_IBM_multimode_draw_arrays GL_IBM_texture_mirrored_repeat GL_3DFX_texture_compression_FXT1 GL_ARB_texture_cube_map GL_ARB_texture_env_add GL_ARB_transpose_matrix GL_EXT_blend_func_separate GL_EXT_fog_coord GL_EXT_multi_draw_arrays GL_EXT_secondary_color GL_EXT_texture_env_add GL_EXT_texture_filter_anisotropic GL_EXT_texture_lod_bias GL_INGR_blend_func_separate GL_NV_blend_square GL_NV_light_max_exponent GL_NV_texgen_reflection GL_NV_texture_env_combine4 GL_S3_s3tc GL_SUN_multi_draw_arrays GL_ARB_texture_border_clamp GL_ARB_texture_compression GL_EXT_framebuffer_object GL_EXT_texture_compression_s3tc GL_EXT_texture_env_combine GL_EXT_texture_env_dot3 GL_MESA_window_pos GL_NV_packed_depth_stencil GL_NV_texture_rectangle GL_ARB_depth_texture GL_ARB_occlusion_query GL_ARB_shadow GL_ARB_texture_env_combine GL_ARB_texture_env_crossbar GL_ARB_texture_env_dot3 GL_ARB_texture_mirrored_repeat GL_ARB_window_pos GL_EXT_stencil_two_side GL_EXT_texture_cube_map GL_NV_depth_clamp GL_APPLE_packed_pixels GL_APPLE_vertex_array_object GL_ARB_draw_buffers GL_ARB_fragment_program GL_ARB_fragment_shader GL_ARB_shader_objects GL_ARB_vertex_program GL_ARB_vertex_shader GL_ATI_draw_buffers GL_ATI_texture_env_combine3 GL_ATI_texture_float GL_EXT_shadow_funcs GL_EXT_stencil_wrap GL_MESA_pack_invert GL_NV_primitive_restart GL_ARB_depth_clamp GL_ARB_fragment_program_shadow GL_ARB_half_float_pixel GL_ARB_occlusion_query2 GL_ARB_point_sprite GL_ARB_shading_language_100 GL_ARB_sync GL_ARB_texture_non_power_of_two GL_ARB_vertex_buffer_object GL_ATI_blend_equation_separate GL_EXT_blend_equation_separate GL_OES_read_format GL_ARB_color_buffer_float GL_ARB_pixel_buffer_object GL_ARB_texture_compression_rgtc GL_ARB_texture_float GL_ARB_texture_rectangle GL_EXT_packed_float GL_EXT_pixel_buffer_object GL_EXT_texture_compression_dxt1 GL_EXT_texture_compression_rgtc GL_EXT_texture_rectangle GL_EXT_texture_sRGB GL_EXT_texture_shared_exponent GL_ARB_framebuffer_object GL_EXT_framebuffer_blit GL_EXT_framebuffer_multisample GL_EXT_packed_depth_stencil GL_APPLE_object_purgeable GL_ARB_vertex_array_object GL_ATI_separate_stencil GL_EXT_draw_buffers2 GL_EXT_draw_instanced GL_EXT_gpu_program_parameters GL_EXT_texture_array GL_EXT_texture_integer GL_EXT_texture_sRGB_decode GL_EXT_timer_query GL_OES_EGL_image GL_ARB_copy_buffer GL_ARB_depth_buffer_float GL_ARB_draw_instanced GL_ARB_half_float_vertex GL_ARB_instanced_arrays GL_ARB_map_buffer_range GL_ARB_texture_rg GL_ARB_texture_swizzle GL_ARB_vertex_array_bgra GL_EXT_texture_swizzle GL_EXT_vertex_array_bgra GL_NV_conditional_render GL_AMD_conservative_depth GL_AMD_draw_buffers_blend GL_AMD_seamless_cubemap_per_texture GL_ARB_ES2_compatibility GL_ARB_blend_func_extended GL_ARB_debug_output GL_ARB_draw_buffers_blend GL_ARB_draw_elements_base_vertex GL_ARB_explicit_attrib_location GL_ARB_fragment_coord_conventions GL_ARB_provoking_vertex GL_ARB_sample_shading GL_ARB_sampler_objects GL_ARB_seamless_cube_map GL_ARB_shader_texture_lod GL_ARB_texture_cube_map_array GL_ARB_texture_gather GL_ARB_texture_multisample GL_ARB_texture_query_lod GL_ARB_texture_rgb10_a2ui GL_ARB_uniform_buffer_object GL_ARB_vertex_type_2_10_10_10_rev GL_EXT_provoking_vertex GL_EXT_texture_snorm GL_MESA_texture_signed_rgba GL_ARB_get_program_binary GL_ARB_robustness GL_ARB_separate_shader_objects GL_ARB_shader_bit_encoding GL_ARB_texture_compression_bptc GL_ARB_timer_query GL_ANGLE_texture_compression_dxt3 GL_ANGLE_texture_compression_dxt5 GL_ARB_compressed_texture_pixel_storage GL_ARB_conservative_depth GL_ARB_internalformat_query GL_ARB_map_buffer_alignment GL_ARB_shader_atomic_counters GL_ARB_shading_language_420pack GL_ARB_shading_language_packing GL_ARB_texture_storage GL_EXT_framebuffer_multisample_blit_scaled GL_EXT_transform_feedback GL_AMD_shader_trinary_minmax GL_ARB_ES3_compatibility GL_ARB_clear_buffer_object GL_ARB_copy_image GL_ARB_explicit_uniform_location GL_ARB_invalidate_subdata GL_ARB_texture_query_levels GL_ARB_texture_storage_multisample GL_ARB_texture_view GL_ARB_vertex_attrib_binding GL_KHR_debug GL_ARB_buffer_storage GL_ARB_clear_texture GL_ARB_multi_bind GL_ARB_seamless_cubemap_per_texture GL_ARB_texture_mirror_clamp_to_edge GL_ARB_vertex_type_10f_11f_11f_rev GL_EXT_shader_integer_mix GL_ARB_conditional_render_inverted GL_ARB_derivative_control

    For it was useful.

  • It would be useful to format your code for the forum. Follow link in first comment from GoToLoop. You don't have to repost the code just edit your previous comments.

  • Just noticed the example code you posted for others to try. Not only it should be formatted for the forum but also a single block that can be copied and pasted into Processing.

    Create a new comment in this discussion with the code you want members to test taking into accont what I said about formatting and just a single block. Make sure the comment explains that you want members to try it out and report back on success or not.

  • Hi guys,

    Thanks a lot for your help. At end it was decided to replace G4P by Java Swing and open the window (toolbox) before any other. With this technique all components works fine.

    It might be possible that it was not the best solution but works.

    Thank you!

  • Now that I have access to Process I can test this further.

    Using Processing 2.2.1 and G4P 3.5.3 I get the following results

    Main     Secondary    Gtextfield works
    JAVA2D     JAVA2D         Y
    JAVA2D     P2D            Y
    P2D        JAVA2D         Y
    P2D        P2D            Y

    Although this differs from my previous comments it shows that the problem is not caused by G4P or Processing.

  • Ok quark.
    Thanks for your support.

Sign In or Register to comment.