Painting within a frame

Can anyone help, with this query.
I am writing a simple program that executes the paint method to draw in a window, for example an Oval. But as an application i.e frames the paint method is never called. I have even written the most basic app to see if the paint method is called and it never is. When I convert the same code to an applet the paint method is called as soon as the applet starts, I thought this was the same with a container.
The simple code that I am writing is as follows:
import java.awt.*;
public class tester extends Frame {
public static void main(String args[]) {
new tester();
public tester() {
Frame newWin = new Frame("Test");
newWin.setSize(200, 200);
newWin.setVisible(true);
public void paint(Graphics g) {
g.drawOval(20, 20, 50, 50);
I thought once the window loads the paint method is automatically called. Any assistence would be appreciated.

Hi,
1. you have a paint method, but it is not the paint method which is used by te jframe you try to display...
2. change this method:
public tester() {
super("test");
setSize(200, 200);
setVisible(true);
(3. use JFrame (import javax.swing.*;))
Hope this helps,
Rgds

Similar Messages

  • Text wrap for a paragraph: How to define the width of a Text box /  active text area? I simply need a longish text to wrap within the frame!

    Hello, I've been searching for a good while in the forums now, but have found no solution or real mention of the problem – I hope some of you can help.
    I want to very simply layout a text between scenes, a slightly longer text that wraps within the frame margins. Here's an example of how I want it to look:
    Now, I couldn't for the life of me get the Custom Text to behave like that, as there are no parameters to set for the width of the text area. The Text Size, yes, along with the Tracking, Baseline and all that, but the width of the text box, no. The above was created by customizing one of the other Text Generator presets that happened to be left aligned.
    However, this preset has a fade in/fade out transition, which I do not want. There's no way to remove this transition as it seems integrated into the Text Generator (meaning they are not really presets, but separate kinds of Text objects? Very silly.)
    So I am asking you: Is there any way to get the Custom Text generator to behave like that? Just a text paragraph as above. Below you'll see all I can manage with the diffferent Custom Text parameters. Any kind of repositioning and resizing of the text just changes the position and size of the frame – but the actual text items are just cropped off where they extend out of that frame. Apparently the bounding box for the text is just some default length, and I can't find any way to adjust the width. See below my different attempts.
    The same text pasted into a Custom Text generator clearly extends outside the frame:
    Here Transform just moves – or resizes – the video frame that the Text Box exists inside:
    The Crop gives similar results, and of course Distort doesn't get me closer to what I need, either. There should be simply a Text Box Width parameter to set somewhere, but if it exists they have hidden it very well. How do you do it?
    Thanks for any help, this is a silly problem, but one of now many trivial problems that amount to me growing quite dissatisfied with FCPX. Hopefully I've just overlooked something.
    All the best,
    Thomas

    Thomas...same kind of crap here.
    I used Custom Text - entered a sentence, hit return, entered another.
    Set to 72 pt.
    The default alignment is centred - I want left aligned text...the text start point stays at the centre of frame and the sentence runs off the edge of the bounding box.
    There is no settings in the Text or Title inspector dialog to correct that!
    Using Transform will not sort it!

  • Duplicate spread causes some text to shift within its frame

    Hi,
    Indesign CS5 problem:
    When I duplicate the first page of my working document some text shifts vertically within its frame on the duplicate page.
    The same thing happens if I copy the text box and paste in place, the shift also occurs.
    This is a small grab of the file with the 1st page on the left and the duplicate page (or paste in place) on the right.
    Its driving me nuts, any help much appreciated.
    Cheers
    Dave

    Aha, you have got somewhere then!  Something is causing that type to shift, why it isn't in your original doesn't matter, the idml one is "cleaner" and now the behaviour makes sense in that both frames are bahaving the same.  There must be something somewhere, I assume you've checked the baseline shift in the control panel?
    If you are sure it's nothing like that it's time to replace your preferences, see the link here.

  • Editing timelapses in Lightroom- looks very different if there´s a small change within the frame

    Hi
    We´re having some serious issues with editing timelapses in Lightroom (5.6). What seems to happen over and over again, is that if there´s a small change within the frame (such as a bird flying past, people walking), the editing result varies greatly compared to the previoius frame. It´s easiest to understand what I mean by viewing the examples below.
    Here there´s one picture without a boat in the frame, and a few seconds later there´s a boat in a small part of the frame. The camera is set to full manual, and the two JPGs which show the unedited pictures shows that the background and sky in both pictures look exactly the same. However, after pasting the same editing setting on both pictures, the picture with the boat looks vastly different (shadow areas are much darker). It´s the same result weather it is a white boat, a black bird or a person walking in/out of the frame. The picture gets much darker, and leads to some serious flicker in the timelapse which can be impossible to get rid of.
    I assume that as there´s a small change in the histogram when the boat enters the frame, this change affects what Lightroom thinks of as shadows/highlights on so on? The example below has some heavy editing applied (shadows up, highlights down, clarity). You can see the settings that have been adjusted in the screenshots below. Does LR change what it considers shadows/highlights based on the histogram, or are there standard settings? If this is the case, it would be much better for timelapsers if Lightroom had standard values for what is considered shadows/highlights, so that two pictures where the only difference is a person walking on the street or not, would look the same with the same editing settings applied. What I find strange if LR works like I´m asking here, why does the picture get darker whether it is a white boat or a black bird changing the histogram slightly. Shouldn´t they then have the opposite effect of each other?
    Any ideas what is causing the difference, and what I can do about it? Thanks!

    In these forums you are only talking to other users like yourself, not Apple. Be sure to repost your info in the channel Apple has set up for it:
    http://www.apple.com/feedback/imovie_iOS.html

  • How do I fit a picture within a frame layer?

    How do I fit a picture within a frame layer?

    If your images are an aspect that does not fit easily into
    a standard video frame, you might need to scale up
    (or preferably down) and reposition your images to fit.
    What are your image dimensions?
    What are your Sequence settings?
    What is the intended destination for your finished video?
    Premiere Pro / Motion: position, scale, and rotate a clip
    http://help.adobe.com/en_US/premierepro/cs/using/WSC7A162B6-6EF1-49e1-8622-8127366710BB.ht ml
    How do I choose the right sequence settings?
    http://www.video2brain.com/en/lessons/how-do-i-choose-the-right-sequence-settings
    Also, make sure you're running the most current update (CS6.0.5).
    Within Premiere:  Help > Updates...

  • I need to insert a fade to black within a frame of footage.

    I need to insert a fade to black effect within a frame of footage. The raw footage simply cuts to black, and I want to edit it so that it fades out within the same frame. Thanks for helping!

    cass516 wrote:
    this method sounds like a PAIN but of course i have no choice but to try it.  Why would Pages make such a simple thing so troublesome?  in other programs, you simply click 'insert file'.
    The only thing odd about Pages' Insert file is that it doesn't do its own format.
    You obviously think that MsWord is "The Norm" but I found really odd things that it won't do. To the point I, like others here, can't be bothered trying to drive the Word square peg into the Mac round hole.
    Mostly Pages works by drag and drop, I'm puzzled why that doesn't work with the thumbnails. But then there are quite a few oddities in every program. Pages is far from an exception.
    Peter

  • Targeting Webhelp within a frame set

    Our Webhelp runs within a frame set. The lower frame displays
    a copyright note and the upper frame (named, say, abc) displays the
    actual webhelp - no problem so far.
    The problems arise when I try to reference the webhelp in toc
    entries. When I include target="_top" then all is fine, except of
    course that the lower frame dissappears and the webhelp is displayd
    on top level which I dont want. But when I include target ="abc"
    (or whatever the frame name is) then the target attribute is simply
    ignored by the webhelp script. BUT, if I include target ="def" - an
    undefined frame name - then a new browser window is opened
    correctly. The target attribute is only ignored when is addresses
    an EXISTING frame name.
    Any ideas on this or is it simply though luck?

    Hello Robert -
    Why not include the copyright note into the top-right frame
    of RoboHelp by the "Powered By" - or try what we do and have the
    copyright info as part of the "Powered By" pop-up (we changed the
    name to "About IRIS" where IRIS is the project name).
    Regards,
    GEWB

  • [JS] CS4 How to position a graphic within a Frame

    I have a JS script that I am converting from CS3 to CS4 and I am finding that the behaviour for positioning a graphic within a frame has changed.  I have code that sets the geometric bounds of a graphic to a negitave value within the frame, within CS3 this works great.  However using the same code on CS4 to set the geometric bounds does not produce the same result.  The graphic is always placed at 0,0 and it ignores the negitive top and left values supplied.
    Does anyone know what has changed with the geometric bounds of a graphic within a recrangle frame?  How would I set the position of the graphic within the frame since setting the geometric bounds does not seem to work any longer.
    Thanks,
    Sheldon

    I have yet to determine why the behavior is different from CS3 to CS4 and how to correct the positioning within CS4.  To help explain the problem further I have included a sample script which demonstrates the problem.  I have run the script on both CS3 and CS4 and included screen shots of the results when the resulting INDD file is opened.  Could someone help explain why the position of the image is wrong in CS4 and what I can do to correct the problem?
    Here is the sample script ...
    for(i=app.documents.count()-1;i>=0;i--){app.documents.item(i).close();}
    app.textPreferences.useOpticalSize = false;
    app.textPreferences.typographersQuotes = false;
    app.textImportPreferences.useTypographersQuotes = false;
    app.taggedTextImportPreferences.useTypographersQuotes = false;
    app.pasteboardPreferences.minimumSpaceAboveAndBelow = "300p";
    app.textFramePreferences.firstBaselineOffset = FirstBaseline.ascentOffset;
    app.colorSettings.cmsSettingsPath = File("C:\\etc\\Friesens_Yearbook_Custom_Color_Settings.csf");
    app.marginPreferences.top = '24pt';
    app.marginPreferences.bottom = '48pt';
    app.marginPreferences.left = '36pt';
    app.marginPreferences.right = '36pt';
    var doc = app.documents.add();
    doc.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.points;
    doc.viewPreferences.verticalMeasurementUnits = MeasurementUnits.points;
    doc.documentPreferences.pageHeight = 792;
    doc.documentPreferences.pageWidth = 612;
    doc.documentPreferences.pageOrientation = PageOrientation.portrait;
    doc.documentPreferences.pagesPerDocument = 2;
    doc.documentPreferences.facingPages = true;
    doc.sections.firstItem().continueNumbering = false;
    doc.sections.firstItem().pageNumberStart = 2;
    var pg = doc.pages.item(0);
    var frm = pg.rectangles.add();
    frm.geometricBounds = ['200.5pt','200.2pt','447.8551pt','415.5206pt'];
    try{frm.place (File('c:\\test.jpg'), false);}catch(err){};
    if(frm.graphics.count() > 0) {frm.graphics.firstItem().geometricBounds = [frm.geometricBounds[0]-147, frm.geometricBounds[1]-49, 407.04+frm.geometricBounds[0]-147, 271.68+frm.geometricBounds[1]-49];};
    var objStyle = doc.objectStyles.add();
    objStyle.enableStroke= false;
    objStyle.transparencySettings.blendingSettings.opacity = 100;
    frm.applyObjectStyle(objStyle, true, true);
    frm.rotationAngle = 59;
    doc.label = '824203.indd';
    doc.packageForPrint('c:\\test\\824203\\', true, true, true, true, true, false, '', false, false);
    for(i=app.documents.count()-1;i>=0;i--){app.documents.item(i).close();}
    The line that I highlighted is the one that adjusts the images position within its frame.  It uses a formula to determine the exact position relative to the containing frames position.  This is why you will see the calculations to determine the geometric bounds.
    Here is the result of the script using InDesign Server CS3, notice the position of the image based on the 'Direct Selection Tool' highlight area (this is the desired result):
    And, here is the result after running the script against InDesign Server CS4:
    As you can see the Image is placed at the lot left corrner of the frame which is wrong.  Any insight into the diffrences in the behavior would be appreciated.
    Thanks

  • Need help with paint() within applet

    Hi,
    I am having some problems in using the paint() method within an applet.
    I need to use drawString() in the paint() method.
    However, I discovered that when i used drawString() in paint() method.
    It clears the background which has other GUI components wipe out.
    Pls help, thanx
    Sample code:
    public class watever extends javax.swing.JApplet {
    //initialize some components and variables
    public void init() {
    //adding of components to contentPane
    public void paint(Graphics g) {
    g.drawString("The variable is " + sum, 80, 80);
    }

    super.paint(g) the paint method draws the components to, so if you override it and then never tell it to draw the components they don't get drawn.

  • Centre aligning images within picture frame using XML file

    Hi
    I am using a flash file that uses an xml file to upload a
    series of images one at a time into a picture holder.
    There are two different widths of the images. The height is
    always the same. Is it possible to set this up so every image that
    the xml file calls is centre aligned within the picture frame.
    At the moment when using the xml file to load the image it
    always left aligns the image when it brings it into the picture
    frame even if you change the alignment to centre align within in
    the align panel.
    Does anyone have a suggestion why this is happening or how to
    fix it?
    Thanks for the help

    You're welcome. Pleased it worked.
    All it does is use the MovieClipLoader class to load the
    images into your holder_mc. Because loading takes time, and because
    you can't check or adjust the size or position of images until they
    have loaded, the MovieClipLoader class gives you a handy option to
    run some code whenever its finished loading something you told it
    to load.
    That's what the addListener instruction does... it says
    whenever myLoader has something new to tell me about the status of
    the load requests I ask it to do... make it run some related code
    in the listener object (which is called loadListener in this
    code... it could equally be called something else). You 'listen'
    for different events or updates of status. All I 'listened' for
    here was the onLoadInit event.
    The onLoadInit is the 'final' status update after loading. It
    occurs when something has loaded and its properties are accessible
    (_x, _width etc). The target_mc that is an argument for the
    loadListener.onLoadInit is a reference to the clip that was loaded
    into.
    The best way to learn about this stuff is probably to read up
    on MovieClipLoader in the livedocs and try google to see if there's
    an online tutorial somewhere. Then give it a try yourself in
    another new fla.
    cheers
    GWD

  • All photos suddenly appear "black" within their frames.  Help!

    Between importing photos from my camera and quitting, then reopening the program again a few days later, my photos all now suddenly appear completely black (the same color as the window's background). In every photo folder I have, the correct number of photos appear. They are even oriented the way they would be, except, of course, that the contents of each photo (highlighted in blue, or with the usual thin white frame) is blank. Slideshows show blanks (black screen) with music playing as usual. The iPhoto library still contains the photos, with thumbnails, and I can open the files and view the photos in the iPhoto library using Preview.
    Why can't I see the photos within the program itself???

    Lude:
    Welcome to the Apple Discussions. Are you referring to the thumbnails or the full sized image in the Edit window?
    It's an issue in iPhoto 6 that some fixed by updating to 10.4.6 using the COMBO updater followed by a repair of disk permissions with Disk Utility.

  • Hyperlinks within scrollable frames

    I'm trying to get hyperlinks within a scrollable text frame to work but it's not working properly in the content viewer. Is it possible to do them within scrollable content, and if so, is there a certain technique that works best? Thanks!

    Sorry -- I've created a scrollable content layer that works properly, just with text scrolling down. I've selected the text and created a hyperlink using the hyperlinks panel (that works for the text in non-scrollable frames). When I view the issue in the Content Viewer on the iPad, the hyperlinks outside the scrollable frames work fine and open, but those within the scrollable frames do not. Is there a specific way I should be creating the hyperlinks within the scrollable frames that I'm not doing correctly? Thanks.

  • My pages stopped scrolling with cursor keys after upgrading to 5.0, the cursor moves WITHIN html documents and "jumps" from frame to frame and character to character within the frame.

    Recently, I noticed that google search pages stopped scrolling. There is an "right arrow" at the beginning of each link. When I press the cursor "up/down" arrow on the keyboard, the cursor jumps from link to link. Also, while on any html webpage, the cursor moves one character at a time (left / right arrow) and one line at a time (up/down arrow) until the end of that frame is reached, it then jumps to the next frame.

    You may have switched on [http://kb.mozillazine.org/accessibility.browsewithcaret caret browsing].
    You can press press F7 (on Mac: fn + F7) to toggle caret browsing on/off.
    * Tools > Options > Advanced : General: Accessibility: [ ] "Always use the cursor keys to navigate within pages"
    * http://kb.mozillazine.org/Scrolling_with_arrow_keys_no_longer_works
    * http://kb.mozillazine.org/Accessibility_features_of_Firefox

  • Jump within scrollable frame?

    Hi DPS community,
    I'm creating a company directory with 250 names and I would like a smooth scrolling experience (also open to other suggestions you may have!) and I would like to ask if its possible to create buttons that jump to a specific areas within the scrollable frame? Similar to the way iOS's Contacts work where the letters are static along the scrollable frame but tapping a letter will jump to the corresponding area? (image attached)
    Thank you for any tips or suggestions.
    -Dan

    That ability does not exist in DPS using InDesign scrolling frames. You
    could do it as HTML and use a Web Content overlay to do it, though.

  • Paint component without frame

    Hallo!
    Do anybody know how to paint a component without using a frame?
    I have a panel with some components, where i do some custom painting.
    What I want to do is: Create an image from my panel to store it on the harddisk as gif or jpeg.
    How can I paint my panel without using a frame like this:
    JFrame f = new JFrame();
    MyPanel p = new MyPanel();
    f.setContentPane(p);
    f.setSize(...);
    ----> i dont want this ...
    f.show;
    I also used SwingUtilities:
    Graphics2D g2D = new Graphics2D();
    SwingUtitlities.paintComponent(g2D, f, p, 0, 0, width, height));
    If I only use:
    MyPanel p = new MyPanel();
    p.revalidate();
    p.repaint();
    I can not catch an image from the panel, it is always only gray.

    If I understand well, you want to paint a component that is not visible ?
    You can use a BufferedImage for example :
    int width = 300; // for example
    int height = 200; // for example
    BufferedImage buffImage = new BufferedImage(width,height,BufferedImage.TYPE_INT_ARGB_PRE);
    Graphics2D graphics = buffImage.createGraphics();
    panel.setBounds(0,0,width,height);
    panel.paint(graphics);
    graphics.dispose();
    Now the panel is painted on the image.
    Denis

Maybe you are looking for