How Can I show image on GLabel or on GTextArea in G4P from MySQL database.

edited August 2017 in Library Questions

Hi All, I have a GUI where I want to display some information from MySQL database. I am able to display text on GTextArea from database. But I need to displaying flag of country on GLabel or GTextArea from same database. could anyone help me.

Thanks to all


  • So is your question: "How do I display an image on a GLabel or GTextArea?" ... and does this have anything to do with a database? Are you able to display an image that you didn't load from a database on a GLabel or GTextArea? If so, is your question "how do I get an image from a database?"

    It would be much easier to understand your problem if you provided a short code example -- for example, are you using the bezier mysql library?

  • It is not possible to display an image inside a GTextArea control.

    The GLabel control can display either text or an image or both together. There is an example sketch that comes with the library that demonstrates text/icon controls. Also this reference page shows the main methods for load and aligning text and images inside a GLabel control.

  • edited August 2017

    I have copied your message here because it is a continuation of the problem described here and any information I provide might help others.

    Hi quark, Thank you for your response. I have try to load image from database (MySQL) into a GLabel. But it is not working. Could you help me ? I have attached my code here. Text is loading into GTextArea but image is not loading into GLabel.

    public void get_country_info(String country_name) { DBConnection connectToDb = new DBConnection(); ResultSet resultSet = null;
        resultSet = connectToDb.find(country_name); 
        try {
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(null, ex.getMessage());
    class DBConnection {

    Thank you

    Unfortunately you don't say what if any error message you got! (Bit like going to the doctors and asking for a diagnosis without telling him the symptoms :-/ )

    Having said that the most likely problem is that the getBlob() method does not return a PImage object.

    resultSet.getBlob("country_flag") // Does not return a PImage

    So you need to covert the binary data returned by getBlob into a PImage first.

  • Hello. I don't know much about blobs, but you have to copy the image information in a file and then read it with an input stream. There are a lot of examples if you search the internet by something as "java mysql displaying blobs in labels". If you want I can search an apropiated example.

Sign In or Register to comment.