-3

How to create java program in netbeans that make the user select an image by pressing button and select the image , and after that make the user add text by pressing button and typing on that image.

....... I want to create 2 buttons one for select images and one for add Text on that image.......

Can anyone help me please. And thanks

  • I want the user add text on that image by button – Khaled Matrix Apr 13 '18 at 18:32
  • `and after that make the user add text by pressing button and typing on that image.` - please define your requirement better. Where is the text displayed?. Is the text centered on the label? Can you add text in more than one place? A typical way to do this might be to add a JTextField to the label when you click on the button. Then you type in the text field and when you hit enter you save the text from the text field as the text of the label. – camickr Apr 13 '18 at 19:18
  • I want the user to add the Text anywhere he want on the image that shows in the label that he is selected before. By clicking on button named example(ADD TEXT) – Khaled Matrix Apr 13 '18 at 19:29
  • 1) Still didn't answer if you can have text in multiple places. 2) How does clicking on the button help? How do you know where to place the text? – camickr Apr 13 '18 at 19:36
  • 1) No... 2) because that is my homework make a button to add text ...... 3) let's say the text will be in the bottom on image – Khaled Matrix Apr 13 '18 at 20:46
  • I created jlabel and 2 buttons under the label one for select images and one to add the Text on that image.. My problem is i cant add the Text on the image – Khaled Matrix Apr 13 '18 at 20:52

1 Answers1

0

after that make the user add text by pressing button and typing on that image.

So when you click on the button I would suggest that you:

  1. Display a JOptionPane to prompt for the text to be displayed.
  2. Then you get the text from the option pane and add the text to the label. How you add the text depends on your exact requirement on how the text should be displayed. Check out: Clear previously drawn string over an image for 4 possible ways to do this.
camickr
  • 321,443
  • 19
  • 166
  • 288