• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JButton and opening new window

 
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello All,
I am having trouble, when I click on mu button i get a window up with a grey background.
I want to get a window up with a white background and the text "HOW CAN I DO THIS" showing, the text should not be editable and a scroll pane so that if I want to put more text in the textArea I can.
so if any of you lovely people want to help me I would be most Grateful
Thanks
Ben
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You never added the JPanel to the JFrame.

You don't need to setVisible() on the JPanel. That is the default behavior. Another thing I am wondering that doesn't have anything to do with your question is why you are processing a Button click with a MouseEvent?
 
ben riches
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Gregg,
Thanks for yoy help it has done wonders.


You don't need to setVisible() on the JPanel. That is the default behavior. Another thing I am wondering that doesn't have anything to do with your question is why you are processing a Button click with a MouseEvent?


The reason I have the MouseEvent is that I am developing the code using Visual Age for Java, and it automatically gives you a MouseEvent.
Thanks Again
Ben
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by ben riches:
The reason I have the MouseEvent is that I am developing the code using Visual Age for Java, and it automatically gives you a MouseEvent.
Thanks Again
Ben


Weird. It is still a JButton though, right? It should be using an ActionEvent. But whatever is working...
 
ben riches
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Again Gregg,
I have another question, How can I add an Image to my text area (if possible). if not possible what is the best solution to adding images and text to and area like I have already?
Thanks
Ben
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can't add an image to a Text Area. You can add an image to a JTextPane and/or a JEditorPane. You can find tutorials on this here and/or you can use the Search feature on this forum because this has been asked many times in the past.
Another approach you could do is you could add an image to a JLabel and place it above or below the TextArea. Not sure if that is the look you are going for. My first suggestion is your best bet if you need anything between words/sentences in your TextArea.
 
Could you hold this puppy for a sec? I need to adjust this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic