Swing , would like to print hello inside of the frame, how?

i would like to print hello inside of the frame, how can i do that?
import java.awt.*;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JButton;
import javax.swing.JComponent;
import java.awt.Toolkit;
import java.awt.BorderLayout;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class Main extends JPanel
implements ActionListener {
JButton button;
public Main() {
super(new BorderLayout());
button = new JButton("Click Me");
button.setPreferredSize(new Dimension(200, 80));
add(button, BorderLayout.CENTER);
button.addActionListener(this);
public void actionPerformed(ActionEvent e) {
     System.out.println("hello");
* Create the GUI and show it. For thread safety,
* this method should be invoked from the
* event-dispatching thread.
private static void createAndShowGUI() {
//Create and set up the window.
JFrame frame = new JFrame("welcome");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Create and set up the content pane.
JComponent newContentPane = new Main();
newContentPane.setOpaque(true); //content panes must be opaque
frame.setContentPane(newContentPane);
//Display the window.
frame.pack();
frame.setVisible(true);
public static void main(String[] args) {
//Schedule a job for the event-dispatching thread:
//creating and showing this application's GUI.
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}

Recommended lessons in this context: [Using Layout Managers|http://java.sun.com/docs/books/tutorial/uiswing/layout/using.html] and [Painting in AWT and Swing|http://java.sun.com/products/jfc/tsc/articles/painting/]
If the second lesson is a little heavy, look at this light version: [Performing Custom Painting|http://java.sun.com/docs/books/tutorial/uiswing/painting/index.html]
Edited by: Andre_Uhres on Aug 24, 2008 8:34 AM

Similar Messages

  • I would like to print using using bluetooth connection. How do I do it ?

    Can I print using bluetooth connection between my laptop and my printer ?? The network i am using is a Hotspot.

    Hi,
    You need both must have Bluetooth. Do your laptop and your printer have Bluetooth ? Wireless hotspot is a different story. What is your laptop and what is your printer ?  To help us answer question quicker, please read this:
       http://h30434.www3.hp.com/t5/First-Time-Here-Learn-How-to/Welcome-Get-started-here/td-p/699035
    Regards.
    BH
    **Click the KUDOS thumb up on the left to say 'Thanks'**
    Make it easier for other people to find solutions by marking a Reply 'Accept as Solution' if it solves your problem.

  • I am trying to print a PDF file to a legal size paper and I would like for it to fill up the page. How do I do this? I went into the settings and changed it from letter to legal, but it's still printing out the same size. Can someone help me, please?

    I am trying to print a PDF file to a legal size paper and I would like for it to fill up the page. How do I do this? I went into the settings and changed it from letter to legal, but it's still printing out the same size. Can someone help me, please?

    Are you trying to Print to PDF or are you trying to Print a PDF file to a physical printer?

  • I have an IPAD 2 and would like to print to my mobile printer HP 470.  Can I do this through the cable? What do I need to do?

    I have an IPAD 2 and would like to print to my mobile printer HP 470.  Can I use the patch cable?  What do I need to do?

    iOS AirPrint Printers  http://support.apple.com/kb/HT4356
    How to Print from Your iPad: Summary of Printer and Printing Options
    http://ipadacademy.com/2012/03/how-to-print-from-your-ipad-summary-of-printer-an d-printing-options
    Print from iPad / iPhone without AirPrint
    http://ipadhelp.com/ipad-help/print-from-ipad-iphone-without-airprint/
    How to Enable AirPrint on a Mac and Use Any Printer
    http://ipadhelp.com/ipad-help/how-to-use-airprint-with-any-printer/
     Cheers, Tom

  • TS3147 I would like to print pdf architectural plans in the scale they were intended how can I do this?

    I would like to print architectural plans to scale from a pdf.  How can I do this?  Even just a section of the plan.
    thank-you

    Did you try Google?
    https://www.google.com/search?q=print+architectural+plans

  • I have a Mac and use an EPSON NX510 printer. I would like my printer to only print in black ink unless I otherwise indicate. How do I do this?

    I have a Mac and use an EPSON NX510 printer. I would like to print in black ink only and cannot locate how to do this?

    You usually find an option to print in black and white or gray scale in the settings of your printer that come up  when you choose "print" in the file menu of the program you are using at the time.
    BUT, if what you want to do is print with only black ink because you are out of ink in one of the color cartridges, that is usually not possible. For some reason I can't remember, printers makers prevent the use of the printer as soon as one of the color cartridges is empty.

  • I would like to print a page from a book bought on Amazon.  How can I do that?

    Dear Support Community:
    I bought a digital book on Amazon.com, and downloaded it to my iPad.  It is in the KINDLE app.  I would like to print a page or two of it on the printer connected to my lap top.  Am having a devil of a time.  can anyone help?   I think I can do it, but just don't know how. Please help?
    thanks.
    Gary

    I've never tried to print a book page directly, so don't know if it is possible.
    But you could do this.
    How to take a screenshot on your iPad
    http://www.imore.com/screenshot-ipad
    And then print the pic.
     Cheers, Tom

  • I would like to print out the icon and title of each of my apps to another document for printing and sharing within my family

    I would like to print out the icon and title of each of my IOS apps to another document for printing and sharing within my family.  My son has my old iPod touch so I erased it so he could put whatever games he wants to play on that I used to play with.  It is difficult to download every game at one time because there is too much to download at one time.  I have many hundreds of apps.  One way I found was to create a screen grab of each page in iTunes  then open it in Preview contact sheet but that is really tiny unreadable image of each screen.  I also tried importing a screen shot of the contact sheet into Paint 2 and magnifying it on several pages but that is really blurry.  The ideal solution would be to import the icon and text to another app or to provide a print list of apps solution within iTunes.

    Create iPad screen shots by briefly pressing the home and on/off buttons together.  You will hear a shutter click sound and find a screen shot on your iPad's Camera Roll.  You can then print these screen shots as you would any iPad photos.
    UPDATE: I assumed you had an iPad.  Hopefully your iOS device does have an on/off and home button and is capable of producing screen shots.

  • Hello all,   I have a iMac, iPhone 4s, iPhone 4 and an Apple TV v3...and I would like to be able to stream the same song to all of these devices all at the same time. Is this possible do you know?   any details greatly Rx'd

    Hello all,
    I have a iMac, iPhone 4s, iPhone 4 and an Apple TV v3...and I would like to be able to stream the same song to all of these devices all at the same time. Is this possible do you know?
    any details greatly Rx'd

    Welcome to the Apple Community.
    Thats not possible I'm afraid, only the Apple TV can receive an AirPlay stream, and even then only one at a time, unless you stream from a computer.

  • I have an Iphone 4S and I would like to print my text messages, including the thread and the Imessage date and time stamps.  How would I do this?

    I have an Iphone 4S and I would like to print my text messages, including the thread and the Imessage date and time stamps.  How would I do this?

    settings - message - imessage - OFF

  • I would like to print a four sided programme, but am having trouble finding out how to organise the sections onto a 17  by 11 paper with the sections in the right order. Any help?

    I would like to print a four sided programme, but am having trouble finding out how to organise the sections onto a 17  by 11 paper with the sections in the right order. Any help?

    If all you are going to do is print double sided and them make
    a single fold reducing the page to 8 1/2 x 11, one side of the
    original 17 x 11 page will be page 4 on the left as you hold
    the page facing you and page 1 on the right, reverse side
    should be printed so top is same as top on the the first side
    and will be page 2 to the left and page 3 to the right. Pick
    up the double sided document with pages 2 and 3 facing you, fold
    left edge to meet right edge; you should now have fold on the left
    with page 1 facing up toward you, turn the page as you normally
    would and pages 2 & 3 should be in order, and one more turn brings
    you to page 4 and the fold should know be on the right. I hope this
    explains clearly enough - if not, post back and some one should
    join in with a better explanation.

  • I would like to print my Pages document on Matte Photo Paper

    I would like to print my Pages document on Matte Photo Paper which is in the rear feeder of my Canon Pixma MX882 printer. The print function in Pages/Yosemite does not give me that option.The only options are to print on plain paper from the cassette. When I print images from iPhoto, I have more paper options. When I try to convert the doc to a jpeg, with Graphic Converter so I can drop it in iPhoto, the result is very blurred almost unreadable.

    Have you gone to Canon's website and downloaded the very latest Printer Driver for your Model?
    Also have you looked amongst the paper handling options in your Print dialogue for the rear feeder option.
    What is stopping you putting the high quality paper in your regular paper cassette?
    Peter
    Here is the link for the Yosemite driver:
    http://www.usa.canon.com/cusa/support/consumer/printers_multifunction/pixma_mx_s eries/pixma_mx882#DriversAndSoftware

  • HELLO I WOULD LIKE TO BUY IPHONE 5 FROM THE OFFICIAL SITE OF APPLE BECAUSE IS CHEAPER FROM MY COUNTRY GREECE. MY QUESTION IS CAN SUPPORT THE GREEK MENU OR LANGUAGE? THANKS

    HELLO I WOULD LIKE TO BUY IPHONE 5 FROM THE OFFICIAL SITE OF APPLE BECAUSE IS CHEAPER FROM MY COUNTRY GREECE. MY QUESTION IS CAN SUPPORT THE GREEK MENU OR LANGUAGE? THANKS

    To find out what languages are supported, just read for yourself the tech specs:
    http://www.apple.com/iphone/specs.html
    To find out if you can buy something you have to contact the store yourself.  The US Apple store does not sell to other countries.

  • Hello, I live in Russia and would like to purchase I-phone through the online store E-bay from a private individual. As in this case, the guarantee?

    Hello, I live in Russia and would like to purchase I-phone through the online store E-bay from a private individual. As in this case, the guarantee?

    Again, the iPhone warranty is NOT international. And, if I may offer unsolicited advice, buying from ebay is always risky. Most sellers are less then honest when it comes to iPhones. They might state that the iPhone is unlocked when it is not; it might not be really unlocked or might be hacked/jailbroken.
    My advice to you is to buy in the country you intend to use the phone and buy it from a legitimate source such as Apple or an authorized reseller.

  • I would like to print addresses on envelopes from my ipad contact list

    I would like to print addresses plus my return address on envelopes using ipad contact list.  I do not have a wireless printer so would have to export file to be able to use in some way on my pc.  Is  this possible?  Thanks  Pam

    Hello FeyQueen,
    You may be able to remove existing game data by via the following:
    On your iOS device, go to Settings > iCloud, then tap Storage & Backup.
    On your Mac, go to Apple () menu > System Preferences, click iCloud, then click Manage.
    On your Windows computer:
    Windows 8.1: Go to the Start screen and click the down arrow in the lower-left corner. Click the iCloud app, then click Manage.
    Windows 8: Go to the Start screen and click the iCloud tile, then click Manage.
    Windows 7: Choose Start menu > All Programs > iCloud > iCloud, then click Manage.
    Once in the 'Manage' dialog, look for the name or icon of the affected game. If present, you should be able to delete any data the game has saved to your iCloud account.
    Managing your iCloud storage
    http://support.apple.com/kb/HT4847
    Cheers,
    Allen

Maybe you are looking for

  • Setting the: signed.applets.codebase_principal_support to true is not working ( keeps asking to set it to true)

    i've Set the Boolean string to true but when i try to copy paste in firefox it just gives me the message again ( you need to set the signed.applets.codebase_principal_support to true ) Is this a know bug ? thanks.

  • Live Capture from GL2 Camera via Firewire

    Image quality when capturing live video into iMovie from a Canon GL2 is very very grainy and poor quality. It used to work fine capturing into iMovie HD, but that no longer works correctly with Snow Leopard (transport controls and other buttons don't

  • Why the roles that I gave, does not refresh instantly on BPM Administrator?

    Hi there: Another question (sorry for being so annoying...lol), Look I gave to a participant a role using Oracle BPM Administrator. On some occasions, the roles refresh instantly, but in other occasions take a long time to refresh(3 to 4 hours) . Why

  • Lightroom 3 issues with viewing

    Can someone please help me! My lightroom 3 does not seem to be working correctly, When trying to create a catalogue I cannot view the pictures! I can view them to try and upload but to try and edit them the picture is not viewable. all I get is a Gre

  • Does Photoshop CS3 Extended support Thai fonts?

    I am translating some short text in Photoshop to several Asian languages. I noticed just with the Thai language, that I get a series of X's with boxes instead of Thai characters. The characters are fine in other applications, including Flash CS3. Oth