Positioning items in a frame

Can someone help me move the AM in my program so that it appears under the time. Also, does anyone know how to put zero,s on the clock when you have single digit numbers, e.g 10:01:03 instead of 10:1:3. Thank You!
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.JLabel;
class Grid extends Frame
{   static PrintWriter screen = new PrintWriter(System.out,true);
int hours, mins, secs, variable;
Calendar t = Calendar.getInstance();
final long DELAY = 1000;
JLabel timeLabel;
JLabel varLabel;
public Grid()
{   setLayout(new GridLayout(1,3));
hours = t.get(Calendar.HOUR_OF_DAY);
mins = t.get(Calendar.MINUTE);
secs = t.get(Calendar.SECOND);
variable = t.get(Calendar.AM_PM);
if(variable == 0)
varLabel = new JLabel("AM");
else
varLabel = new JLabel("PM");
timeLabel = new JLabel(hours+":"+mins+":"+secs);     
this.add(timeLabel);
this.add(varLabel);
private void pause(long DELAY){
try{
Thread.sleep(DELAY);
}catch(InterruptedException ie){System.err.println("Thread.sleep() error)" +ie);}
public void update()
{while(true)
{pause(DELAY);
Calendar c = Calendar.getInstance();
hours = c.get(Calendar.HOUR_OF_DAY);
mins = c.get(Calendar.MINUTE);
secs = c.get(Calendar.SECOND);
variable = c.get(Calendar.AM_PM);
if(variable == 0)
varLabel.setText("AM");
else
varLabel.setText("PM");
timeLabel.setText(hours+":"+mins+":"+secs);
class Clock
{ public static void main(String [] args)
{ Grid g = new Grid();
g.setSize(300, 300);
g.setTitle("Digital Clock");
g.setVisible(true);
g.addWindowListener
(new WindowAdapter()
{public void
     windowClosing(WindowEvent e)
     {System.exit(0);}
g.update();
}

see http://java.sun.com/j2se/1.4.2/docs/api/java/text/NumberFormat.html for information on Number Formatting (alternatively you could simply check if your digit is < 10 and add a 0 manually)
see http://java.sun.com/docs/books/tutorial/uiswing/layout/using.html to learn more about java layout managers (to specify which component should be placed where)

Similar Messages

  • Adjust Slideshow (autoviewer) position withih a page frame

    Can anybody tell me...
    Once you've created a page frame how do you position the slideshow or item within that frame? which file affects it, and what setting?
    Example
    http://web.mac.com/coreydee/iWeb/DEMO/Photo%20Page.html

    You'll basically have to figure out what the minimum dimensions are for the slideshow you want and then make your textbox/iframe dimensions at least as big. Think of the textbox/iframe as a mask or a cutout through which your slideshow is being displayed. If the slideshow is bigger than the cutout, then parts of it will be cutoff.
    The original AutoViewer files should be completely scalable to whatever dimensions you choose. But if you use iPhoto Export, it may disable this feature. What you can do is to use something else to produce your AutoViewer slideshow, like WebExport ( http://mountainmandan.net/webexport/ ) which purportedly leaves the scaling capability intact. Or you can go to http://www.airtightinteractive.com and download the original AutoViewer files and then replace the following files with the ones iPhotoExport gives you...
    gallerydata.xml
    images folder
    Here's an example of the scaling...
    This is the displayed page with the iframe...
    http://web.mac.com/jwtseng/iWeb/kate/MyWorld/526EAB19-F722-4899-8D92-43849B193C6 1.html
    And this is the direct link to the slideshow...
    http://homepage.mac.com/jwtseng/playground/
    Try dragging the browser window smaller and larger on the slideshow page to see the automatic scaling capabilities of AutoViewer (and most Flash content).

  • How to make the graph follows the position of the video frame

    Hai..
    I want to open the video (. avi) and graph together in one VI.. The videos and graphs can be controlled (forwarded or rewind) in the desired position.. However, the graph should follow where's the position of the video frame..   The graph generated from the data in excel, after reading data, then there is the processing of signals, such as filter, mean, find the peak, etc.. After that the result will appear in the graph..
    Until now, I've been able to display video and graph.. I'm trying to use WMP and also IMAQ..
    Because I want to show the position of the graph or signal when the video plays, I was making a cursor or a line on a graph that follows the position of the video..
    First, I'm trying using WMP.. I can forward and rewind video using WMP, after that I make a cursor on the graph and the position of cursor I put in the position video.. And then when I run the program, the signal that arises from the right, but the cursor in the graph follow the position of the video (the cursor appears on the left) different side with the signal..
    I also tried using IMAQ when I tried to use the video controls, so the video can be forward or rewind using the slide, and I made a graph control to follow the video.. But the video isn't playing, it just show only images or frame in the video..
    Can we create a graph that can follow the position of the video? (graph can be in forward and rewind just like with video)
    I've tried many ways but until now have not been successful.. can someone help me?
    Any help is greatly appreciated thank you.

    This should do pretty much what you want, assuming that a slider is how you are controlling your video position. You are going to have to play around with it a little but it should give you the basic idea.
    Attachments:
    Slider.vi ‏35 KB

  • Anchored page item in chained frames

    Hi all,
    I'm using an "anchored object" page item with custom positioning, x reference is relative to the right border of the frame. The anchor is in a preceding paragraph (could be multiple lines away) in order to enable text wrap around that object. We recently have turned to use multiple chained frames. When the anchor is close to the bottom of one frame, this causes the object to show up below that frame rather than to follow its imaginary reference line, where it used to be in a single frame.
    Short from writing a script or plugin to do the adjustments, did I miss any built-in way to anchor objects so they follow the text flow of their surrounding (rather than their anchor) across frame breaks, and still allow for text wrap and frame relative x position?
    Version in use is CS4, but I'd also like to hear if CS5 has improved in this regard.
    Thanks,
    Dirk

    Dirk Becker  wrote:
    Hi all,
    I'm using an "anchored object" page item with custom positioning, x reference is relative to the right border of the frame. The anchor is in a preceding paragraph (could be multiple lines away) in order to enable text wrap around that object. We recently have turned to use multiple chained frames. When the anchor is close to the bottom of one frame, this causes the object to show up below that frame rather than to follow its imaginary reference line, where it used to be in a single frame.
    Short from writing a script or plugin to do the adjustments, did I miss any built-in way to anchor objects so they follow the text flow of their surrounding (rather than their anchor) across frame breaks, and still allow for text wrap and frame relative x position?
    Version in use is CS4, but I'd also like to hear if CS5 has improved in this regard.
    Thanks,
    Dirk
    Hi, Dirk:
    Some time ago, I think I found that the info here: http://www.adobepress.com/articles/article.asp?p=1324259 put me on the right path. IIRC, it has something to do with the position where the anchored object is inserted, which I think is at the beginning of the paragraph (again, IIRC I'm not rereading the article now.)
    HTH
    Regards,
    Peter
    Peter Gold
    KnowHow ProServices

  • How can I change the position of an entire frame on the timeline?

    As I've posted before, I'm very new to flash and am
    incredibly green. I've done HTML/Dreamweaver work in the past, but
    I had something thrust into my lap that was a bit more complex than
    I expected! :)
    Anyway, the person that set up the flash document before did
    not do the best job organizing frames. The entire document is a
    compartmentalised site. So you click on the links to the left, and
    it displays the appropriate linked frame. I assume this is a fairly
    standard way of doing things?
    Anyway, that said...
    What I want to do is put these frames together, in proper
    order, within flash. I have tried "cutting" the frames, but that
    leaves a weird piece behind, and I can't find a way to "insert" the
    cut frames back into the timeline.
    Is there no option to just move the frame backwards/forwards
    in the timeline?
    Am I asking the right question?
    Thanks so much in advance :)
    Nick

    you can click once on the frame (or click-drag a group of
    frames) to select them, then click-drag the frame or group to a new
    position. one can also select the frame, right-click (ctrl click
    mac) and select 'copy frames' then you can right click select
    'paste frames' as well although this will 'copy' them and not
    'remove' them from that position.

  • [CS3 JS] Positioning items in menus

    Hi,
    I can add items to menus but do not know how to control their position.
    var myMenuSeparator1 = myFileMenu.menuSeparators.add();
    var myScriptMenuItem3 = myFileMenu.menuItems.add(myScriptAction3);
    How do I put my menu items where I want.
    Thanks
    Simon Kemp

    Thanks,
    This helps a bit.
    What do I use for "SomeScriptMenuItem".
    I have tried...
    var myScriptMenuItem3 = myFileMenu.menuItems.add(myScriptAction3, LocationOptions.AFTER, "User...");
    var myScriptMenuItem3 = myFileMenu.menuItems.add(myScriptAction3, LocationOptions.AFTER, User);
    var myScriptMenuItem3 = myFileMenu.menuItems.add(myScriptAction3, LocationOptions.AFTER, 24);
    I want my menu item to appear after "User..." in the file menu.
    Thanks

  • Pages loose item persistence in frames

    I have these pages that branch to each other. This works fine, except when the HTMLDB pages are part of an intranet app and actually rendered inside a frame. When this happens, then my page cache is cleared even though I do not explicitly clear it with the URL argument. They transition to the correct pages within the frame, just the items are now cleared.

    The pages are public. I am using this code to process an insert and then return to the calling previous page:
    declare
    l_items varchar2(4000);
    l_values varchar2(4000);
    begin
    if :REQUEST = 'CREATE_NEW' then
    insert into hr.dwh_discussion(parent_id,subject,topic_text,author,category)
    values (:P26_PARENT_ID,:P26_SUBJECT,:P26_TEXT,:P26_AUTHOR,:P26_CAT);
    htmldb_application.g_page_text_generated := true;
    case :P26_RETURN_PAGE
    when '22' then
    owa_util.redirect_url('f?p=110:22::::26');
    when '23' then
    l_items := 'P23_ID,P23_ID_STATIC,P23_CONTENT_ID';
    l_values := :P26_ID_STATIC||','||:P26_ID_STATIC||','||:P26_PARENT_ID;
    owa_util.redirect_url('f?p=110:23::::26:'||l_items||':'||l_values);
    else
    null;
    end case;
    end if;
    end;
    If I leave out the items/values list from the URL, then page 23 will clear all its items when these pages are in a frame. If I leave off the items/values from the URL but the pages are on top, not in a frame, then the page 23 items are not cleared.
    I transition to page 26 from page 23 with these items/values in the URL:
    items - P26_SUBJECT,P26_PARENT_ID,P26_RETURN_PAGE,P26_ID_STATIC
    values - re - &P23_SUBJECT.,&P23_CONTENT_ID.,23,&P23_ID_STATIC.
    I am using a custom LDAP authentication scheme that makes a call to a PL/SQL function:
    return hr.util_ldap.connectAuthenticate;
    function connectAuthenticate(p_username in varchar2,p_password in varchar2)
    return boolean
    as
    l_retval PLS_INTEGER := -1;
    l_ssl PLS_INTEGER := -1;
    l_session DBMS_LDAP.session;
    l_attrs DBMS_LDAP.string_collection;
    begin
    DBMS_LDAP.use_exception := false;
    begin
    --connect to LDAP and authenticate
    l_session := DBMS_LDAP.init(hostname => g_host,
    portnum => g_port);
    exception
    when others then
    null;
    end;
    l_retval := DBMS_LDAP.simple_bind_s(ld => l_session,
    dn => g_pre||p_username||','||g_ldap_user_base,
    passwd => p_password);
    if l_retval = 0 then
    -- Disconnect from the LDAP server.
    l_retval := DBMS_LDAP.unbind_s(ld => l_session);
    return true;
    else
    return false;
    end if;
    exception
    when others then
    return false;
    end connectAuthenticate;

  • Tabbing (Next Navigation Item) to different frames/datasets on a canvas?

    How can I set the tab order to tab between frames on my form? In the properties palette for an item, the Next Navigation Item field, I can only choose items in the same dataset. What if I wanted to mix and match the fields from say 2 different datasets so they show up together in a frame and have consistent tabbing?
    Also, I have set up a join relationship between 2 datasets on a canvas but when I insert record it only inserts 1 set and not the info from the other but when I query info that was already in the dataset it shows up fine on both sets??? Please help. Thanks alot

    To achieve cross-block navigation, here is what I do:
    For forward tabbing as well as automatic skipping to same field, create a hidden navigable item following the item, and on that item, create a when-new-item-instance trigger with a go_item command. (For hidden navigable, it must be on the same canvas. Just set its height and width to zero.)
    For shift-tab (reverse navigation), use a key-prev-item trigger on the second item with a go_item back to the first item.

  • Change X, Y position of a text frame based on some conditions

    Hi All,
    I am trying to re-position the Y position alone of all text frames in a documennt if that text frame has certain Y position. Here is the code I tried.
    It works, but, it place all the text frames in to the given myTextFrame.move ( ["216.425 pt","54 pt"] ); one on another. Whereas, I need to change Y position of only the text frames with the following conditions.
    The conditions are:
    If X="216.425 pt" AND Y="103.89 pt", change to X="216.425 pt" and Y="54 pt"   OR
    If X="216.425 pt" AND Y="78.945 pt", change to X="216.425 pt" and Y="54 pt"    OR
    If X="216.425 pt" AND Y="79.157 pt", change to X="216.425 pt" and Y="54 pt"    OR
    If X="213.425 pt" AND Y="486.647 pt", change to X="216.425 pt" and Y="54 pt"    OR
    If X="213.425 pt" AND Y="74.409 pt", change to X="216.425 pt" and Y="54 pt"   
    Please help me on this to add the above conditions into the following code and reposition only the text frames has the above said XY positions.  Is there anyother way other than "move" statement?
    var myDocument=app.activeDocument;
    var myPages=myDocument.pages;
        for(p=0;p<myPages.length;p++) {
        var allTextFrames=myPages[p].textFrames;
            for (s=0; s<allTextFrames.length; s++) {
                        var myTextFrame = allTextFrames[s];
                        var myTextFrameBounds =  myTextFrame.geometricBounds;
                        var properly_aligned = "54 pt";
                            if ((myTextFrameBounds[0] = "103.89 pt") && (myTextFrameBounds[1] ="216.425 pt")) {
                                myTextFrame.move ( ["216.425 pt","54 pt"] );

    Hi Jongware,
    Thanks for your reply.
    I have modified the code little bit after referring one of the post. Here is the updated code. It is working fine for the whole number (var oldposition1) as input value and does not work for decimal values (var oldposition2, var oldposition3, var oldposition4 and var oldposition5). However, it repositions the frames with decimal values (newposition1, newposition2 and newposition3). I am facing problem with the decimal input values for original position of text frames. Is there any other way to give decimal values as input as my document comes with these decimal values as X, Y position.
    var oldposition1 = [216, 103] // original position, upper left corner
    var oldposition2 = [216.425, 78.945] // original position, upper left corner
    var oldposition3 = [216.425, 79.157] // original position, upper left corner
    var oldposition4 = [213.425, 74.409] // original position, upper left corner
    var oldposition5 = [213.425, 486.647] // original position, upper left corner
    var newposition1 = [216.425, 54] // new position, upper left corner
    var newposition2 = [36, 54] // new position, upper left corner
    var newposition3 = [216.425, 437.4] // new position, upper left corner
    var myObjects = app.activeDocument.pageItems.everyItem().getElements();
    for (var i=0; i<myObjects.length; i++){
        if (Math.round(myObjects[i].geometricBounds[1])==oldposition1[0]&&Math.round(myObjects[i].ge ometricBounds[0])==oldposition1[1]){
            myObjects[i].move(newposition1);
        else if (Math.round(myObjects[i].geometricBounds[1])==oldposition2[0]&&Math.round(myObjects[i].ge ometricBounds[0])==oldposition2[1]){
            myObjects[i].move(newposition1);
        else if (Math.round(myObjects[i].geometricBounds[1])==oldposition3[0]&&Math.round(myObjects[i].ge ometricBounds[0])==oldposition3[1]){
            myObjects[i].move(newposition1);
        else if (Math.round(myObjects[i].geometricBounds[1])==oldposition4[0]&&Math.round(myObjects[i].ge ometricBounds[0])==oldposition4[1]){
            myObjects[i].move(newposition1);
        else if (Math.round(myObjects[i].geometricBounds[1])==oldposition5[0]&&Math.round(myObjects[i].ge ometricBounds[0])==oldposition5[1]){
            myObjects[i].move(newposition3);

  • Framing an item using the Frame Chaeel - PS CS5

    Under Window there is Actions and one of the actions is Frame Channel. When I click Fram Chanel nothing happens but it does expand and some stuff is listed below it. Each time I double click one of the listed items again nothing happens. I was wondering what the Frame Channel was to do. Maybe it just doesn't do anything in those trial versions of Photoshop Extender.   I am using thePS Extender CS5 trial.
    Please explain the correct use of the Frame Channel, 

    I finnally can frame both photos and graphics.  I even figured out how to get a colored frame.  Just choose Fill and the color will appear like the example below.  However, for the life of me I can not figure out how to get the white out of the saved item.  I did one but not sure how I did it.
    It is hard to tell since the background of this board is white but there is a large white background when I open in PS,
    The best one is this Eagle.

  • BUG - layer position moves when switching frames in timeline

    When creating a new layer and positioning it in the active frame, the position is sometimes wrong when returning to that frame.
    1. create multiple frames in the timeline
    2. create a layer and position it somewhere in the image
    3. view another frame
    4. return to the original frame and the position has changed
    Positioning the layer again seems to work, it doesn't move by itself when moving between frames, but remains in position.

    Same as your otehr post: Screenshots!
    Mylenium

  • How to set particular comboBox item selected once frame loaded?

    I have a comboBox with all the items with data and labels
    (set in the parameter of comboBox). However, I can't set the
    particular comboBox item to display when the frame entered, like
    this:
    var listenerObject:Object = new Object();
    listenerObject.load = function(eventObject:Object) {
    _root.cb.selectedIndex=3;
    _root.cb.addEventListener("load", listenerObject);
    What's wrong?

    You cannot use the load event on a frame, because by the time
    the code runs the component has already been loaded. But what you
    can do is set the properties directly in that frame wihtout the
    need of a listener. Simply write this,line instead of all the
    previous code:
    _root.cb.selectedIndex=3;

  • Selecting items in a frame without selecting frame (HTML)

    i have a web page with two frames for two jsp's;
    and i'd like to be able to tab elements in those frames without passing the focus to a frame in whole/
    i tried to set a property <frame tabindex=-1> but
    in this case all the frame becomes inaccesisble
    if this propery isn't set i can tab until a whole frame becomes selected - that is a birder around it appeares///
    what should i do then????

    i've jjust solved this problem!
    i needed tabIndex = "-1" in a body tag of a page!!!

  • Button item's target frame property creates a problem

    Hi All
    I have created a button in one page.set its destination property and set target frame property to _blank
    When i run this page in jdeveloper,it works fine.
    when i deploy that page in Client's env,it says that _blank is undefined.
    Is there any parameters we have to set it to enable target frame property.
    Is there any other way to open a page in another window?
    Any pointers will help me a lot.
    Thanks
    Hitesh

    I am facing the same problem. Any solution ??

  • Is it possible to change the position of the FMS chat component in different frames?

    I have developed an application using various FMS2 Communication Components.  One of those is the Chat component.  The application has various display modes (minimized, normal, maximized).  These display modes require the Chat component instance to be resized and repositioned on the screen.  I took the approach of having a separate frame represent each of the display modes.
    The problem I am having is that the Chat component won't resize or relocate from the size/position on the first frame.  The visual layout isn't respected, and calling this.moveTo(x,y) has no effect either.  The only way I can get the component to have the desired behavior is to comment out the last line of the Chat component actionscript:
    this.setSize(this._width,this._height);
    Of course, by doing this, the Chat component appearance is horrible.  I have narrowed this down to two set assignments that occur within the setSize function.  If either one, or both is called, then the component gets "stuck".  The assignments are:
    this._xscale = 100;
    this._yscale = 100;
    Anybody else run into this and come up with a solution?

    Try chat_mc._height and chat_mc._x instead.

Maybe you are looking for