File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes JButton and opening new window Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JButton and opening new window" Watch "JButton and opening new window" New topic
Author

JButton and opening new window

ben riches
Ranch Hand

Joined: Nov 08, 2002
Posts: 126
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
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15300
    
    6

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?


GenRocket - Experts at Building Test Data
ben riches
Ranch Hand

Joined: Nov 08, 2002
Posts: 126
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
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15300
    
    6

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

Joined: Nov 08, 2002
Posts: 126
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
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15300
    
    6

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JButton and opening new window