How to add a title to a JFrame descendent

Hi. I have created a class that extends the JFrame class. What I would like to do is put a title on the window. How do I do that?
Must I create another constructor to accept the string? Currently, all I have defined is a no-parameter constructor.
Should I use super. somehow? My constructor looks as follows:
public Rectangle()
// Set up the Grid layout
mainGrid = new GridLayout(6, 2);
// Add the layout to the container
container = getContentPane();
container.setLayout (mainGrid);
//Create Length Label
labLength = new JLabel("Length: ");
labLength.setHorizontalAlignment(JLabel.RIGHT);
container.add(labLength);
// Create Length TextField
txtLength = new JTextField("1.0", 5);
container.add(txtLength);
// Create Width Label
labWidth = new JLabel("Width: ");
labWidth.setHorizontalAlignment(JLabel.RIGHT);
container.add(labWidth);
// Create Area TextField
txtArea = new JTextField(5);
txtArea.setEditable (false);
container.add(txtArea);
setSize(400,150);
setVisible(true);
} // end constructor method
Thanks for any help you can offer.

Yeah, you can make another constructor that takes a String as an argument then calls super(String)
public Rectangle(String title)
super(title); // calls the JFrame constructor
Rectangle(); // calls your no argument constructor
or use the setTitle(String) metod to set it some other time if you want.

Similar Messages

  • How to add a Title (slide? screen?) BEFORE the video track

    Hello,
    I'm very new to Adobe Premiere Pro and I'm trying to figure out how to add a title to my project but I don't want the title on the start of the video in the sequence. I'd like to add it to a black screen, maybe with some transition effects, that will play prior to the video starting. Do I need to create a black image in CS and add it as a still and just add the title to the still which I can position before the video/audio track A starts?
    I'm hoping that there's something I can do right within Premiere that will give me a place to put the title before my video starts. I didn't see an option to add a blank slide or something to that effect that I can add title to.
    thanks for your assistance!
    The more I learn the more excited I get, this software is great.

    Thanks for the link.. like I said in my post, I'm brand new to the software and I've been watching and following guides for hours. Time is not on my side, I have a project that must be done by the end of this week and I have very limited time after work.
    So when I have the head at the begining of my main track and click INSERT in the source monitor window it inserts a duplicate of the entire video so I have TWO videos in my sequence. This is clearly not what I'm wanting so I'm assuming that there's something I'm missing. I've searched google but don't see anything.
    I'm just looking to add a black, blank screen that I can add a title to before my video begins. I realize this may be rudamentary to season vets but as I said, I'm very new and trying to learn this all quickly and I would really appreciate if someone could point me directly to some information about it. I'm not afraid to read and learn, hell I love it, but I'm pressed for time so someone just telling me, "go learn the software" with a link to a huge FAQ, doesn't really help me.
    I've already learned a ton from some great guides but I have yet to have anyone indicate how to add extra footage (be it a still or blank video) directly from Premiere Pro.
    Thank you all for your time!
    EDIT: I think I figured it out... I just bumped the start of the main track up about 10 seconds and I added new item "Black Screen" right in front of it. I will add the title to this. Thanks all.

  • How to Add the title name for Graph in Excel

    Dear Friends
                      I am using LabVIEW 8.0.I need how to add the title name for chart in Excel.
    Jayavel
    Solved!
    Go to Solution.

    Do you have the Report Generation Toolkit? If so, the Excel Easy Graph VI has an input for that.
    If you don't have the toolkit then you will need to use ActiveX. Please do a search on how to use ActiveX (there are examples that ship with LabVIEW) to control Excel. There are also lots of example in the Excel thread. NOTE: DO NOT POST QUESTIONS IN THAT THREAD. 
    Ultimately you will need to look up the information in MSDN. 

  • How to add a title to the book cover/spine?

    Hi,
    appears to be a stupid question, but I couldn't find any answer in the Videos by JK o any other help page:
    How can I add a title to he book cover and the spine of a blurb-book made in LR5?
    I could not find any cover template having a title (only a lot of text).
    Thanks a lot in advance,
        schleifi

    I have worked with Booksmart and made one book successfully. I have also made a book in Lr 5.2 and had it printed by Blurb to my satisfaction.
    Compared to creating a book in Lr the workflow in Booksmart is cumbersome and slow.
    (1) During the creation of a book in Lr I test the book often by exporting it as a PDF. This option is only available when you select PDF instead of Blurb - but it is possible to switch between PDF and Blurb without harm. The only change is that the Blurb logo page disappears when PDF is selected. Viewing the PDF in Acrobat tells me what the book will look like in print since my monitor is calibrated and set to the correct intensity (brightness).  It also tells me if my sharpening is good. For the export to PDF I select 100 for quality; color profile sRGB; file resolution 300; sharpening High; media type glossy.
    A Blurb representative told me that these settings come close to the settings that Lr uses when the book is uploaded to Blurb.
    In Booksmart I can't export to PDF.
    BTW you should sharpen the image so much that it looks a bit too sharp in your PDF. When the boook is printed the ink droplets spread out a tiny bit before they dry. This tends to make the print softer than it looks on screen.
    (2) Booksmart is not color managed. Therefore in Booksmart you have no feedback how your book will look in print. If you want to test your images you have to softproof them in Photoshop.
    (3) When I make a book I find often that my develop adjustments are not optimal. In Lr it is very easy to switch the the Develop Module, make the necessary adjustments and switch back to the Book Module. With Booksmart you have to export the adjusted image again - or it has to be re-published if you use the Blurb plug-in.
    (4) In the past I have made complaints that Lr does not give enough flexibility for the layout. Since then I have worked more in Lr and I find the Book Module actually quite good.
    I find that the full page bleed allows the most flexibility for creating my own layout. Starting with a full page bleed I use the padding feature to place the image anywhere on the page and in any size I want. The boxes for "Page Text" and "Photo Text" allow for more than one column. The text can be edited by adjusting Tracking (all letters are spaced wider/closer), Kerning (individual pairs of letters can be spaced), Baseline (letters can be pushed up or down), or Leading (the distance between different lines of text can be adjusted). There are no such features in Booksmart.
    (5) Selecting a color for page background or for text is cumbersome in Booksmart. In Lr it's easy.
    The cover of my first book in Lr looks like this:

  • How to add a KeyListener for the JFrame (when I'm typing in a JTextField)?

    I have some problem with KeyListener..
    I add a KeyListener (I named it "listener") for my JFrame and it works fine. Then I add JTextField to the JFrame. When I'm typing some text in the JTextField - my "listener" does not work. (cause my JTextField doesn't have a KeyListener).
    I just want to make an ability to process hot keys which user presses in my java program..
    Does anyone know how to do it?

    In future, please ask Swing questions in the [Swing Forum.|http://forums.sun.com/forum.jspa?forumID=57]
    Don't use KeyListener. In fact KeyListener is seldom useful. Use key binding: [http://java.sun.com/docs/books/tutorial/uiswing/misc/keybinding.html]
    Or you can have menu items with accelerators (hot keys).

  • How to add a button to a JFrame..?

    Hi everyone,
    First of all, I would like to apologise for asking such a "stupid" question.. im new to the java world.
    Now for my question : I have a JFrame , but I would like to add a button to it ( I would also like to be able to choose where I can place the button) . Also, once I click on the button, I want the JFrame to disappear and let the rest of the code be run ( The JFrame is only used as a "presentation" , to introduce the program ).
    Sorry if I didn't explain it well :)
    Thanks everyone,
    -ax

    Here is a good swing tutorial:
    http://java.sun.com/docs/books/tutorial/uiswing/components/index.html

  • How to add a title to a JavaScript Confirm dialog box.

    function confirmDelete() {
    var msg = "Do you want to continue removing the items ?";
    return confirm(msg);
    Presently it says http://locahost:8080/says etc on the title bar for the dialog box. Instead I want to set the title as "Confirm Delete". How can I do this?

    You're talking about the document title as you set it in the HTML head? Just alter the title of the document accordingly in the same Javascript function.
    If you find Javascript hard, there's a nice tutorial at w3schools.com. And for Javascript related questions better use a forum devoted to Javascript. There are ones at webdeveloper.com and dynamicdrive.com.

  • How to add image as backgrount in JFrame with Box containers?

    Hi
    I am trying to set the background of my JFrame to an image.
    The problem is that when i use the JPanel method to add the image as background i have to add it in the frame as the last thing or else you can't see it, because the Box components are put on top of it. If i add it as the last component to the frame the only thing you can se is the background, because it is added on top of everything.
    So my question is, are there any other ways?
    Thanks.
    Hessi - the new guy. :)
    Edited by: Hessi on Apr 10, 2009 3:26 PM

    Then when you start scrolling or clicking on entries or otherwise manipulating the list the graphics get all messed up.The opacity property is a contract with the painting system that the component will paint all the pixels opaque within its bounds. If the component dosen't do that and its opacity is set to true then you get painting artifacts.
    But I see what the problem is now. The gray thing behind the list is the viewport of the scroll pane. So do this
    JScrollPane scrollPane = new JScrollPane(list);
    scrollPane.setOpaque(false);
    scrollPane.getViewport().setOpaque(false);
    scrollPane.getViewport().setBackground(new java.awt.Color(0, true));It also needs to be done on the scrollbars of the scrollpane.
    Edited by: Maxideon on Apr 16, 2009 10:03 PM
    A recursive method to do all this stuff after everything has been added can help. Saves the trouble of constantly setting the opacity and background color.
    import javax.swing.*;
    import java.awt.Image;
    import javax.imageio.ImageIO;
    import java.awt.Color;
    public class Test {
        public static void main(String[] args) throws Exception {
           SwingUtilities.invokeLater(new Runnable() {
               public void run() {
                   createAndShowGUI();
        private static void createAndShowGUI() {
            JPanel contentPane = null;
            try {
                final Image img = ImageIO.read(new java.net.URL("http://" +
                        "hritcu.files.wordpress.com/2006/11/dukewithhelmet.jpg"));
                contentPane = new JPanel() {
                    public void paintComponent(java.awt.Graphics g) {
                        super.paintComponent(g);
                        g.drawImage(img, 0, 0, null);
                contentPane.setBackground(Color.white);
            } catch (Exception e) {
                System.err.println("Unable to load image for " +
                        "background demonstration");
                contentPane = new JPanel();
                contentPane.setBackground(Color.PINK);
            Object[] numbers = new Object[30];
            for (int i = 0; i < numbers.length; i++) {
                numbers[i] = new Integer(i);
            JList list = new JList(numbers);
            list.setForeground(java.awt.Color.green);
            JScrollPane scrollPane = new JScrollPane(list);
            JFrame frame = new JFrame();
            frame.setContentPane(contentPane);
            frame.add(scrollPane);
            frame.add(new JButton("A Button"));
            frame.add(new JSlider());
            frame.add(new JRadioButton("A Radio Button"));
            frame.add(new JTextField("A text field"));
            frame.add(new JTextArea("A text area.\nSome more text."));
            frame.add(new JSpinner());
            frame.add(new JLabel("A Label"));
            frame.add(new JScrollPane(new JTree()));
            frame.setSize(600, 450);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            setHeiarchyTransparent(contentPane, false);
            frame.setVisible(true);
        private static final Color transWhite = new Color(0x00ffffff,true);
        public static void setHeiarchyTransparent(java.awt.Component root,
                                                  boolean includeRoot) {
            if(includeRoot && root instanceof JComponent) {
                JComponent jc = (JComponent) root;
                jc.setOpaque(false);
                jc.setBackground(transWhite);
            if (root instanceof java.awt.Container) {
                for (java.awt.Component c : ((java.awt.Container) root).getComponents()) {
                    setHeiarchyTransparent(c,true);
    }

  • How to add a title to button in flash?

    Hi,
    I have a button in flash and a action layer with the following script:
    button1.addEventListener(MouseEvent.CLICK,clickHandler);
    function clickHandler(event:MouseEvent):void{
    navigateToURL(new URLRequest("http://mortimerhall.99k.org/homepage.htm"),"_self");
    Now I would like to have a title when user move mouse over a button eg "Click To Enter".
    I tried this code in a new layer but it doesn’t work:
    on (rollOver) {
    text = "hello";
    on (rollOut) {
    text = "";
    I would be grateful if you could help with it.
    The button has of course the "Instance Name".
    Thanks
    PS My first post, sorry for wrong place or any mistakes
    I have a cs5.5 Pro.

    Thanks! Your method is working fine. It is enough for my needs.
    For any one that may want to see it:
    button1.addEventListener(MouseEvent.ROLL_OVER, rollOverHandler);
    button1.addEventListener(MouseEvent.ROLL_OUT, rollOutHandler);
    function rollOverHandler(e:MouseEvent):void
         text2.visible = true;
    function rollOutHandler(e:MouseEvent):void
         text2.visible = false;
    it's fine being new to flash, but when you don't explain what you are trying to achieve very clearly and then use terms like title when you mean tooltip cna be very confusing for those trying to help.
    Sorry, my bad
    Thanks again!

  • How to add a title in iMovie 10.0.7?

    I searched the net but its full of tutorials in older versions.

    DaHappy_DJ wrote:
    I searched the net but its full of tutorials in older versions.
    the official and included (click on 'Help' in iMovie)  Manual is always up to date and tells you ...:
    http://help.apple.com/imovie/mac/10.0.6/?lang=en#/mov4d3dce7ba

  • How Do I Add A Title To My Outline?

    Sick of MS WORD so I broke down and bought PAGES this morning. So far I like it, but I was most excited about using the Outline Mode, however I'm trying to add a title to my outline, but I can only make it one of the actual bullet points. Anyone know how to add a title and for that matter, how to start and stop an outline within a document, meaning if I want to do a paragraph or two of plain text and then outline a few points and then go back to a paragraph. Thanks in advance for any advice.

    You are definitely after List Style not Outline. Outline is just a way of looking at your document and moving parts of it around. You switch between that and the regular view of the document:
    Menu > View > Show/Hide Document Outline
    Lists are on the right of the toolbar. You may have to stretch the window out a little toi see it.
    Download and read the Pages09_UserGuide.pdf from under the Help menu.
    Peter

  • How do I add song titles and writer/arranger text to scores in Logic 8

    I am having trouble figuring out how to add song titles into or onto the scores of compositions I'm doing.
    Thanks
    "Peace and Blessings"
    www.Myspace.com/cayebaby
    www.flickr.com/photos/c-aye/sets

    Have you checked this:
    [Working with Notation|http://documentation.apple.com/en/logicpro/usermanual/index.html#chapt er=31%26section=0]
    A

  • Add the title before each Report

    Hi Experts,
    For a requirement I need to combine 3 reports into a single template using Web application designer,
    The title should display for each of the reports.
    I do not have any standard template.Its a combination of 3 reports and is displayed in the same page.
    My requirement is to how to add the title before each of the 3 reports .
    Many Thanks,
    Vijaya.

    Hi Vijaya,
    You can  have the Analysis or the Table item with a Tray. i.e; You can enter a name for the report in the Tray.
    You will find the Tray in the Properties of the Web Item. Its mainly used for naming purpose.
    Or else you can have a Text Web Item corresponding to each of your reports. 3 Report 3 Text items. Text item is found in the Standard Tab in WAD 3.5 or under Misc. Tab in WAD 7.
    Bind the Text Element to the respective Reports and give it a name.
    Place the Text item above the report in the template.
    Cheers,
    Tanish

  • How to add a Button in JFrame title Bar ?

    Hi Folks,
    I want to add a button near to JFrame's Minimize Button(On the title bar). How can i do it ? Should i extend RootPaneUI and add custom button ? Any other easy ways to do this ?
    If anyone provides me Sample Code how to do it, It is much Appreciated.
    Thanks,

    There's no easy way to achieve this. You'll have to provide a RootPaneUI delegate with a custom title pane implementation. There, you'll have to provide a custom layout to position your button. In addition, this approach will not work on look-and-feels that do not support decorated mode (such as Windows or GTK) since under such LAFs the title pane always comes from the OS.

  • Add new button on title bar of JFrame

    how can i add new button (like minimize, maximize and close) on title bar of JFrame.
    actually i want a new button for system try icon. if user click on this button JFrame will hide and system try icon will be visible

    Hi,
    Check out this Thread.
    Hope that help,
    Jack

Maybe you are looking for