• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

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.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic