Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7771755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:43:41+00:00 2026-06-01T16:43:41+00:00

I am creating a window with two image buttons (using TriplePlay in my playN

  • 0

I am creating a window with two image buttons (using TriplePlay in my playN game).

Now I need dynamic text on these buttons. But when I add buttons with images (setIcon), I am not able to add Text on it same time. Please check the following code block I use now.


Interface iface = new Interface(null);
pointer().setListener(iface.plistener);
Styles buttonStyles = Styles.none().add(Style.BACKGROUND.is(new NullBackground())).
    addSelected(Style.BACKGROUND.is(Background.solid(0xFFCCCCCC)));
Stylesheet rootSheet = Stylesheet.builder().add(Button.class, buttonStyles).create();
Root buttonroot = iface.createRoot(AxisLayout.horizontal().gap(150), rootSheet);
buttonroot.setSize(width_needed, height_needed);
buttonroot.addStyles(Styles.make(Style.BACKGROUND.is(new NullBackground())));
graphics().rootLayer().add(buttonroot.layer);
Button you = new Button().setIcon(buttonImage);
Button friend = new Button().setIcon(buttonImage);
buttonroot.add(you).add(friend);
buttonroot.layer.setTranslation(x_needed, y_needed);
Root nameroot = iface.createRoot(AxisLayout.horizontal().gap(300), rootSheet);
nameroot.setSize(width_needed, height_needed);
nameroot.addStyles(Styles.make(Style.BACKGROUND.is(new NullBackground())));
graphics().rootLayer().add(nameroot.layer);
name = new Label("YOU");// we need the dynamic string variable instead
friendName = new Label("FRIEND"); // we need the dynamic string variable instead
nameroot.add(name).add(friendName);
nameroot.layer.setTranslation(x_needed, y_needed);

here I have tried making a root then add button with images to it then making another root and add labels on it so that it will be show like text on the image buttons. But I know this is a bad way of doing it, and the alignment will not be according to what needed as it a dynamic text. Is there anyway to add a button, with image and a label on it?

Thanks in anticipation

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T16:43:43+00:00Added an answer on June 1, 2026 at 4:43 pm

    Creating a button with text and an icon is trivial:

    Button button = new Button("Text").setIcon(iconImage);
    

    You can then change the text on the button any time you like, like so:

    button.text.update("New Text");
    

    If you want a button with a background image with text rendered over the background, then do the following:

    Button button = new Button("Text").
      addStyles(Background.is(Background.image(bgImage)));
    

    Note that you will need the latest TriplePlay code (from Github) to use the ImageBackground. The latest code also supports Flash-style “scale9” backgrounds:

    Button button = new Button("Text").
      addStyles(Background.is(Background.scale9(bgImage)));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating an X11 window for a game, but it seems to only
When creating a window class for use with a DialogBox you need to specify
When creating a window using CreateWindow(...) , which requires the window width and height,
I am creating a modal window using Twitter Bootstrap. The default behavior is if
I am creating a WPF custom control, a Button with an Image and Text
I am creating a program using wxpython which entails the need to create many
I have an app where I am creating two subviews of the main window,
I am writing a GTKmm window program; the main window creates two buttons, one
I am creating window c# desktop application I have three columns in my datagridview
In previous versions of Xcode creating a window-based, universal application would populate the project

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.