HT203521 24 hour calendar

Calendar is now quite seamless, but for those used to a 24hour clock format, it's frustrating that Calendar persists with an am/pm format.
Is it possible to use the 24 hour format in Calendar?

Go to Language & Text and set it to display the system time in 24hr format.
You might need to restart iCal to get it to update

Similar Messages

  • TS4337 How do I stop iCal from automatically converting manually entered times into entries on my hourly calendar?

    I use the monthly calendar view in iCal.
    I enter an event as such: "lunch with mom @ 3" so I can just look at my monthly calendar at a glance and see what time things are.
    In the latest update, it now automatically strips that entry of "@ 3" and converts it to the hourly calendar, which I never use or want to look at, adding a layer of clicking between me and the info I need.
    Is there a way to turn that off? Or do I just need to find a new calendar app to use and/or never update any Apple software again for fear of them changing the features I use?

    Try lunch with mom at 3 instead
    I tried and the text was not stripped and the event was entered at the correct time

  • Pointers needed to create a JSP for week/hour calendar type component

    Hi,
    I am looking to get some pointers on how to create week/hour calendar type component in JSP.
    My application is JSP/struts2 based web application. I need to create a web page where users will see a week hour calendar and for any time slot will enter some information. Each time slot can have different information. For example: Sunday 9:30am to 10:00am - Click on this cell and pop up a dialog for info and save it without refreshing the page. At the end combine all this info for each slot and submit to the server.
    If there is already a component like this is available to use, please point me to that.
    Any ideas are welcome.
    Thanks,
    Developer in need.

    I dont know of an already existing application that can do this. However, here are some ideas on creating your own:
    Create an html table in JSP who's number of rows and columns match what you would find in an ordinary wall calendar for the given month and year. Use the Calander.java class to obtain the number of days in the current month and build the JSP page accordingly (Calendar.java should automatically take care of leap year). You will probably need to add 'next' and 'previous' buttons to the form to retrieve the previous and next month(s) in case the user wants to access previous or future months. Each cell in the table displays that day (example ' 28 '). Notice my convention the first column is usually 'Sunday'.
    Next, determine what to put in each cell. One suggestion is to embed a table in each cell with 48 rows (24 hours in a day, 1/2 hour resolution= =48), and two columns (first column is for time: example: "10:30am to 11:00am", the second column is for the user's appointment message).
    Above that embedded table is the day (example: '28'). If a user has no information in the embedded table, the outer cell will appear to have nothing but the '28' in it.
    Next, how to populate the cell. When the user clicks on the cell, have an onclick event call a javascript function. The function will pop up a new window (a child window) by calling 'window.open( )' (google 'window.open'). In the pop up, show a table with 48 rows, 2 columns that the user can type in a message within column 2. When the user clicks 'submit' button on the pop up, call a javascript onclick function that reads all the message cells. Any cell not empty will populate the corresponding cell (day, rowID, columnID) back on the parent window by calling something like this: window.opener.document.myFormName.myTextField.value = someValue
    (google 'window.opener'). Once this is done, close the child window from that javascript function. By calling 'window.opener', you dont have to refresh the parent window.
    Next, if the user clicks on the parent window cell that is already populated, you will have to pass all theexisting information for that day through the window.open( ) to the child window so the pop up child window will show that preexisting information (that way he can add to the cell or alter it as he pleases).
    Next, after he alters many days on the calender, you have to provide an 'update' button on the parent form so the user saves his changes (write the data to a database record, with his name attached to that record). Note: if he clicks the previous/next button, he will lose any changes unless you also save the information before going to the previous/next page.
    Next, you might want to provide a vertical scroll bar on the table cell if
    the end user has many messages that cant be viewed in the parent cell all at once. Note each cell should be a fixed number of pixels width/height so it shows correctly. Have Fun!

  • Possible to show fewer Calendar hours per day?

    Is there a way to reduce the number of hours Calendar shows each day? 
    My appointments happen between the hours of 8am and 8pm.  But CAL shows all 24 hours each day.  If I have one appointment at 8am, one at 2pm, a third at 4pm and maybe a dinner at 7pm, the page view on iPhone limits my view to one or two of these appointments.  To see others I have to scroll up or down.  Not a big deal but I'd like to see all that day's appointments on one page view.
    Is there a way to do this?

    See Apple's article titled "Controlling when a user can access your network" found at:
    http://docs.info.apple.com/article.html?path=Airport/5.0/en/ap2122.html

  • Java Calendar problem

    Hello
    I have problems with Java Calendar class:
    Problem 1:
    I try to set Java calendar to specific date, but an exception is thrown. Problematic dates are 19210501 and 19420403 (yyyymmdd) at midnight (hour of day = 0, minutes = 0, seconds = 0, milliseconds = 0). Setting other dates between 15000101 and 22000101 work OK. Exception is thrown when calendar calculates new values. Note that exception is NOT thrown if I do not set hour / minute / second fields!
    Problem 2:
    I set Java calendar to specific date A and convert that date to timeInMillis. Then I set this timeInMillis to calendar and convert it to date B. For certain dates A != B. Problematic dates are 19210501 and 19420403 (yyyymmdd) at midnight (hour of day = 0, minutes = 0, seconds = 0, milliseconds = 0). Setting other dates between 15000101 and 22000101 work OK.
    These problems occur if timeZone = "Europe/Helsinki". Problem does not occur if timeZone = "EET" or "GMT".
    Example code of this problem is below:
    ==================
    package z_javaexperiments5;
    import java.util.Calendar;
    import java.util.TimeZone;
    public class CalendarProblem {
    public static void main(String[] args) {
    CalendarProblem main = new CalendarProblem();
    System.out.println( "RunSetCalendars" );
    TimeZone timeZone = TimeZone.getTimeZone( "GMT" );
    main.runSetCalendars( timeZone, 19420403000000000L );
    main.runSetCalendars( timeZone, 19210501000000000L );
    main.runSetCalendars( timeZone, 19210502000000000L );
    timeZone = TimeZone.getTimeZone( "EET" );
    main.runSetCalendars( timeZone, 19420403000000000L );
    main.runSetCalendars( timeZone, 19210501000000000L );
    main.runSetCalendars( timeZone, 19210502000000000L );
    timeZone = TimeZone.getTimeZone( "Europe/Helsinki" );
    main.runSetCalendars( timeZone, 19420403000000000L );
    main.runSetCalendars( timeZone, 19210501000000000L );
    main.runSetCalendars( timeZone, 19210502000000000L );
    Calendar setCalendar1( TimeZone timeZone, long dateTimeYYYYMMDDHHMMSSsss ) {
    Calendar calendar = Calendar.getInstance(timeZone);
    calendar.clear();
    System.out.println( "setCalendar1 timeZone = " + calendar.getTimeZone().getID());
    int year = (int)( dateTimeYYYYMMDDHHMMSSsss / 10000000000000L );
    int month = (int)(( dateTimeYYYYMMDDHHMMSSsss % 10000000000000L ) / 100000000000L ) - 1;
    int day = (int)(( dateTimeYYYYMMDDHHMMSSsss % 100000000000L ) / 1000000000 );
    int hour = (int)(( dateTimeYYYYMMDDHHMMSSsss % 1000000000 ) / 10000000 );
    int min = (int)(( dateTimeYYYYMMDDHHMMSSsss % 10000000 ) / 100000 );
    int sec = (int)(( dateTimeYYYYMMDDHHMMSSsss % 100000 ) / 1000 );
    int mSec = (int)( dateTimeYYYYMMDDHHMMSSsss % 1000 );
    System.out.println( year + "." + (month+1) + "." + day + " " + hour + ":" + min + ":" + sec + "." + mSec );
    calendar.set( year, month, day );
    calendar.set( Calendar.HOUR_OF_DAY, hour );
    calendar.set( Calendar.MINUTE, min );
    calendar.set( Calendar.SECOND, sec );
    calendar.set( Calendar.MILLISECOND, mSec );
    calendar.setLenient( false ); // Reject illegal values
    try {
    calendar.get( Calendar.SECOND ); // Recalc values
    } catch ( IllegalArgumentException e ) {
    throw new RuntimeException("Invalid argument: Cannot convert long to dateTimeYYYYMMDDHHMMSSsss, long = " + dateTimeYYYYMMDDHHMMSSsss + " Exception message = " + e.getMessage());
    return calendar;
    Calendar setCalendar2( TimeZone timeZone, long dateTimeYYYYMMDDHHMMSSsss ) {
    Calendar calendar = Calendar.getInstance(timeZone);
    System.out.println( "setCalendar2 timeZone = " + calendar.getTimeZone().getID());
    calendar.clear();
    int year = (int)( dateTimeYYYYMMDDHHMMSSsss / 10000000000000L );
    int month = (int)(( dateTimeYYYYMMDDHHMMSSsss % 10000000000000L ) / 100000000000L ) - 1;
    int day = (int)(( dateTimeYYYYMMDDHHMMSSsss % 100000000000L ) / 1000000000 );
    int hour = (int)(( dateTimeYYYYMMDDHHMMSSsss % 1000000000 ) / 10000000 );
    int min = (int)(( dateTimeYYYYMMDDHHMMSSsss % 10000000 ) / 100000 );
    int sec = (int)(( dateTimeYYYYMMDDHHMMSSsss % 100000 ) / 1000 );
    int mSec = (int)( dateTimeYYYYMMDDHHMMSSsss % 1000 );
    System.out.println( "Initial dateTime = " + year + "." + (month+1) + "." + day + " " + hour + ":" + min + ":" + sec + "." + mSec );
    calendar.set( year, month, day );
    if ( hour != 0 )
    calendar.set( Calendar.HOUR_OF_DAY, hour );
    else
    calendar.clear( Calendar.HOUR_OF_DAY );
    if ( min != 0 )
    calendar.set( Calendar.MINUTE, min );
    else
    calendar.clear( Calendar.MINUTE );
    if ( sec != 0 )
    calendar.set( Calendar.SECOND, sec );
    else
    calendar.clear( Calendar.SECOND );
    if ( mSec != 0 )
    calendar.set( Calendar.MILLISECOND, mSec );
    else
    calendar.clear( Calendar.MILLISECOND );
    calendar.setLenient( false ); // Reject illegal values
    try {
    calendar.get( Calendar.SECOND ); // Recalc values
    } catch ( IllegalArgumentException e ) {
    throw new RuntimeException("Invalid argument: Cannot convert long to dateTimeYYYYMMDDHHMMSSsss, long = " + dateTimeYYYYMMDDHHMMSSsss + " Exception message = " + e.getMessage());
    long millis = calendar.getTimeInMillis();
    //System.out.println( "Initial dateTime = " + millis );
    calendar = Calendar.getInstance(timeZone);
    calendar.clear();
    calendar.setTimeInMillis( millis );
    int year2 = calendar.get( Calendar.YEAR );
    int month2 = calendar.get( Calendar.MONTH );
    int day2 = calendar.get( Calendar.DAY_OF_MONTH );
    int hour2 = calendar.get( Calendar.HOUR_OF_DAY );
    int min2 = calendar.get( Calendar.MINUTE );
    int sec2 = calendar.get( Calendar.SECOND );
    int mSec2 = calendar.get( Calendar.MILLISECOND );
    System.out.println( "Final dateTime = " + year2 + "." + (month2+1) + "." + day2 + " " + hour2 + ":" + min2 + ":" + sec2 + "." + mSec2 );
    if (( year != year2 ) || ( month != month2 ) || ( day != day2 ) || ( hour != hour2 ) || ( min != min2 ) || ( sec != sec2 ) || ( mSec != mSec2 ))
    System.out.println( "setCalendar2 failed, dates are not equal" );
    return calendar;
    void runSetCalendars( TimeZone timeZone, long dateTimeYYYYMMDDHHMMSSsss ) {
    System.out.println( "" );
    System.out.println( "runSetCalendars dateTimeYYYYMMDDHHMMSSsss = " + dateTimeYYYYMMDDHHMMSSsss );
    try {
    setCalendar1( timeZone, dateTimeYYYYMMDDHHMMSSsss );
    } catch ( RuntimeException e ) {
    System.out.println( "setCalendar1 failed, dateTimeYYYYMMDDHHMMSSsss = " + dateTimeYYYYMMDDHHMMSSsss + " Exception = " + e.toString());
    Calendar calendar = null;
    try {
    calendar = setCalendar2( timeZone, dateTimeYYYYMMDDHHMMSSsss );
    long timeInMillis = calendar.getTimeInMillis();
    calendar.clear();
    calendar.setTimeInMillis( timeInMillis );
    } catch ( RuntimeException e ) {
    System.out.println( "setCalendar2 failed, dateTimeYYYYMMDDHHMMSSsss = " + dateTimeYYYYMMDDHHMMSSsss + " Exception = " + e.toString());
    ==================
    Program output is below:
    ==================
    RunSetCalendars
    runSetCalendars dateTimeYYYYMMDDHHMMSSsss = 19420403000000000
    setCalendar1 timeZone = GMT
    1942.4.3 0:0:0.0
    setCalendar2 timeZone = GMT
    Initial dateTime = 1942.4.3 0:0:0.0
    Final dateTime = 1942.4.3 0:0:0.0
    runSetCalendars dateTimeYYYYMMDDHHMMSSsss = 19210501000000000
    setCalendar1 timeZone = GMT
    1921.5.1 0:0:0.0
    setCalendar2 timeZone = GMT
    Initial dateTime = 1921.5.1 0:0:0.0
    Final dateTime = 1921.5.1 0:0:0.0
    runSetCalendars dateTimeYYYYMMDDHHMMSSsss = 19210502000000000
    setCalendar1 timeZone = GMT
    1921.5.2 0:0:0.0
    setCalendar2 timeZone = GMT
    Initial dateTime = 1921.5.2 0:0:0.0
    Final dateTime = 1921.5.2 0:0:0.0
    runSetCalendars dateTimeYYYYMMDDHHMMSSsss = 19420403000000000
    setCalendar1 timeZone = EET
    1942.4.3 0:0:0.0
    setCalendar2 timeZone = EET
    Initial dateTime = 1942.4.3 0:0:0.0
    Final dateTime = 1942.4.3 0:0:0.0
    runSetCalendars dateTimeYYYYMMDDHHMMSSsss = 19210501000000000
    setCalendar1 timeZone = EET
    1921.5.1 0:0:0.0
    setCalendar2 timeZone = EET
    Initial dateTime = 1921.5.1 0:0:0.0
    Final dateTime = 1921.5.1 0:0:0.0
    runSetCalendars dateTimeYYYYMMDDHHMMSSsss = 19210502000000000
    setCalendar1 timeZone = EET
    1921.5.2 0:0:0.0
    setCalendar2 timeZone = EET
    Initial dateTime = 1921.5.2 0:0:0.0
    Final dateTime = 1921.5.2 0:0:0.0
    runSetCalendars dateTimeYYYYMMDDHHMMSSsss = 19420403000000000
    setCalendar1 timeZone = Europe/Helsinki
    1942.4.3 0:0:0.0
    setCalendar1 failed, dateTimeYYYYMMDDHHMMSSsss = 19420403000000000 Exception = java.lang.RuntimeException: Invalid argument: Cannot convert long to dateTimeYYYYMMDDHHMMSSsss, long = 19420403000000000 Exception message = HOUR_OF_DAY
    setCalendar2 timeZone = Europe/Helsinki
    Initial dateTime = 1942.4.3 0:0:0.0
    Final dateTime = 1942.4.3 1:0:0.0
    setCalendar2 failed, dates are not equal
    runSetCalendars dateTimeYYYYMMDDHHMMSSsss = 19210501000000000
    setCalendar1 timeZone = Europe/Helsinki
    1921.5.1 0:0:0.0
    setCalendar1 failed, dateTimeYYYYMMDDHHMMSSsss = 19210501000000000 Exception = java.lang.RuntimeException: Invalid argument: Cannot convert long to dateTimeYYYYMMDDHHMMSSsss, long = 19210501000000000 Exception message = MINUTE
    setCalendar2 timeZone = Europe/Helsinki
    Initial dateTime = 1921.5.1 0:0:0.0
    Final dateTime = 1921.5.1 0:20:8.0
    setCalendar2 failed, dates are not equal
    runSetCalendars dateTimeYYYYMMDDHHMMSSsss = 19210502000000000
    setCalendar1 timeZone = Europe/Helsinki
    1921.5.2 0:0:0.0
    setCalendar2 timeZone = Europe/Helsinki
    Initial dateTime = 1921.5.2 0:0:0.0
    Final dateTime = 1921.5.2 0:0:0.0
    ==================
    Why does the program fail when timeZone = "Europe/Helsinki"?

    Could it be related to the time zone changes which occurred at about this time?
    http://www.timeanddate.com/worldclock/clockchange.html?n=101&year=1921

  • Is there a way I can use a Master with sub-projects on different calendars?

    Wondering if I can get some advice creating a Master Project (MSP2013 Standard, no Project Server software). I have 3 projects of which 2 are utilising a Standard calendar 8:00AM to 5:00PM 8hr day 40hr week, and 1 project (the largest) utilising a Customised
    calendar 7:30AM to 3:30PM  7.5hr day 37.5hr week.
    The dominant project is running on the Customised calendar so I have set the Global Options in the Master to reflect the 7:30AM to 3:30PM  7.5hr day 37.5hr week. Then set the calendar in Master Project Information default to the Customised calendar. 
    Finally, the resource pool for all 3 projects is in the Master.
    No problem when I insert the sub-project into the Master which is using the customised calendar. All data is reflective of the original project.  However, when I insert either of the 2 sub-projects using the 40hr week calendar the Summary Headings for
    the inserted projects are incorrect.  For example, instead of being 2 weeks duration, the summary heading displays 2.13 weeks, and instead of 4 weeks duration, the summary heading displays 4.27 weeks.
    The Global settings appear to be interfering with the projects on the Standard calendars.  I am surprised and extremely frustrated as I thought the settings in the Master would not affect anything?
    Sorry guys, have posted this in 3 different places as it is so important to me!

    Hi Guys, many thanks for your responses, really appreciate your time, however I am finding this much more complex. I have put my original sheets to one side and started again. Once again this is very important hence a lot of detail here. I am hoping something
    will provide a clue where I am going wrong.
    New sheet |save as Master | Change Working Times |copy Standard Calendar and called it 37.5 Hour
    Calendar| No exceptions | Work Weeks tab |Details | Set Monday to Friday 7:30AM to 12:30PM then 1:00PM to 3:30PM. Selected Options | Schedule | Start 7:30AM End 3:30PM |Hours 7.5 | Hours per week 37.5 |Auto Scheduled |Duration Hours|
    Work Hours |Fixed Duration | OK OK. Project | Project Information | Calendar changed to 37.5 Hour Calendar | Save.
    In my previous example I noted that my main project is scheduled 37.5 hours but I will skip inserting it here, the issue is subprojects with different settings to the Global, that is mixing projects with different calendars in a Master.
    New sheet | save as 40 Hour Project |Change Working Times |Standard Calendar | No exceptions | Selected Options | Schedule | Start 8:00AM End 5:00PM |Hours 8 Hours per week 40 |Auto Scheduled |Duration Weeks | Work Hours |Fixed Duration
    | OK OK | Save.
    Entered 5 new Tasks, all 2weeks duration, all linked Finish to Start. Inserted a Summary Heading named 40 Hour Summary | 40 Hour Summary Duration = 10 wks | Start 9 June 1014 8:00 AM | Finish 15 August 2014 5:00 PM |Created 1 Resource called Fred | 100%
    |$100 Standard Rate | Assigned Fred to all tasks 100% | Project | Project Information | Statistics | 10w 400h $40.000 |Save and Close | All correct.
    Back to the Master | Project | Insert Subproject | selected 40 Hour Project |Duration 400 hrs | Start 9 June 2014 8:00AM | Finish 21 August 2014 10:30AM. It appears the Global settings are affecting the inserted subproject note the finish time is now
    10:30AM. Project | Project Information |Statistics |Duration 400h | Work 400h | All correct!
    BUT | select View Outline Show Subtasks |This is where further changes have happened | Project | Project Information |Statistics |Duration is now
    374.5h | Work 400h.
    Besides information being displayed incorrectly these figures will affect all Reports. This example suggests you cannot have subprojects in a Master that are associated with different calendars? Surely not! Please help if you can, I have
    spent hours searching for answers, and I can’t believe I am the only one who has come across this! Many thanks.......

  • 8 and 24 hour calenders

    I have a project with multiple resources. Some are in different countries so I have both the Standard Calendar and also an additional Base calendar for a second country.  Resources for
    the foreign country are based on the additional calendar.<o:p></o:p>
    I have one task that is computer based and runs 24 hours a day.  I would like to have that task coexist with the rest of the project and at the same time reflect accurate Work, Duration,
    Start Date and End Date.<o:p></o:p>
    When I change the computer task so that it's based on the 24 hour calendar and also check the "ignore resource calendar", MS Project 2010 gets the work, start and end dates right,
    but duration is incorrect.  I found a posting that has a list of 13 steps to get this right, and that does fix the computer task.  But it also messes up all the rest of the tasks (for example a 8 hour task that was correctly displayed with 1 day
    duration is now .3 days.).  One of the 13 steps involves changing the Project Options+Schedule settings to 24 hour day, 168 hour week.<o:p></o:p>
    Is there a way to have both 8 and 24 hour tasks where all display duration, start and end dates accurately?<o:p></o:p>

    Each project can only have one conversion rate for hours in days. SO if this is 8h/d then any 24h calendar day can fit in 3 "standard" 8h days. If your tasks with 24h days are just weekend cutovers or similar than consider using a duration of
    hours as this makes it clear what's happening.
    Rod Gill
    Author of the one and only Project VBA Book
    www.project-systems.co.nz

  • What happened to items that were listed on my calendar prior to 2012?

    Had many items listed in my calendar going back years in iOS 6.  The only ones now listed are from 2013 forward. What happened to those old dates that were listed? Can those items ever be retrieved?

    It's set to " all events." That's not the problem. I am trying to have the calendar list go back before 2013 without going month by month and date by date through old calendars to search for items.   I can go back to an old calendar and see a grey dot on a particular date, June 3, 2008, for example, and if I open that date I can see that date's hourly calendar, plus the item I had listed for that date. But it's not in the master list. The master list only lists events from 2013. Older items haven't  been deleted on the calendar, just from the list.

  • Cant get the current hour

    Hi i am trying to get the hour of the current time using the calendar class and when the time is on the 12th hour, the hour returns 0 instead of 12.
    here is my code below:
    //Update the time
                        calendar.setTime(new Date());
                        hour = calendar.get(calendar.HOUR);

    http://java.sun.com/j2se/1.4.2/docs/api/java/util/Calendar.html
    * Field number for <code>get</code> and <code>set</code> indicating the
    * hour of the morning or afternoon. <code>HOUR</code> is used for the
    * 12-hour clock (0 - 11). Noon and midnight are represented by 0, not by 12.
    * E.g., at 10:04:15.250 PM the <code>HOUR</code> is 10.
    * @see #AM_PM
    * @see #HOUR_OF_DAY
    */

  • 24 hour resources?

    Dear All
    I have a requirement to set up a resource that will run for up to 24 hours in a day.  I've set up a resource in our test area, and assigned it to the 24 hour calendar.  The problem is that when I go to add it to a plan and enter 100% units it only
    puts 8 hours in work.  If I enter 24 hours work it sets the units to 300%.
    Is there a way of setting up a resource that can book 24 hours in a day, showing 100% in units?  I'm sure I'm just missing something.
    Many thanks.
    John

    False alarm on my part, it is working it just doesn't work how I imagined it would.
    Im my tests I had assumed 1 day was calculated per resource so a 24hour resouce would show 24 hours.  But 1 day is 8 hours no matter what.
    When I expanded the days it showed the resource working 24 hours per day.  Hence I suspect Pauls suggection of changing the task calendar changes the definition of 1 day to be calculated off the calendar.
    Thank for your help Paul and Ely
    John

  • DO i need some extra hardware interface for receving both Audio and video

    hi i m doing e-learning project. i have to capture video from webcam and voice from headphone and send to client.
    but my code is working fine for either one at a time.
    DO i need some extra hardware interface for receving both Audio and video. im using code AVTransmit and AVReceive found from this site only
    After running TX
    i give Dsound:// & vfw://0 in Media Locater only sound is received and no vedio
    and when i give vfw://0 in Media Locater only live video is transmited.
    im using JMF1.1.2e.
    if any one know the method to run or cause of it plz reply me soon. i will be very thankfull
    transmiter/server side code .first run TX on server
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.net.*;
    import java.util.*;
    import javax.media.rtp.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.border.*;
    public class Tx extends JFrame implements ActionListener, KeyListener,
    MouseListener, WindowListener {
    Vector targets;
    JList list;
    JButton startXmit;
    JButton rtcp;
    JButton update;
    JButton expiration;
    JButton statistics;
    JButton addTarget;
    JButton removeTarget;
    JTextField tf_remote_address;
    JTextField tf_remote_data_port;
    JTextField tf_media_file;
    JTextField tf_data_port;
    TargetListModel listModel;
    AVTransmitter avTransmitter;
    RTCPViewer rtcpViewer;
    JCheckBox cb_loop;
    Config config;
    public Tx() {
    setTitle( "JMF/RTP Transmitter");
         config= new Config();
         GridBagLayout gridBagLayout= new GridBagLayout();
         GridBagConstraints gbc;
         JPanel p= new JPanel();
         p.setLayout( gridBagLayout);
         JPanel localPanel= createLocalPanel();
         gbc= new GridBagConstraints();
         gbc.gridx= 0;
         gbc.gridy= 0;
         gbc.gridwidth= 2;
         gbc.anchor= GridBagConstraints.CENTER;
         gbc.fill= GridBagConstraints.BOTH;
         gbc.insets= new Insets( 10, 5, 0, 0);
         ((GridBagLayout)p.getLayout()).setConstraints( localPanel, gbc);
         p.add( localPanel);
         JPanel targetPanel= createTargetPanel();
         gbc= new GridBagConstraints();
         gbc.gridx= 1;
         gbc.gridy= 1;
         gbc.weightx= 1.0;
         gbc.weighty= 1.0;
         gbc.anchor= GridBagConstraints.CENTER;
         gbc.fill= GridBagConstraints.BOTH;
         gbc.insets= new Insets( 10, 5, 0, 0);
         ((GridBagLayout)p.getLayout()).setConstraints( targetPanel, gbc);
    p.add( targetPanel);
         JPanel mediaPanel= createMediaPanel();
         gbc= new GridBagConstraints();
         gbc.gridx= 1;
         gbc.gridy= 2;
         gbc.weightx= 1.0;
         gbc.weighty= 1.0;
         gbc.anchor= GridBagConstraints.CENTER;
         gbc.fill= GridBagConstraints.BOTH;
         gbc.insets= new Insets( 10, 5, 0, 0);
         ((GridBagLayout)p.getLayout()).setConstraints( mediaPanel, gbc);
    p.add( mediaPanel);
    JPanel buttonPanel= new JPanel();
    rtcp= new JButton( "RTCP Monitor");
    update= new JButton( "Transmission Status");
         update.setEnabled( false);
         rtcp.addActionListener( this);
         update.addActionListener( this);
         buttonPanel.add( rtcp);
         buttonPanel.add( update);
         gbc= new GridBagConstraints();
         gbc.gridx = 0;
         gbc.gridy = 3;
    gbc.gridwidth= 2;
         gbc.weightx = 1.0;
         gbc.weighty = 0.0;
         gbc.anchor = GridBagConstraints.CENTER;
         gbc.fill = GridBagConstraints.HORIZONTAL;
         gbc.insets = new Insets( 5,5,10,5);
         ((GridBagLayout)p.getLayout()).setConstraints( buttonPanel, gbc);
         p.add( buttonPanel);
    getContentPane().add( p);
         list.addMouseListener( this);
         addWindowListener( this);
    pack();
    setVisible( true);
    private JPanel createMediaPanel() {
    JPanel p= new JPanel();
         GridBagLayout gridBagLayout= new GridBagLayout();
    GridBagConstraints gbc;
         p.setLayout( gridBagLayout);
         JLabel label= new JLabel( "Media Locator:");
         gbc= new GridBagConstraints();
         gbc.gridx = 0;
         gbc.gridy = 0;
         gbc.weightx = 0.0;
         gbc.weighty = 0.0;
         gbc.anchor = GridBagConstraints.EAST;
         gbc.fill = GridBagConstraints.NONE;
         gbc.insets = new Insets( 5,5,10,5);
         ((GridBagLayout)p.getLayout()).setConstraints( label, gbc);
         p.add( label);
         tf_media_file= new JTextField( 35);
         gbc= new GridBagConstraints();
         gbc.gridx = 1;
         gbc.gridy = 0;
         gbc.weightx = 1.0;
         gbc.weighty = 0.0;
         gbc.anchor = GridBagConstraints.WEST;
         gbc.fill = GridBagConstraints.HORIZONTAL;
         gbc.insets = new Insets( 5,5,10,5);
         ((GridBagLayout)p.getLayout()).setConstraints( tf_media_file, gbc);
         p.add( tf_media_file);
         tf_media_file.setText( config.media_locator);
         cb_loop= new JCheckBox( "loop");
         startXmit= new JButton( "Start Transmission");
         startXmit.setEnabled( true);
         startXmit.addActionListener( this);
         gbc= new GridBagConstraints();
         gbc.gridx = 2;
         gbc.gridy = 0;
         gbc.weightx = 0.0;
         gbc.weighty = 0.0;
         gbc.anchor = GridBagConstraints.WEST;
         gbc.fill = GridBagConstraints.NONE;
         gbc.insets = new Insets( 5,5,10,5);
         ((GridBagLayout)p.getLayout()).setConstraints( cb_loop, gbc);
         p.add( cb_loop);
         cb_loop.setSelected( true);
         cb_loop.addActionListener( this);
         gbc= new GridBagConstraints();
         gbc.gridx = 1;
         gbc.gridy = 1;
         gbc.weightx = 0.0;
         gbc.weighty = 0.0;
         gbc.anchor = GridBagConstraints.CENTER;
         gbc.fill = GridBagConstraints.NONE;
         gbc.insets = new Insets( 5,5,10,5);
         ((GridBagLayout)p.getLayout()).setConstraints( startXmit, gbc);
         p.add( startXmit);
         TitledBorder titledBorder= new TitledBorder( new EtchedBorder(), "Source");
         p.setBorder( titledBorder);
         return p;
    private JPanel createTargetPanel() {
    JPanel p= new JPanel();
         GridBagLayout gridBagLayout= new GridBagLayout();
    GridBagConstraints gbc;
         p.setLayout( gridBagLayout);
         targets= new Vector();
         for( int i= 0; i < config.targets.size(); i++) {
         targets.addElement( config.targets.elementAt( i));
    listModel= new TargetListModel( targets);
    list= new JList( listModel);
         list.addKeyListener( this);
         list.setPrototypeCellValue( "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
    JScrollPane scrollPane= new JScrollPane( list,
    ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
    ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
         gbc= new GridBagConstraints();
         gbc.gridx= 0;
         gbc.gridy= 0;
         gbc.weightx= 1.0;
         gbc.weighty= 1.0;
         gbc.anchor= GridBagConstraints.CENTER;
         gbc.fill= GridBagConstraints.BOTH;
         gbc.insets= new Insets( 10, 5, 0, 0);
         ((GridBagLayout)p.getLayout()).setConstraints( scrollPane, gbc);
         p.add( scrollPane);
    JPanel p1= new JPanel();
         p1.setLayout( gridBagLayout);
         JLabel label= new JLabel( "IP Address:");
         gbc= new GridBagConstraints();
         gbc.gridx = 0;
         gbc.gridy = 0;
         gbc.weightx = 0.0;
         gbc.weighty = 0.0;
         gbc.anchor = GridBagConstraints.EAST;
         gbc.fill = GridBagConstraints.NONE;
         gbc.insets = new Insets( 5,5,0,5);
         ((GridBagLayout)p1.getLayout()).setConstraints( label, gbc);
         p1.add( label);
         tf_remote_address= new JTextField( 15);
         gbc= new GridBagConstraints();
         gbc.gridx = 1;
         gbc.gridy = 0;
         gbc.weightx = 0.0;
         gbc.weighty = 0.0;
         gbc.anchor = GridBagConstraints.WEST;
         gbc.fill = GridBagConstraints.NONE;
         gbc.insets = new Insets( 5,5,0,5);
         ((GridBagLayout)p1.getLayout()).setConstraints( tf_remote_address, gbc);
         p1.add( tf_remote_address);
         label= new JLabel( "Data Port:");
         gbc= new GridBagConstraints();
         gbc.gridx = 0;
         gbc.gridy = 1;
         gbc.weightx = 0.0;
         gbc.weighty = 0.0;
         gbc.anchor = GridBagConstraints.EAST;
         gbc.fill = GridBagConstraints.NONE;
         gbc.insets = new Insets( 5,5,0,5);
         ((GridBagLayout)p1.getLayout()).setConstraints( label, gbc);
         p1.add( label);
         tf_remote_data_port= new JTextField( 15);
         gbc= new GridBagConstraints();
         gbc.gridx = 1;
         gbc.gridy = 1;
         gbc.weightx = 0.0;
         gbc.weighty = 0.0;
         gbc.anchor = GridBagConstraints.WEST;
         gbc.fill = GridBagConstraints.NONE;
         gbc.insets = new Insets( 5,5,0,5);
         ((GridBagLayout)p1.getLayout()).setConstraints( tf_remote_data_port, gbc);
         p1.add( tf_remote_data_port);     
    JPanel p2= new JPanel();
    addTarget= new JButton( "Add Target");     
    removeTarget= new JButton( "Remove Target");
         p2.add( addTarget);
         p2.add( removeTarget);
         addTarget.addActionListener( this);
         removeTarget.addActionListener( this);
         gbc= new GridBagConstraints();
         gbc.gridx = 0;
         gbc.gridy = 2;
         gbc.weightx = 1.0;
         gbc.weighty = 0.0;
         gbc.gridwidth= 2;
         gbc.anchor = GridBagConstraints.CENTER;
         gbc.fill = GridBagConstraints.HORIZONTAL;
         gbc.insets = new Insets( 20,5,0,5);
         ((GridBagLayout)p1.getLayout()).setConstraints( p2, gbc);
         p1.add( p2);
         gbc= new GridBagConstraints();
         gbc.gridx= 1;
         gbc.gridy= 0;
         gbc.weightx= 1.0;
         gbc.weighty= 1.0;
         gbc.anchor= GridBagConstraints.CENTER;
         gbc.fill= GridBagConstraints.BOTH;
         gbc.insets= new Insets( 10, 5, 0, 0);
         ((GridBagLayout)p.getLayout()).setConstraints( p1, gbc);
         p.add( p1);
         TitledBorder titledBorder= new TitledBorder( new EtchedBorder(), "Targets");
         p.setBorder( titledBorder);
         return p;
    private JPanel createLocalPanel() {
    JPanel p= new JPanel();
         GridBagLayout gridBagLayout= new GridBagLayout();
    GridBagConstraints gbc;
         p.setLayout( gridBagLayout);
         JLabel label= new JLabel( "IP Address:");
         gbc= new GridBagConstraints();
         gbc.gridx = 0;
         gbc.gridy = 0;
         gbc.weightx = 0.0;
         gbc.weighty = 0.0;
         gbc.anchor = GridBagConstraints.EAST;
         gbc.fill = GridBagConstraints.NONE;
         gbc.insets = new Insets( 5,5,0,5);
         ((GridBagLayout)p.getLayout()).setConstraints( label, gbc);
         p.add( label);
         JTextField tf_local_host= new JTextField( 15);
         gbc= new GridBagConstraints();
         gbc.gridx = 1;
         gbc.gridy = 0;
         gbc.weightx = 0.0;
         gbc.weighty = 0.0;
         gbc.anchor = GridBagConstraints.WEST;
         gbc.fill = GridBagConstraints.NONE;
         gbc.insets = new Insets( 5,5,0,5);
         ((GridBagLayout)p.getLayout()).setConstraints( tf_local_host, gbc);
         p.add( tf_local_host);
         try {
    String host= InetAddress.getLocalHost().getHostAddress();     
         tf_local_host.setText( host);
         } catch( UnknownHostException e) {
         label= new JLabel( "Data Port:");
         gbc= new GridBagConstraints();
         gbc.gridx = 0;
         gbc.gridy = 1;
         gbc.weightx = 0.0;
         gbc.weighty = 0.0;
         gbc.anchor = GridBagConstraints.EAST;
         gbc.fill = GridBagConstraints.NONE;
         gbc.insets = new Insets( 5,5,0,5);
         ((GridBagLayout)p.getLayout()).setConstraints( label, gbc);
         p.add( label);
         tf_data_port= new JTextField( 15);
         gbc= new GridBagConstraints();
         gbc.gridx = 1;
         gbc.gridy = 1;
         gbc.weightx = 0.0;
         gbc.weighty = 0.0;
         gbc.anchor = GridBagConstraints.WEST;
         gbc.fill = GridBagConstraints.NONE;
         gbc.insets = new Insets( 5,5,10,5);
         ((GridBagLayout)p.getLayout()).setConstraints( tf_data_port, gbc);
         p.add( tf_data_port);
         tf_data_port.setText( config.local_data_port);
         TitledBorder titledBorder= new TitledBorder( new EtchedBorder(), "Local Host");
         p.setBorder( titledBorder);
         return p;
    public void actionPerformed( ActionEvent event) {
    Object source= event.getSource();
         if( source == addTarget) {
         String ip= tf_remote_address.getText().trim();
         String port= tf_remote_data_port.getText().trim();
         String localPort= tf_data_port.getText().trim();
         addTargetToList( localPort, ip, port);
         if( avTransmitter != null) {
         avTransmitter.addTarget( ip, port);
         } else if( source == removeTarget) {
         int index= list.getSelectedIndex();
         if( index != -1) {
              Target target= (Target) targets.elementAt( index);
              if( avTransmitter != null) {
         avTransmitter.removeTarget( target.ip, target.port);
              targets.removeElement( target);
              listModel.setData( targets);          
         } else if( source == startXmit) {
         if( startXmit.getLabel().equals( "Start Transmission")) {          
         int data_port= new Integer( tf_data_port.getText()).intValue();
              avTransmitter= new AVTransmitter( this, data_port);
         avTransmitter.start( tf_media_file.getText().trim(), targets);          
              avTransmitter.setLooping( cb_loop.isSelected());
         startXmit.setLabel( "Stop Transmission");
         } else if( startXmit.getLabel().equals( "Stop Transmission")) {
              avTransmitter.stop();
              avTransmitter= null;
              removeNonBaseTargets();
              listModel.setData( targets);
         startXmit.setLabel( "Start Transmission");          
         } else if( source == rtcp) {
         if( rtcpViewer == null) {
         rtcpViewer= new RTCPViewer();
         } else {
              rtcpViewer.setVisible( true);
              rtcpViewer.toFront();
         } else if( source == cb_loop) {
         if( avTransmitter != null) {
              avTransmitter.setLooping( cb_loop.isSelected());
    private void removeNonBaseTargets() {
         String localPort= tf_data_port.getText().trim();
         for( int i= targets.size(); i > 0;) {
         Target target= (Target) targets.elementAt( i - 1);
         if( !target.localPort.equals( localPort)) {
    targets.removeElement( target);
         i--;
    public void addTargetToList( String localPort,
                             String ip, String port) {     
    ListUpdater listUpdater= new ListUpdater( localPort, ip,
                                  port, listModel, targets);
    SwingUtilities.invokeLater( listUpdater);           
    public void rtcpReport( String report) {
         if( rtcpViewer != null) {
         rtcpViewer.report( report);
    public void windowClosing( WindowEvent event) {
         config.local_data_port= tf_data_port.getText().trim();
         config.targets= new Vector();
         for( int i= 0; i < targets.size(); i++) {
         Target target= (Target) targets.elementAt( i);
         if( target.localPort.equals( config.local_data_port)) {
              config.addTarget( target.ip, target.port);
         config.media_locator= tf_media_file.getText().trim();
         config.write();
    System.exit( 0);
    public void windowClosed( WindowEvent event) {
    public void windowDeiconified( WindowEvent event) {
    public void windowIconified( WindowEvent event) {
    public void windowActivated( WindowEvent event) {
    public void windowDeactivated( WindowEvent event) {
    public void windowOpened( WindowEvent event) {
    public void keyPressed( KeyEvent event) {
    public void keyReleased( KeyEvent event) {
    Object source= event.getSource();
         if( source == list) {
         int index= list.getSelectedIndex();
    public void keyTyped( KeyEvent event) {
    public void mousePressed( MouseEvent e) {
    public void mouseReleased( MouseEvent e) {
    public void mouseEntered( MouseEvent e) {
    public void mouseExited( MouseEvent e) {
    public void mouseClicked( MouseEvent e) {
    Object source= e.getSource();
         if( source == list) {
         int index= list.getSelectedIndex();
         if( index != -1) {
              Target target= (Target) targets.elementAt( index);
              tf_remote_address.setText( target.ip);
              tf_remote_data_port.setText( target.port);
         int index= list.locationToIndex( e.getPoint());
    public static void main( String[] args) {
    new Tx();
    class TargetListModel extends AbstractListModel {
    private Vector options;
    public TargetListModel( Vector options) {
         this.options= options;
    public int getSize() {
         int size;
         if( options == null) {
         size= 0;
         } else {
         size= options.size();
         return size;
    public Object getElementAt( int index) {
    String name;
    if( index < getSize()) {
         Target o= (Target)options.elementAt( index);
    name= o.localPort + " ---> " + o.ip + ":" + o.port;
         } else {
         name= null;
         return name;
    public void setData( Vector data) {
         options= data;
         fireContentsChanged( this, 0, data.size());
    class ListUpdater implements Runnable {
    String localPort, ip, port;
    TargetListModel listModel;
    Vector targets;
    public ListUpdater( String localPort, String ip, String port,
                   TargetListModel listModel, Vector targets) {
         this.localPort= localPort;
         this.ip= ip;
         this.port= port;
         this.listModel= listModel;
         this.targets= targets;
    public void run() {
    Target target= new Target( localPort, ip, port);
         if( !targetExists( localPort, ip, port)) {
         targets.addElement( target);
    listModel.setData( targets);
    public boolean targetExists( String localPort, String ip, String port) {
         boolean exists= false;
         for( int i= 0; i < targets.size(); i++) {
         Target target= (Target) targets.elementAt( i);
         if( target.localPort.equals( localPort)
         && target.ip.equals( ip)
              && target.port.equals( port)) {          
              exists= true;
         break;
         return exists;
    >>>>>>>>>>>>>>>>>
    import java.awt.*;
    import java.io.*;
    import java.net.InetAddress;
    import java.util.*;
    import javax.media.*;
    import javax.media.protocol.*;
    import javax.media.format.*;
    import javax.media.control.TrackControl;
    import javax.media.control.QualityControl;
    import javax.media.rtp.*;
    import javax.media.rtp.event.*;
    import javax.media.rtp.rtcp.*;
    public class AVTransmitter implements ReceiveStreamListener, RemoteListener,
    ControllerListener {
    // Input MediaLocator
    // Can be a file or http or capture source
    private MediaLocator locator;
    private String ipAddress;
    private int portBase;
    private Processor processor = null;
    private RTPManager rtpMgrs[];
    private int localPorts[];
    private DataSource dataOutput = null;
    private int local_data_port;
    private Tx tx;
    public AVTransmitter( Tx tx, int data_port) {
         this.tx= tx;
         local_data_port= data_port;
    * Starts the transmission. Returns null if transmission started ok.
    * Otherwise it returns a string with the reason why the setup failed.
    public synchronized String start( String filename, Vector targets) {
         String result;
         locator= new MediaLocator( filename);
         // Create a processor for the specified media locator
         // and program it to output JPEG/RTP
         result = createProcessor();
         if (result != null) {
         return result;
         // Create an RTP session to transmit the output of the
         // processor to the specified IP address and port no.
         result = createTransmitter( targets);
         if (result != null) {
         processor.close();
         processor = null;
         return result;
         // Start the transmission
         processor.start();
         return null;
    * Use the RTPManager API to create sessions for each media
    * track of the processor.
    private String createTransmitter( Vector targets) {
         // Cheated. Should have checked the type.
         PushBufferDataSource pbds = (PushBufferDataSource)dataOutput;
         PushBufferStream pbss[] = pbds.getStreams();
         rtpMgrs = new RTPManager[pbss.length];
         localPorts = new int[ pbss.length];
         SessionAddress localAddr, destAddr;
         InetAddress ipAddr;
         SendStream sendStream;
         int port;
         SourceDescription srcDesList[];
         for (int i = 0; i < pbss.length; i++) {
         // for (int i = 0; i < 1; i++) {
         try {
              rtpMgrs[i] = RTPManager.newInstance();     
              port = local_data_port + 2*i;
              localPorts[ i]= port;
              localAddr = new SessionAddress( InetAddress.getLocalHost(),
                                  port);
              rtpMgrs.initialize( localAddr);          
              rtpMgrs[i].addReceiveStreamListener(this);
              rtpMgrs[i].addRemoteListener(this);
         for( int k= 0; k < targets.size(); k++) {
              Target target= (Target) targets.elementAt( k);
              int targetPort= new Integer( target.port).intValue();
              addTarget( localPorts[ i], rtpMgrs[ i], target.ip, targetPort + 2*i);
              sendStream = rtpMgrs[i].createSendStream(dataOutput, i);          
              sendStream.start();
         } catch (Exception e) {
              e.printStackTrace();
              return e.getMessage();
         return null;
    public void addTarget( String ip, String port) {
         for (int i= 0; i < rtpMgrs.length; i++) {
         int targetPort= new Integer( port).intValue();
         addTarget( localPorts[ i], rtpMgrs[ i], ip, targetPort + 2*i);
    public void addTarget( int localPort, RTPManager mgr, String ip, int port) {
         try {
         SessionAddress addr= new SessionAddress( InetAddress.getByName( ip),
                                  new Integer( port).intValue());
         mgr.addTarget( addr);
         tx.addTargetToList( localPort + "", ip, port + "");
         } catch( Exception e) {
         e.printStackTrace();
    public void removeTarget( String ip, String port) {
         try {     
         SessionAddress addr= new SessionAddress( InetAddress.getByName( ip),
                                  new Integer( port).intValue());
         for (int i= 0; i < rtpMgrs.length; i++) {
         rtpMgrs[ i].removeTarget( addr, "target removed from transmitter.");
         } catch( Exception e) {
         e.printStackTrace();
    boolean looping= true;
    public void controllerUpdate( ControllerEvent ce) {
         System.out.println( ce);
         if( ce instanceof DurationUpdateEvent) {
         Time duration= ((DurationUpdateEvent) ce).getDuration();
         System.out.println( "duration: " + duration.getSeconds());
         } else if( ce instanceof EndOfMediaEvent) {
         System.out.println( "END OF MEDIA - looping=" + looping);
         if( looping) {
         processor.setMediaTime( new Time( 0));
              processor.start();
    public void setLooping( boolean flag) {
         looping= flag;
    public void update( ReceiveStreamEvent event) {
         String timestamp= getTimestamp();
         StringBuffer sb= new StringBuffer();
         if( event instanceof InactiveReceiveStreamEvent) {
         sb.append( timestamp + " Inactive Receive Stream");
         } else if( event instanceof ByeEvent) {
         sb.append( timestamp + " Bye");
         } else {
         System.out.println( "ReceiveStreamEvent: "+ event);
         tx.rtcpReport( sb.toString());     
    public void update( RemoteEvent event) {     
         String timestamp= getTimestamp();
         if( event instanceof ReceiverReportEvent) {
         ReceiverReport rr= ((ReceiverReportEvent) event).getReport();
         StringBuffer sb= new StringBuffer();
         sb.append( timestamp + " RR");
         if( rr != null) {
              Participant participant= rr.getParticipant();
              if( participant != null) {
              sb.append( " from " + participant.getCNAME());
              sb.append( " ssrc=" + rr.getSSRC());
              } else {
              sb.append( " ssrc=" + rr.getSSRC());
              tx.rtcpReport( sb.toString());
         } else {
         System.out.println( "RemoteEvent: " + event);
    private String getTimestamp() {
         String timestamp;
         Calendar calendar= Calendar.getInstance();
         int hour= calendar.get( Calendar.HOUR_OF_DAY);
         String hourStr= formatTime( hour);
         int minute= calendar.get( Calendar.MINUTE);
         String minuteStr= formatTime( minute);
         int second= calendar.get( Calendar.SECOND);
         String secondStr= formatTime( second);
         timestamp= hourStr + ":" + minuteStr + ":" + secondStr;     
         return timestamp;
    private String formatTime( int time) {     
         String timeStr;
         if( time < 10) {
         timeStr= "0" + time;
         } else {
         timeStr= "" + time;
         return timeStr;
    * Stops the transmission if already started
    public void stop() {
         synchronized (this) {
         if (processor != null) {
              processor.stop();
              processor.close();
              processor = null;
         for (int i= 0; i < rtpMgrs.length; i++) {
         rtpMgrs[ i].removeTargets( "Session ended.");
              rtpMgrs[ i].dispose();
    public String createProcessor() {
         if (locator == null) {
         return "Locator is null";
         DataSource ds;
         DataSource clone;
         try {
         ds = javax.media.Manager.createDataSource(locator);
         } catch (Exception e) {
         return "Couldn't create DataSource";
         // Try to create a processor to handle the input media locator
         try {
         processor = javax.media.Manager.createProcessor(ds);
         processor.addControllerListener( this);     
         } catch (NoProcessorException npe) {
         return "Couldn't create processor";
         } catch (IOException ioe) {
         return "IOException creating processor";
         // Wait for it to configure
         boolean result = waitForState(processor, Processor.Configured);
         if (result == false)
         return "Couldn't configure processor";
         // Get the tracks from the processor
         TrackControl [] tracks = processor.getTrackControls();
         // Do we have atleast one track?
         if (tracks == null || tracks.length < 1)
         return "Couldn't find tracks in processor";
         // Set the output content descriptor to RAW_RTP
         // This will limit the supported formats reported from
         // Track.getSupportedFormats to only valid RTP formats.
         ContentDescriptor cd = new ContentDescriptor(ContentDescriptor.RAW_RTP);
         processor.setContentDescriptor(cd);
         Format supported[];
         Format chosen;
         boolean atLeastOneTrack = false;
         // Program the tracks.
         for (int i = 0; i < tracks.length; i++) {
         Format format = tracks[i].getFormat();
         if (tracks[i].isEnabled()) {
              supported = tracks[i].getSupportedFormats();
              // We've set the output content to the RAW_RTP.
              // So all the supported formats should work with RTP.
              // We'll just pick the first one.
              if (supported.length > 0) {
              if (supported[0] instanceof VideoFormat) {
                   // For video formats, we should double check the
                   // sizes since not all formats work in all sizes.
                   chosen = checkForVideoSizes(tracks[i].getFormat(),
                                       supported[0]);
              } else
                   chosen = supported[0];
              tracks[i].setFormat(chosen);
              System.err.println("Track " + i + " is set to transmit as:");
              System.err.println(" " + chosen);
              atLeastOneTrack = true;
              } else
              tracks[i].setEnabled(false);
         } else
              tracks[i].setEnabled(false);
         if (!atLeastOneTrack)
         return "Couldn't set any of the tracks to a valid RTP format";
         // Realize the processor. This will internally create a flow
         // graph and attempt to create an output datasource for JPEG/RTP
         // audio frames.
         result = waitForState(processor, Controller.Realized);
         if (result == false)
         return "Couldn't realize processor";
         // Set the JPEG quality to .5.
         setJPEGQuality(processor, 0.5f);
         // Get the output data source of the processor
         dataOutput = processor.getDataOutput();
         return null;
    static SessionAddress destAddr1, destAddr2;
    * For JPEG and H263, we know that they only work for particular
    * sizes. So we'll perform extra checking here to make sure they
    * are of the right sizes.
    Format checkForVideoSizes(Format original, Format supported) {
         int width, height;
         Dimension size = ((VideoFormat)original).getSize();
         Format jpegFmt = new Format(VideoFormat.JPEG_RTP);
         Format h263Fmt = new Format(VideoFormat.H263_RTP);
         if (supported.matches(jpegFmt)) {
         // For JPEG, make sure width and height are divisible by 8.
         width = (size.width % 8 == 0 ? size.width :
                        (int)(size.width / 8) * 8);
         height = (size.height % 8 == 0 ? size.height :
                        (int)(size.height / 8) * 8);
         } else if (supported.matches(h263Fmt)) {
         // For H.263, we only support some specific sizes.
         if (size.width < 128) {
              width = 128;
              height = 96;
         } else if (size.width < 176) {
              width = 176;
              height = 144;
         } else {
              width = 352;
              height = 288;
         } else {
         // We don't know this particular format. We'll just
         // leave it alone then.
         return supported;
         return (new VideoFormat(null,
                        new Dimension(width, height),
                        Format.NOT_SPECIFIED,
                        null,
                        Format.NOT_SPECIFIED)).intersects(supported);
    * Setting the encoding quality to the specified value on the JPEG encoder.
    * 0.5 is a good default.
    void setJPEGQuality(Player p, float val) {
         Control cs[] = p.getControls();
         QualityControl qc = null;
         VideoFormat jpegFmt = new VideoFormat(VideoFormat.JPEG);
         // Loop through the controls to find the Quality control for
         // the JPEG encoder.
         for (int i = 0; i < cs.length; i++) {
         if (cs[i] instanceof QualityControl &&
              cs[i] instanceof Owned) {
              Object owner = ((Owned)cs[i]).getOwner();
              // Check to see if the owner is a Codec.
              // Then check for the output format.
              if (owner instanceof Codec) {
              Format fmts[] = ((Codec)owner).getSupportedOutputFormats(null);
              for (int j = 0; j < fmts.length; j++) {
                   if (fmts[j].matches(jpegFmt)) {
                   qc = (QualityControl)cs[i];
                   qc.setQuality(val);
                   System.err.println("- Setting quality to " +
                             val + " on " + qc);
                   break;
              if (qc != null)
              break;
    * Convenience methods to handle processor's state changes.
    private Integer stateLock = new Integer(0);
    private boolean failed = false;
    Integer getStateLock() {
         return stateLock;
    void setFailed() {
         failed = true;
    private synchronized boolean waitForState(Processor p, int state) {
         p.addControllerListener(new StateListener());
         failed = false;
         // Call the required method on the processor
         if (state == Processor.Configured) {
         p.configure();
         } else if (state == Processor.Realized) {
         p.realize();
         // Wait until we get an event that confirms the
         // success of the method, or a failure event.
         // See StateListener inner class
         while (p.getState() < state && !failed) {
         synchronized (getStateLock()) {
              try {
              getStateLock().wait();
              } catch (InterruptedException ie) {
              return false;
         if (failed)
         return false;
         else
         return true;
    * Inner Classes
    class StateListener implements ControllerListener {
         public void controllerUpdate(ControllerEvent ce) {
         // If there was an error during configure or
         // realiz

    I do this all the time, I put my MBP to a 60 inch Sharp. If you have the video working do the simple thing first. Check to make sure your sound is on your TV and Mac. Then if that doesn't work go to System Prefrences and under sound go to a tab called Output and see if your TV is listed and if it is change it to that setting
    Hope It Works

  • How to  use  Filter  in ActionServlet

    hi how do i use filter in my ActionServlet ?
    here is a code :
    package test;
    import java.io.*;
    import java.util.*;
    import javax.servlet.*;
    public class TimeFilter implements Filter {
      public void init(FilterConfig config) throws ServletException {
      public void doFilter(ServletRequest request, ServletResponse response,
        FilterChain chain) throws IOException, ServletException {
        int hour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
        // only service the request between 08:00 and 17:59
        if (hour >= 8 && hour <= 17) {
          chain.doFilter(request, response);
        // for other times, forward the request to someplaceelse
        } else {
          request.getRequestDispatcher("/someplaceelse").forward(request, response);
      public void destroy() {
    }where do i place it in my ActionServlet to get filtered access ?
    My ActionServlet :
    import javax.servlet.http.*;
    import org.apache.struts.action.*;
    import java.io.*;
    import java.util.*;
    public final class SubmitAction extends Action {
      public ActionForward perform(ActionMapping mapping,
          ActionForm form,
          HttpServletRequest request,
          HttpServletResponse response) {
          DynaActionForm SubmitForm = (DynaActionForm) form;
         // blah
        // blah
    return (mapping.findForward("success"));
    }can ActionServlet use filter ?
    How do i use the Filter class in ActionServlet if i want to get filtered Aceess of the website ?

    Ok, this is how filters work.
    Typically the filter maps to '/*' and your action servlet maps to '/*.do'. So if you request 'login.do', then the filter would first be called. If it's not between 08:00 and 16:59, the request will be passed on to the action servlet, else it would be forwarded to the action servlet.
    There's no need to 'integrate' the filter into you action servlet.

  • How to get the Date in a particular format?

    Hi,
    How to get the Date in the below format? I will be passing the year in my method..
    2/10/2003 9:46:52 PM
    D/M/YYYY H:M:S A
    public Date getDate (String year) {
    Here i want to get the Date in this format
    2/10/<Passed Year> 9:46:52 PM
    Thanks

    This is my code
    public static Date getCalendar(Calendar calendar,int getYear) {
    String      formatted_date="";
         int year = getYear;
         int month = calendar.get(Calendar.MONTH+1);
         int day = calendar.get(Calendar.DATE);
         int hour = calendar.get(Calendar.HOUR);
         int min = calendar.get(Calendar.MINUTE);
         int sec = calendar.get(Calendar.SECOND);
         int am_pm =calendar.get(Calendar.AM_PM);
         formatted_date = month+"/"+day+"/"+year+" "+hour+":"+min+":"+sec+" PM";
         System.out.println("formatted_date is "+formatted_date);     
         o/p : formatted_date is 1/4/2006 1:44:21 PM
         SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
    //     DateFormat dateFormat =DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
         Date passdate = new Date();
         try {
              passdate = dateFormat.parse(formatted_date);
         } catch (ParseException e) {
              System.out.println("Invalid Date Parser Exception "+e.getLocalizedMessage()+"DateFormat is "+dateFormat);
              System.out.println("The Date inside the function is "+passdate+"and the year passed is "+year);
    o/p : The Date inside the function is Sat Apr 01 00:00:00 IST 2006and the year passed is 2006
         return passdate;
    Expected O/P is 3/1/2006 1:44:12 PM
         }

  • 10.1.3 Pro: How to get the selectedItem in a selectOneChoice?

    I have a selectOneChoice component on the JSP. It has a list of IDs from 1 to 100 and 19 is skipped (... 17, 18, 20, 21...). I tried the following code to get the real value of the selectedId.
    FacesContext fc = FacesContext.getCurrentInstance();
    ValueBinding valueBinding = fc.getApplication().createValueBinding(
    "#{bindings.RoyMainView1Ke.inputValue}");
    if(valueBinding != null){
    Object selectedId = valueBinding.getValue(fc);
    System.out.println(" selectedId is " + selectedId);
    }else{
    System.out.println(" selectedId is null");
    The problem is: if the seletedId is from 1 to 18, it works fine. But if it is 20, the selectedId is 19. It seems like the selectedId I get from the above code is the index, not the real value.
    Anybody know how to fix it? Thank you so much in advance.
    Best regards,
    Annie
    null

    This is my code
    public static Date getCalendar(Calendar calendar,int getYear) {
    String      formatted_date="";
         int year = getYear;
         int month = calendar.get(Calendar.MONTH+1);
         int day = calendar.get(Calendar.DATE);
         int hour = calendar.get(Calendar.HOUR);
         int min = calendar.get(Calendar.MINUTE);
         int sec = calendar.get(Calendar.SECOND);
         int am_pm =calendar.get(Calendar.AM_PM);
         formatted_date = month+"/"+day+"/"+year+" "+hour+":"+min+":"+sec+" PM";
         System.out.println("formatted_date is "+formatted_date);     
         o/p : formatted_date is 1/4/2006 1:44:21 PM
         SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
    //     DateFormat dateFormat =DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
         Date passdate = new Date();
         try {
              passdate = dateFormat.parse(formatted_date);
         } catch (ParseException e) {
              System.out.println("Invalid Date Parser Exception "+e.getLocalizedMessage()+"DateFormat is "+dateFormat);
              System.out.println("The Date inside the function is "+passdate+"and the year passed is "+year);
    o/p : The Date inside the function is Sat Apr 01 00:00:00 IST 2006and the year passed is 2006
         return passdate;
    Expected O/P is 3/1/2006 1:44:12 PM
         }

  • Please help getString()

    hi,
    this might sound like a question that shouln't have been asked but
    i'm new to java, studied it for a few months (haven't learnt any kind of programming languages before )and been assigned to do a project, tried my best at it but got stuck on this GetString() method
    what's wrong with this code
    i tried to compile it but came up with errors
    cannot find symbol
    symbol : method getString()
    location: class java.lang.String
    stm.setString(4,strdate.getString());
    cannot find symbol
    symbol : method strtimegetString()
    location: class javaproject
    stm.setString(5, strtimegetString());
    2 errors
    here's the code
    //javaproject.java
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import java.sql.*;
    public class javaproject extends JApplet implements ActionListener,Runnable
    JPanel panel; JLabel lname, lcode,lterm,ltime,ldate;
    JTextField tfname , tfcode;
    JButton bttsaved, bttcancel, bttclose;
    JComboBox cbterm;     
    String term[] ={"Semester A","Semester B","Semester C","Semester D"};
    String strdate, strtime ;
    Thread time;
    GregorianCalendar calendar;
    public void init()
         panel = new JPanel();
         lcode = new JLabel ("Code : ");
         lname = new JLabel("Name : ");
         lterm = new JLabel("Term : ");
         ltime = new JLabel();
         ldate = new JLabel();
         tfcode = new JTextField(20);
         tfname = new JTextField(20);
         cbterm = new JComboBox(term);
    bttsaved = new JButton(" Saved ");
    bttcancel = new JButton(" Cancel ");
    bttclose = new JButton(" Close ");
         calendar = new GregorianCalendar();
         time =new Thread(this);
         time.start();
         display();
         panel.add(ldate); panel.add(ltime);
         panel.add(lcode); panel.add(tfcode);
         panel.add(lname); panel.add(tfname);
         panel.add(lterm); panel.add(cbterm);
         panel.add(bttsaved); panel.add(bttcancel); panel.add(bttclose);
         getContentPane().add(panel);
         bttsaved.addActionListener(this);
         bttcancel.addActionListener(this);
         bttclose.addActionListener(this);
    public void run()
         for(;;)
         calendar = new GregorianCalendar();
              strtime = calendar.get(Calendar.HOUR)+":"+calendar.get(Calendar.MINUTE)
              +":"+calendar.get(Calendar.SECOND);
              ltime.setText(strtime);
              try
              time.sleep(1000);
              catch(InterruptedException e)
              showStatus("ThreadInterrupted");          
    public void display()
         strdate = calendar.get(Calendar.DATE) + "/" + (calendar.get(Calendar.MONTH)+1) + "/"+calendar.get(Calendar.YEAR);
         ldate.setText(strdate);
    public void actionPerformed(ActionEvent evt)
         if(evt.getSource() == bttcancel )
         tfcode.setText(" ");
         tfname.setText(" ");
         showStatus(" ..... Please enter new information ..... ");
         if(evt.getSource() == bttclose )
         System.exit(0);          
         if(evt.getSource() ==bttsaved )
         try
              String blankcode = tfcode.getText();
              if(blankcode.length() == 0)
                   showStatus("Student's code cannot be empty");
                   return;          
              String blankname = tfname.getText();
              if(blankname.length() == 0)
                   showStatus("..... Student's name cannot be empty ......");
              return;
              Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              Connection con;
              con = DriverManager.getConnection("jdbc:odbc:kayteej","sa", null);
              PreparedStatement stm;
              stm = con.prepareStatement("insert into Students values(?,?,?)");
              stm.setString(1,tfcode.getText());     
              stm.setString(2,tfname.getText());
              stm.setString(3,(String)cbterm.getSelectedItem());
              stm.setString(4,strdate.getString());
              stm.setString(5, strtimegetString());
              stm.executeUpdate();     
              showStatus("..... Please enter new information ..... ");
              JOptionPane.showMessageDialog(null, "Data Saved","Congrats!!",1);
         catch(Exception err)
              showStatus("Error occured while interacting with sql");
    //<Applet code="javaproject.class" width=800 height=600></applet>
    should i use the getString method or is it possible to use other type of methods. please help I'm really stuck
    Thank you in advance

    So when you run it, the code throws an exception? Then there's something wrong with your code, or with your setup.
    The exception's stack trace contains useful information which would help you (or us) figure out just what is wrong. Hopefully you have a catch-block that calls the printStackTrace() method of the exception.

Maybe you are looking for