E71x calendar displays 2 different meeting times

I have an e71x with an unusual problem. Meeting often have two different times in the editing mode.  Here is an example:
I select a meeting for November 18 (this is a real example from the past) and it shows 1pm to 5pm.  The meeting time has changed, so I want to edit it. It repeats weekly.  When I select Edit>This occurance only the meeting time is 1pm to 5pm.   When I select Edit>All occurances the meeting time is 3pm to 4pm.
As it turns out, 3pm to 4pm is the new meeting time, so obviously I tried to edit this entry before.  But on the Calendar View only the 1pm time shows up.
This is crazy!  Why would it even show 2 times at all?
I'd like the Calendar to show only 1 time.  Is there any way to correct this?
Roger

Snick wrote:
Is there any way of changing the day view where currently a meeting, even though booked for 2-hours, displays as 1-hour?
Maybe I am missing something here in your question, but you are asking that if you schedule a meeting in your calendar for two hours, you want it only to display as a one hour meeting?
No, the BB calendar will display the amount of time you designate... if you book it for two hours it will display for two hours. If you schedule it for one hour, your calendar will display a one hour time block.
If you want it only to display a one hour time block, schedule the meeting for one hour.
1. If any post helps you please click the below the post(s) that helped you.
2. Please resolve your thread by marking the post "Solution?" which solved it for you!
3. Install free BlackBerry Protect today for backups of contacts and data.
4. Guide to Unlocking your BlackBerry & Unlock Codes
Join our BBM Channels (Beta)
BlackBerry Support Forums Channel
PIN: C0001B7B4   Display/Scan Bar Code
Knowledge Base Updates
PIN: C0005A9AA   Display/Scan Bar Code

Similar Messages

  • Multiple Fiscal Calendars Displayed in Subject Area Time Dimension

    Hi all,
    Thanks for taking the time to review my post.
    Environment
    Oracle BI Applications 7.9.6 Financial Analytics
    Oracle E-Business Suite 11.5.10
    Query
    The Time dimension on my Subject Areas (Financial Analytics) are showing more period data than I expected.
    I have configured one Enterprise Calendar (WPG_Calendar) that I set in the DAC parameters - $$GBL_CALENDAR_ID (WPG_Calendar~Month) and $$GBL_DATASOURCE_NUM_ID (4). The warehouse Enterprise Calendar table W_ENT_PERIOD_D is populating with the periods as configured in EBS for that calendar(Jan-09, Feb-0, Mar-09, etc). I noticed that the Multiple Fiscal W_MCAL_PERIOD_D table is also been populated with the Enterprise Calendar data PLUS, the Seeded EBS calendar (JEBE_MONTH_VAT) and a generated Calendar that appears to be a 5-4-5-4 Calendar (Jan-01-09, Jan-02-09, Jan-03-09, etc). The trouble is these W_MCAL_PERIOD_D periods and dates are all coming through in my Time dimensions and make it confusing for the Answers Users when choosing a Time dimension.
    Also, for columns W_CURRENT_MCAL_PERIOD_CODE, W_CURRENT_MCAL_QTR_CODE, W_CURRENT_MCAL_YEAR_CODE there are rows with Current, Previous and Next populated that span these different periods as you would expect, but I'm concerned these return multiple rows for Filters Current Fiscal Quater, Current Fiscal Year.
    Funnily enough, W_CURRENT_MCAL_MONTH_CODE has nothing populated (NULLs for all rows).
    Your comments are most welcome.
    Kind Regards,
    Gary.

    The filtering of the calendar can be done directly on the logical layer.
    for the logical dimension "Dim - Date Fiscal Calendar", Logical Table Source "Dim_W_MCAL_PERIOD_D_Fiscal_Period"
    set the content as :
    "Oracle Data Warehouse".Catalog.dbo.Dim_W_MCAL_PERIOD_D_Fiscal_Period.MCAL_CAL_WID = VALUEOF("MY_MCAL_WID")
    and setup the repository variable MY_MCAL_WID to match with your calendar wid.
    If your calendar depends on any context then you can use session variable instead of repository variable

  • I am having trouble with the calendar displaying incorrect dates and times

    I am currently receiving calendar invites that i know are displaying incorrectly in my calendar and i am unsure how to fix this.

    Yes its all correct. I have just discovered that a separate calendar was set up with incorrect settings from the originator. I have checked all my settings and I'm good to go. thanks for your response

  • Why my calendar display different there is one day difference from different  when I see main screen and open the calendar

    See my Why my calendar display different there is one day difference from different  when I see main screen and open the calendar

    I too am having the same issue only I am in Regina, Canada.  iCloud appears to think Regina, Canada is in the Central time zone which it is, but it does not use Daylight Savings time.  My PC is Windows 7 and I am using Outlook 2010.  I have iCloud on iPhone 5 and iPad 2.   Terribly frustrating!

  • Outlook 2013 calendar displays wrong time on iPhone calendar

    I would like to start by saying this is definitely NOT a time zone issue.  I have researched the internet and apple and have not been able to find a solution as of yet.  This is also not restricted to my phone.  We have our work calendar in Outlook 2013.  When it syncs to my iPhone 5c and my boss' iPhone 4s it displays the time of the event exactly 7 hours earlier.  I have checked the Outlook time zone and the iPhone time zone (in both places, general and the mail/contacts/calendar settings).  They are all displayed in the current time zone.  I have selected and deselected the auto setting for the time zone as well.  Nothing has worked!  I'm wondering if it has something to do with an update.  It was working just fine for years and now all of a sudden displays the wrong time.  PLEASE HELP! Thanks.

    Hi Cath,
    Yes, it is a by default settings to delete meeting requests after it is responded. As what Vasil says, we can change the following Outlook settings to leave the meeting request message in Inbox:
    1. Click File > Options.
    2. In Mail option, on Send messages part, uncheck Delete meeting requests and notifications from Inbox after responding option.
    3. Click OK to save the settings.
    Then check whether the issue persists.
    Regards,
    Winnie Liang
    TechNet Community Support

  • Is there a way to create a custom screensaver with pics/slides that display for different amounts of time?

    Is there a way to create a custom screensaver with pics/slides that display for different amounts of time? Or even add a "video slide" into the screensaver?
    My business has 3 TVs displayed in our lobby, each with its own apple TV and they are all linked to the same photo stream. Currently the Atv screensaver displays the photostream pictures of our products for the default 3 seconds. We just added pics/slides that now display messages and useful info for our customers but I want that info to be displayed for a longer period of time than the pictures to give people a chance to read it.
    I tried using flickr and powerpoint as a work around but no luck.  I created a slide in powerpoint with play length of 15 secs and saved it as a wmv file.  I added that file to a "screensaver" set in flickr and pointed the Atv screensaver to that flickr set.  It still displays everything, pics and the wmv file at the default 3 sec.
    I know I can increase the duration of all pics in the screensaver to display for longer but the goal is to have the pics display at 3 secs and the info slides to display at 15 secs.

    Welcome to the Apple Community.
    No that's not possible.
    If you have any suggestions that you think might enhance the Apple TV you can send Apple your feedback here 

  • IOS 6 calendar display jumps to different dates????

    iOS 6 calendar display jumps around. On my iPod touch 5, iOS 6, after editing an event, the display jumps to random list dates before ending up on the correct date.  These gyrations take several seconds and will dwell on the wrong date for a while.

    Try:
    - Reset the iOS device. Nothing will be lost
    Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - Reset all settings
    Go to Settings > General > Reset and tap Reset All Settings.
    All your preferences and settings are reset. Information (such as contacts and calendars) and media (such as songs and videos) aren’t affected.
    - Restore from backup
    - Restore to factory settings/new iOS device.

  • I would like to add content that changes on a calendar basis, such as 'thought for the day". It can then display a different text or image on a nominated day. Can this be done? Robert.

    I would like to add content that changes on a calendar basis, such as 'thought for the day". It can then display a different text or image on a nominated day. Can this be done? Robert.

    OK Thanks Brad.
    I could use Tockify of course, but wanted to create the same things on an existing site.
    I do not know how to copy the code and get it onto Muse, but that’s OK for now. I will work something else out.
    Robert

  • Calendar Display - Hours Spacing

    When I first had my Q10, the Calendar, when in the "Day" mode, displayed the time in 1/2 hour increments.  Now it has switched to displaying in 1 hour increments.  This means that the words saying what the appointment is are not visible, in the case of those appointments that are less than a full hour long.  I have to open up the appointment to see what it is.  So I would like to change the display back to where the hours are more widely spread from top to bottom.  I have not figured out where that secret setting can be found.  Does anybody know?

    You can try changing the color settings in Outlook.
    In Calendar, click Calendar Coloring, and then click Edit Labels. 
    You can also try changing the background, or creating a new Google Calendar with a different color setting.  

  • 8703e Calendar Display

    I have just upgraded to Version 4.2.1.110.  Naturally, all my display settings changed (urg!!). 
    I am having some difficulties in the calendar with some of the settings:-
    1.  Although I have set the "Show End Time in Agenda View" to "No", it still displays the end time;
    2.  On the right side of the display, beside each scheduled item, whether specific times set or full day, shows an interlocking red page.  What is this?

    You can try changing the color settings in Outlook.
    In Calendar, click Calendar Coloring, and then click Edit Labels. 
    You can also try changing the background, or creating a new Google Calendar with a different color setting.  

  • How can I share calendars between two different people?

    I am trying to share my ICAL with my wife and she wants to do the same with me. For some reason I cannot find the path to allow us to see each otjer's calendars. Any ideas?
    Thanks
    Don

    Hi,
    According to your post, my understanding is that you wanted share data between two forms on different lists.
    To show external  information on the calendar event, there are two methods: Calculated column, workflow. You can refer to:
    A Simple Guide to Show More Information on a Calendar Event
    I recommend to use workflow to achieve what you want. But you need to create a people column to display the manager.
    You can create a workflow associated to the "Out of Office Request" list, add action to Start Approve Process. If the manager approves the request, you can create a item in the calendar, and then update the people column and the title column.
    Then the calendar will display the Title, date/time and the manager.
    To create a view for each manager, you need to modify the Filter. You can use the people column is equal to the manager name or the Title contains the manager name.
    Thank you for your understanding.
    Best Regards,
    Linda Li
    Linda Li
    TechNet Community Support

  • Meeting time mismatch between MS Outlook 2011 and iCal

    Devices:
    Mac Air running OS X 10.10 with MS Office 2011 (Outlook via IMAP) - no Exchange.
    Also running Mail concurrently via IMAP.
    iPhone 6+ running iOS 8.2.
    Time Zone:
    New Zealand on daylight saving - UTC/GMT +13:00
    Background:
    I have using both Microsoft and Apple Mail and Calendar (iCal) platforms concurrently on various MacBooks etc for at least 5 years i.e. previously MS Entourage 2008 (?) now Outlook 2011. Once upon a time Entourage/Outlook & Mail/iCal used to sync quite nicely via iTunes and sync services but then that functionality was taken away from us in Mavericks. There was a lot of fuss about this!
    I managed to find a work around that worked for me. Far more detail can be found in a previous thread https://discussions.apple.com/thread/5479205  but in short I found I could drag calendar and contacts from Outlook to iCal & Contacts and vice versa without too much fuss for my volume of meetings etc.
    Once meetings and contacts were in iCal and Contacts then iCloud made sure they synced with my iPhone - YAY!!!
    THAT ALL CHANGED AGAIN WITH YOSEMITE !!!!!!
    Problem:
    It would seem that since upgrading to Yosemite I am experiencing serious TIME ZONE discrepancies between Meeting requests in Outlook and OS X / IOS.
    Example:
    1. Meeting request created in Outlook from external 3rd party contact received for Sunday, 23 November 2014 10.00am - 12.00pm
    Shows correctly in Outlook
    OS X & iOS show event exactly 13 hours later @ Sunday, 23 November 11.00pm - 1.00am
    This is exactly the time difference between GMT/UTC and NZT (or GMT/UTC +13:00)
    Because meeting/event is from a 3rd party the date/time cannot be edited.
    Accepting locks it in at the wrong time which ends up being synced to iPhone.
    2. Meeting request created by 'self' in Outlook and dragged onto iCal in OS X for Saturday, 13 December 2014 3.30pm - 4.00pm
    Shows correctly in Outlook (as you'd expect!)
    The instant its dragged across the iCal 'Adding a new event' pop up box appears.
    Click 'OK' and for literally 2 seconds it's displayed as the right day and time ...
    BUT THEN it jumps (moves) to Saturday, 14 December 2014 4.30am - 5.00am!!! Exactly 13 hours later.
    When iOS updates via iCloud it also shows the event @ Saturday, 14 December 2014 4.30am - 5.00am.
    Log on to iCloud (web calendar) and it's the same.
    Again this is exactly the time difference between GMT/UTC and NZT (or GMT/UTC +13:00).
    NOW CHECK THIS OUT - double click event in iCal OR iCloud web calendar and it shows the details as "13 December 3.30pm - 4.00pm (GMT)"
    See images -
    3. Meeting request created by 'self' in Outlook and dragged onto iCal in OS X for Friday, 7 December 2014 12.00pm - 1.30pm PLUS added and sent to invitee
    Shows correctly in Outlook (as you'd expect!)
    The instant its dragged across the iCal 'Adding a new event' pop up box appears.
    Click 'OK' and for literally 2 seconds it's displayed as the right day and time ...
    BUT THEN it jumps (moves) to Saturday, 8 November 2014 1.00am - 2.30am.
    So everything else is as previously described ... the EXCEPTION here is the person who I sent the invite to.
    They received it in OS X Mail and iOS - it also appeared in their calendars Saturday, 8 November 2014 1.00am - 2.30am rather than the more suitable time for a Friday business lunch!!
    Given this worked fine under Mavericks and the only thing to have changed is an upgrade to Yosemite then there has to be a bug in Yosemite??
    I've attempted to be as thorough with my testing as possible but whilst I am in IT Sales and Business Dev, I am not an engineer!! Therefore I am very keen to hear from any far more intelligent being that suggest other tests, what I should do next or better still how to fix it !!!!
    Now I shall sit and wait for the arrival of great and profound wisdom ... yes, still smiling but I don't know for how long!!

    So no replies/comments but lots of views ... either means I haven't reached someone who's prepared to tackle this one or everyone thinks I'm a Muppet for doing things the way I do!!
    Because of the many views and at least 2 persons who have indicated they have the same issue ...
    UPDATE:
    So much research!!! Would appear that Outlook is designed to send calendar events in UTC/GMT time irrespective of local - don't quote me! That being the case that would explain why the events I had issues with turn up with showing GMT. Would also suggest that for some reason iCal cannot see inside to translate the actual time ... anyway ... moving on.
    So at this point I need to say I have turned off in Mac Mail preferences "Add invitations to Calendar - Automatically" and set to "Never" ... I will try testing with that "on" again later.
    For now here's a kludged workaround for at least the process that I use i.e. dragging meetings from Outlook to iCal to sync via iCloud to my iPhone.
    Before I would drag the Outlook event (straight from Outlook's calendar) onto the iCal icon (sorry realize I hadn't perhaps been explicit on that before) ... that would then open iCal if not already open and then 'pop' the 'Adding a new event' box ... click 'OK' and it'd be entered with the same alert time etc ... that once worked, then broke hence this post!!
    So what I've found that does work (with some shortcomings) is (and easier if you're running dual screens!!):
    Open iCal - best if you use Day view
    Drag the Outlook event to that day and to the correct time
    N.B.: Duration, Category and Alert information is lost
    Open event in iCal and edit the above
    Syncs immediately to iCloud and in its own good time to iPhone
    I have tested this against my original examples:
    Example 1 - Works for events/meetings received from external Outlook source - you can open and edit the time and alerts. Not sure if it creates any grief or extra clutter at the senders end!! Guess I'll hear about that soon enough.
    Example 2 - Works for events/meetings created by me in Outlook and dragged over - same deal - still have to edit duration and alerts etc.
    Example 3 - Hmmmm ... haven't tried adding an invitee who I know is an iCal only user yet. I expect that if sent from Outlook he's still going to have it show up wrong at his end so will be a set of instructions and training I expect. I have an idea that may work ... will have to test.
    SORRY - I said it was a Kludge.
    I will see if this approach remains stable for a bit before turning back on the "Add invitations to Calendar - Automatically" setting in Mail.
    I'll report back again after that.

  • Messagebox that displays a different randum number every 2 secs

    well im having trouble with putting a messagebox that displays a different randum number every 2 secs and closes with a close button. it goes in the print menu option of this simple text editor,you shoud also be able to work in the background while this message box is been displayed.
    import javax.swing.*;
    import javax.swing.text.*;
    import javax.swing.text.rtf.*;
    import javax.swing.event.*;
    import javax.swing.filechooser.*;
    import javax.swing.undo.*;
    import java.util.Timer;
    import java.util.TimerTask;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.util.*;
    import java.beans.*;
      -------------------| Simple Text Editor example application using Java 1.3 with Swing |--------------
    public class SimpleTextEditor extends JFrame
            private JTextPane textpane;
            private JMenuBar mb;
            private JFileChooser chooser,picChooser;
            private Hashtable actions;
            private JPopupMenu popup;
            private JMenuItem exit, newDoc, save, open, saveAs,print;
            private About ab;
            private StyledEditorKit edkit;
            private RTFEditorKit rtfkit;
            private DefaultStyledDocument doc;
            private MyDocumentListener doclistener;
           private MyUndoableEditListener undolistener;
             //Useful variables
            private String filename="untitled1.txt",filetype=".txt";
            private File thisfile;
            protected String FileFormats[],FileDescriptions[],PicFileFormats[],PicFileDescriptions[];
            protected boolean DocumentIsUnedited=true, DocumentIsSaved=false;
            public static int SQUARE=0,TRIANGLE=1,CIRCLE=2;
            public String newline="\n";
            protected UndoManager undo ;
            protected UndoAction undoAction;
            protected RedoAction redoAction;
            // These are the actions used in the menus and on the toolbar
            protected Action bold, italic, underline, alignleft, alignright, aligncentre;
            protected Action spellchecker, alignjustify, more, cut, copy, paste, tools[];
            public SimpleTextEditor()
                    super("SimpleTextEditor - untitled1.rtf");
                    this.setLocation(200,200);
                    this.setIconImage(getMyIcon("Icon.gif").getImage());
                    getContentPane().setLayout(new BorderLayout());
                    undo = new UndoManager();
                    //Set up the file formats and file choosers etc
                    FileFormats = new String[]{".rtf",".txt",".java",".bat"};
                    FileDescriptions = new String[]{"Rich Text Format Files","Text Files","Java Source Files","DOS Batch Files"};
                    PicFileFormats = new String[]{".gif",".bmp",".jpg"};
                    PicFileDescriptions = new String[]{"Gif Images","Bitmap Images","JPEG Images"};
                    chooser = new JFileChooser();
                    picChooser = new JFileChooser();
                    picChooser.setAccessory(new ImagePreview(picChooser));
                    javax.swing.filechooser.FileFilter defaultFilter = new SimpleFilter(FileFormats[0],FileDescriptions[0]);
                    javax.swing.filechooser.FileFilter defaultPicFilter = new SimpleFilter(PicFileFormats[0],PicFileDescriptions[0]);
                    for(int i=1;i<FileFormats.length;i++){
                            chooser.addChoosableFileFilter(new SimpleFilter(FileFormats,FileDescriptions[i]));
    for(int i=1;i<PicFileFormats.length;i++){
    picChooser.addChoosableFileFilter(new SimpleFilter(PicFileFormats[i],PicFileDescriptions[i]));
    chooser.setFileFilter(defaultFilter);
    picChooser.setFileFilter(defaultPicFilter);
    File working = new File("C:/Documents");
    if(!working.exists()){
    working= new File("C:/MyDocuments");
    if(!working.exists()) working = new File("C:/");
    if(working.exists()) {
    chooser.setCurrentDirectory(working);
    picChooser.setCurrentDirectory(working);
    // Set up Document object and Editor kits
    doc = new DefaultStyledDocument();
    edkit = new StyledEditorKit();
    rtfkit = new RTFEditorKit();
    // Set up Listener objects
    doclistener= new MyDocumentListener();
    undolistener= new MyUndoableEditListener();
    doc.addDocumentListener(doclistener);
    doc.addUndoableEditListener(undolistener);
    //Set up main GUI content
    textpane=new JTextPane(doc);
    textpane.setPreferredSize(new Dimension(400,400));
    textpane.setMinimumSize(new Dimension(400,400));
    JScrollPane scroller=new JScrollPane(textpane);
    scroller.setPreferredSize(new Dimension(400,400));
    mb=new JMenuBar(); // Create a menu bar
    JMenu File=new JMenu("File");
    JMenu Help=new JMenu("Help");
    //Sort out Actions etc
    createActionTable(textpane);
    createToolbarActions();
    JMenu Style=createStyleMenu();
    undoAction = new UndoAction();
    redoAction = new RedoAction();
    //Create Style, Edit and Format menus + Toolbar
    JMenu Edit=createEditMenu();
    JMenu Format=createFormatMenu();
    JMenu Insert = createInsertMenu();
    JToolBar toolbar = createToolbar();
    getContentPane().add("North",toolbar);
    // set up main menu items with ActionListeners
    newDoc=new JMenuItem("New");
    newDoc.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e)
    newDoc();
    exit=new JMenuItem("Exit");
    exit.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e)
    exit();
    print=new JMenuItem("Print");
    print.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e)
    print();
    save=new JMenuItem("Save");
    save.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e)
    save();
    saveAs=new JMenuItem("Save As...");
    saveAs.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e)
    saveas();
    open=new JMenuItem("Open...");
    open.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e)
    open();
    JMenuItem about=new JMenuItem("About");
    about.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e)
    ab=new About(SimpleTextEditor.this);
    ab.show();
    ab.setLocation(400,300);
    // Create the popup menu
    popup = createEditMenu().getPopupMenu();
    popup.addSeparator();
    popup.add(createStyleMenu());
    popup.add(createFormatMenu());
    textpane.add(popup);
    // set up Help and File menus
    Help.add(about);
    File.add(newDoc);
    File.add(open);
    File.add(print);
    File.add(save);
    File.add(saveAs);
    File.addSeparator();
    File.add(exit);
    // add the menus to the menubar
    mb.add(File);
    mb.add(Edit);
    mb.add(Format);
    mb.add(Style);
    mb.add(Insert);
    mb.add(Help);
    this.setJMenuBar(mb);
    getContentPane().add("Center",scroller);
    // Add mouse Listener to the textpane for popup events
    textpane.addMouseListener(new MouseAdapter(){
    public void mousePressed(MouseEvent e)
    if(e.isPopupTrigger())
    popup.show(textpane, e.getX(), e.getY());
    e.consume();
    public void mouseReleased(MouseEvent e)
    if(e.isPopupTrigger())
    popup.show(textpane, e.getX(), e.getY());
    e.consume();
    //-----------------| Main active methods |------------------
    public void exit()// Main Exit method
    if(DocumentIsUnedited){//Check that document is saved/unedited etc
    dispose();
    setVisible(false);
    System.exit(0);
    else{
    switch(showNotSavedDialog("Exit")){
    case JOptionPane.YES_OPTION: save(); exit(); break;
    case JOptionPane.NO_OPTION: DocumentIsUnedited=true;exit();break;
    case JOptionPane.CANCEL_OPTION: break;
    public void newDoc()//Method to create new documents
    if(DocumentIsUnedited){
    initDoc();
    filename="untitled.txt";
    filetype=".txt";
    resetTitle();
    else
    switch(showNotSavedDialog("New Document")){
    case JOptionPane.YES_OPTION: save(); newDoc(); break;
    case JOptionPane.NO_OPTION: DocumentIsUnedited=true;newDoc();break;
    case JOptionPane.CANCEL_OPTION: break;
    private void initDoc()// Helper method to initialize a new document
    doc = null;
    doc = (DefaultStyledDocument)edkit.createDefaultDocument();
    doc.addDocumentListener(doclistener);
    textpane.setStyledDocument(doc);
    public void print()
    new TimerTestFrame();
    class TimerTestFrame extends JFrame
    Timer timer;
    TimerTestFrame()
    super();
    timer = new Timer(true);
    TimerTask task = new MessageTimer(TimerTestFrame.this);
    timer.schedule(task,2000,2000);
    class MessageTimer extends TimerTask
    Component parent;
    public MessageTimer(Component parent)
    this.parent = parent;
    public void run()
    int randnum = (1 +(int)(Math.random()*10));
    JOptionPane.showMessageDialog(parent,""+randnum,"Timer Message",JOptionPane.INFORMATION_MESSAGE);
    public void saveas()
    int n = chooser.showSaveDialog(this);
    if(n==0){
    filename=chooser.getSelectedFile().getName();
    boolean ext = false;
    setFiletype();
    thisfile = new File(chooser.getCurrentDirectory(),filename);
    DocumentIsSaved=true;
    save();
    resetTitle();
    repaint();
    public void save()// Save method. Used by "Save As..." as well
    if( DocumentIsSaved)
    try
    FileOutputStream out = new FileOutputStream(thisfile);
    if((filetype.equals(".rtf"))||(filetype.equals(".doc"))){
    rtfkit.write(out,doc,0,doc.getLength());
    else edkit.write(out,doc,0,doc.getLength());
    catch(Exception e)
    System.out.println(""+e.getMessage()+"");
    DocumentIsUnedited=true;
    else saveas();
    public void open()// Find a file and read it into the document
    if(DocumentIsUnedited){
    int n = chooser.showOpenDialog(this); // get the outcome of the dialog
    if(n==0){
    File file = chooser.getSelectedFile();
    filename=chooser.getName(file);
    setFiletype();
    resetTitle();
    initDoc();
    try
    FileInputStream in= new FileInputStream(file);
    if(filetype.equals(".rtf")){
    rtfkit.read(in,doc,0);
    edkit.read(in,doc,0);
    catch(Exception e)
    System.out.println(""+e.getMessage()+"");
    thisfile= new File(chooser.getCurrentDirectory(),chooser.getSelectedFile().getName());
    DocumentIsUnedited=true;
    DocumentIsSaved=true;
    resetTitle();
    repaint();
    else
    switch(showNotSavedDialog("Open")){
    case JOptionPane.YES_OPTION: save(); open(); break;
    case JOptionPane.NO_OPTION: DocumentIsUnedited=true; open(); break;
    case JOptionPane.CANCEL_OPTION: break;
    private void setFiletype()// Helper method to get the filetype of saved/opened documents
    filetype=null;
    for(int i=0;i<FileFormats.length;i++){
    if(filename.toLowerCase().endsWith(FileFormats[i])) filetype = FileFormats[i];
    else{
    for(i=0;i<filename.length();i++){
    if(filename.toLowerCase().charAt(i)=='.')
    filetype=filename.substring(i);
    if(filetype==null) filetype=".txt";
    private void resetTitle()
    this.setTitle("SimpleTextEditor - "+filename);
    private ImageIcon getMyIcon(String filename){
    ImageIcon pic = new ImageIcon("Images/"+filename);
    return pic;
    private int showNotSavedDialog(String title)// Helper method to create "Save? Yes/No/Cancel" dialogs
    int n = JOptionPane.showConfirmDialog(this,"The last document has not been saved. \nDo you want to save it first?",
    title,
    JOptionPane.YES_NO_CANCEL_OPTION,
    JOptionPane.QUESTION_MESSAGE);
    return n;
    //-----------------| Listeners and Helper classes |----------------
    protected class MyDocumentListener implements DocumentListener
    public void insertUpdate(DocumentEvent e) {
    SimpleTextEditor.this.DocumentIsUnedited=false;
    public void removeUpdate(DocumentEvent e) {
    SimpleTextEditor.this.DocumentIsUnedited=false;
    public void changedUpdate(DocumentEvent e) {
    SimpleTextEditor.this.DocumentIsUnedited=false;
    protected class MyUndoableEditListener implements UndoableEditListener {
    public void undoableEditHappened(UndoableEditEvent e) {
    //Remember the edit and update the menus.
    undo.addEdit(e.getEdit());
    undoAction.updateUndoState();
    redoAction.updateRedoState();
    //Helper class for FileFilter, allows a description to be assigned to a filetype
    protected class SimpleFilter extends javax.swing.filechooser.FileFilter
    String type,des;
    public SimpleFilter(String type, String des)
    this.des=des;
    this.type=type;
    public boolean accept(File f){
    if(f.isDirectory())return true;
    else{
    if(f.getName().toLowerCase().endsWith(type)) return true;
    else return false;
    public String getDescription(){
    return des;
    //------------| Methods to help create menus and toolbar |--------------
    protected JMenu createStyleMenu()
    JMenu menu = new JMenu("Style");
    menu.add(bold);
    menu.add(italic);
    menu.add(underline);
    menu.addSeparator();
    menu.add(new StyledEditorKit.FontSizeAction("12", 12));
    menu.add(new StyledEditorKit.FontSizeAction("14", 14));
    menu.add(new StyledEditorKit.FontSizeAction("18", 18));
    menu.addSeparator();
    menu.add(new StyledEditorKit.FontFamilyAction("Serif","Serif"));
    menu.add(new StyledEditorKit.FontFamilyAction("SansSerif","SansSerif"));
    menu.addSeparator();
    Action red = new StyledEditorKit.ForegroundAction("Red", new Color(255,0,0));
    red.putValue(Action.SMALL_ICON,getMyIcon("red.gif"));
    menu.add(red);
    Action green = new StyledEditorKit.ForegroundAction("Green", new Color(0,150,0));
    green.putValue(Action.SMALL_ICON,getMyIcon("green.gif"));
    menu.add(green);
    Action blue = new StyledEditorKit.ForegroundAction("Blue", new Color(0,50,150));
    blue.putValue(Action.SMALL_ICON,getMyIcon("blue.gif"));
    menu.add(blue);
    Action black = new StyledEditorKit.ForegroundAction("Black", new Color(0,0,0));
    black.putValue(Action.SMALL_ICON,getMyIcon("black.gif"));
    menu.add(black);
    menu.add(more);
    return menu;
    protected JMenu createEditMenu() {
    JMenu menu = new JMenu("Edit");
    menu.add(undoAction);
    menu.add(redoAction);
    menu.addSeparator();
    menu.add(cut);
    menu.add(copy);
    menu.add(paste);
    menu.addSeparator();
    Action selectall=getActionByName(DefaultEditorKit.selectAllAction);
    selectall.putValue(Action.NAME, "Select All");
    menu.add(selectall);
    return menu;
    protected JMenu createFormatMenu(){
    JMenu menu = new JMenu("Format");
    menu.add(spellchecker);
    menu.add(alignleft);
    menu.add(alignright);
    menu.add(aligncentre);
    menu.add(alignjustify);
    return menu;
    protected JMenu createInsertMenu(){
    JMenu menu = new JMenu("Insert");
    Action insertimage = new InsertImageAction(this);
    menu.add(insertimage);
    Action insertdate = new InsertDateAction();
    menu.add(insertdate);
    Action insertline = new InsertLineAction();
    menu.add(insertline);
    JMenu bullets =new JMenu("Bullet Points");
    bullets.add(new InsertBulletAction(CIRCLE,"Circle"));
    bullets.add(new InsertBulletAction(TRIANGLE,"Triangle"));
    bullets.add(new InsertBulletAction(SQUARE,"Square"));
    menu.add(bullets);
    return menu;
    public JToolBar createToolbar(){
    JToolBar bar= new JToolBar();
    JButton newbutton=new JButton(getMyIcon("new.gif"));
    newbutton.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e)
    newDoc();
    bar.add(newbutton);
    JButton savebutton=new JButton(getMyIcon("save.gif"));
    savebutton.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e)
    save();
    bar.add(savebutton);
    JButton openbutton=new JButton(getMyIcon("open.gif"));
    openbutton.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e)
    open();
    bar.add(openbutton);
    bar.addSeparator();
    for(int i=0;i<tools.length;i++){
    JButton button=new JButton();
    button.setAction(tools[i]);
    button.setIcon(getMyIcon(tools[i].getValue(Action.NAME)+".gif"));
    button.setText("");
    bar.add(button);
    if((i==2)||(i==6))bar.addSeparator();
    return bar;
    public void createToolbarActions(){
    bold = new StyledEditorKit.BoldAction();
    bold.putValue(Action.NAME, "Bold");
    italic = new StyledEditorKit.ItalicAction();
    italic.putValue(Action.NAME, "Italic");
    underline = new StyledEditorKit.UnderlineAction();
    underline.putValue(Action.NAME, "Underline");
    more = new MoreColorsAction();
    cut = getActionByName(DefaultEditorKit.cutAction);
    cut.putValue(Action.NAME, "Cut");
    copy = getActionByName(DefaultEditorKit.copyAction);
    copy.putValue(Action.NAME, "Copy");
    paste = getActionByName(DefaultEditorKit.pasteAction);
    paste.putValue(Action.NAME, "Paste");
    alignleft = new StyledEditorKit.AlignmentAction("Left Justify",StyleConstants.ALIGN_LEFT);
    alignright = new StyledEditorKit.AlignmentAction("Right Justify",StyleConstants.ALIGN_RIGHT);
    aligncentre = new StyledEditorKit.AlignmentAction("Align Centre",StyleConstants.ALIGN_CENTER);
    alignjustify = new StyledEditorKit.AlignmentAction("Fully Justify",StyleConstants.ALIGN_JUSTIFIED);
    spellchecker = new StyledEditorKit.AlignmentAction("Spell Checker",StyleConstants.ALIGN_JUSTIFIED);
    tools = new Action[]{  cut, copy, paste, bold, italic, underline, more, alignleft, alignright, aligncentre, alignjustify, spellchecker };
    // helper methods to enable menu creators to get their actions by name
    private void createActionTable(JTextComponent textComponent) {
    actions = new Hashtable();
    Action[] actionsArray = textComponent.getActions();
    for (int i = 0; i < actionsArray.length; i++) {
    Action a = actionsArray[i];
    actions.put(a.getValue(Action.NAME), a);
    private Action getActionByName(String name) {
    return (Action)(actions.get(name));
    //----------------| Custom Actions |--------------------
    class InsertImageAction extends AbstractAction {
    protected SimpleTextEditor parent;
    public InsertImageAction(SimpleTextEditor parent){
    super("Image...");
    this.parent=parent;
    public void actionPerformed(ActionEvent e) {
    int n = parent.picChooser.showOpenDialog(parent);
    if(n==0){
    String filename=picChooser.getSelectedFile().getName();
    File file = new File(picChooser.getCurrentDirectory(),filename);
    Icon pic = new ImageIcon(file.getAbsolutePath());
    textpane.insertIcon(pic);
    SimpleTextEditor.this.repaint();
    class InsertDateAction extends AbstractAction {
    public InsertDateAction(){
    super("Date");
    public void actionPerformed(ActionEvent ble) {
    Calendar c= Calendar.getInstance();
    String[] months= new String[]{"01","02","03","04","05","06","07","08","09","10","11","12"};
    textpane.replaceSelection(c.get(c.DAY_OF_MONTH)+"/"+months[c.get(c.MONTH)]+"/"+c.get(c.YEAR));
    class InsertLineAction extends AbstractAction {
    public InsertLineAction(){
    super("Horizontal line");
    public void actionPerformed(ActionEvent e) {
    Icon pic = new ImageIcon("Images/line.gif");
    textpane.insertIcon(pic);
    class InsertBulletAction extends AbstractAction {
    protected int type;
    protected String filenames[] = new String[]{"square.gif","triangle.gif","circle.gif"};
    public InsertBulletAction(int type,String name){
    super(name);
    this.type=type;
    this.putValue(SMALL_ICON,new ImageIcon("Images/"+filenames[type]));
    public void actionPerformed(ActionEvent e) {
    Icon pic = new ImageIcon("Images/"+filenames[type]);
    textpane.insertIcon(pic);
    textpane.replaceSelection(" ");
    class MoreColorsAction extends AbstractAction {
    public MoreColorsAction(){
    super("More Colors");
    public void actionPerformed(ActionEvent e){
    AttributeSet as = textpane.getCharacterAttributes();
    SimpleAttributeSet sas = new SimpleAttributeSet(as);
    Color newColor = JColorChooser.showDialog(
    SimpleTextEditor.this,
    "C

    Here you go guys:
    Peace!
    import javax.swing.*;
    import javax.swing.Timer;
    import javax.swing.border.BevelBorder;
    import javax.swing.text.*;
    import javax.swing.text.rtf.*;
    import javax.swing.event.*;
    import javax.swing.filechooser.*;
    import javax.swing.undo.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.util.*;
    import java.beans.*;
      -------------------| Simple Text Editor example application using Java 1.3 with Swing |--------------
    public class SimpleTextEditor extends JFrame
        private JTextPane textpane;
        private JMenuBar mb;
        private JFileChooser chooser,picChooser;
        private Hashtable actions;
        private JPopupMenu popup;
        private JMenuItem exit, newDoc, save, open, saveAs,print;
        private About ab;
        private StyledEditorKit edkit;
        private RTFEditorKit rtfkit;
        private DefaultStyledDocument doc;
        private MyDocumentListener doclistener;
        private MyUndoableEditListener undolistener;
        //Useful variables
        private String filename = "untitled1.txt",filetype = ".txt";
        private File thisfile;
        protected String FileFormats[],FileDescriptions[],PicFileFormats[],PicFileDescriptions[];
        protected boolean DocumentIsUnedited = true, DocumentIsSaved = false;
        public static int SQUARE = 0,TRIANGLE = 1,CIRCLE = 2;
        public String newline = "\n";
        protected UndoManager undo;
        protected UndoAction undoAction;
        protected RedoAction redoAction;
        // These are the actions used in the menus and on the toolbar
        protected Action bold, italic, underline, alignleft, alignright, aligncentre;
        protected Action spellchecker, alignjustify, more, cut, copy, paste, tools[];
        public SimpleTextEditor()
            super("SimpleTextEditor - untitled1.rtf");
            this.setLocation(200, 200);
            this.setIconImage(getMyIcon("Icon.gif").getImage());
            getContentPane().setLayout(new BorderLayout());
            undo = new UndoManager();
            //Set up the file formats and file choosers etc
            FileFormats = new String[]{".rtf", ".txt", ".java", ".bat"};
            FileDescriptions = new String[]{"Rich Text Format Files", "Text Files", "Java Source Files", "DOS Batch Files"};
            PicFileFormats = new String[]{".gif", ".bmp", ".jpg"};
            PicFileDescriptions = new String[]{"Gif Images", "Bitmap Images", "JPEG Images"};
            chooser = new JFileChooser();
            picChooser = new JFileChooser();
            picChooser.setAccessory(new ImagePreview(picChooser));
            javax.swing.filechooser.FileFilter defaultFilter = new SimpleFilter(FileFormats[0], FileDescriptions[0]);
            javax.swing.filechooser.FileFilter defaultPicFilter = new SimpleFilter(PicFileFormats[0], PicFileDescriptions[0]);
            for (int i = 1; i < FileFormats.length; i++)
                chooser.addChoosableFileFilter(new SimpleFilter(FileFormats, FileDescriptions[i]));
    for (int i = 1; i < PicFileFormats.length; i++)
    picChooser.addChoosableFileFilter(new SimpleFilter(PicFileFormats[i], PicFileDescriptions[i]));
    chooser.setFileFilter(defaultFilter);
    picChooser.setFileFilter(defaultPicFilter);
    File working = new File("C:/Documents");
    if (!working.exists())
    working = new File("C:/MyDocuments");
    if (!working.exists()) working = new File("C:/");
    if (working.exists())
    chooser.setCurrentDirectory(working);
    picChooser.setCurrentDirectory(working);
    // Set up Document object and Editor kits
    doc = new DefaultStyledDocument();
    edkit = new StyledEditorKit();
    rtfkit = new RTFEditorKit();
    // Set up Listener objects
    doclistener = new MyDocumentListener();
    undolistener = new MyUndoableEditListener();
    doc.addDocumentListener(doclistener);
    doc.addUndoableEditListener(undolistener);
    //Set up main GUI content
    textpane = new JTextPane(doc);
    textpane.setPreferredSize(new Dimension(400, 400));
    textpane.setMinimumSize(new Dimension(400, 400));
    JScrollPane scroller = new JScrollPane(textpane);
    scroller.setPreferredSize(new Dimension(400, 400));
    mb = new JMenuBar(); // Create a menu bar
    JMenu File = new JMenu("File");
    JMenu Help = new JMenu("Help");
    //Sort out Actions etc
    createActionTable(textpane);
    createToolbarActions();
    JMenu Style = createStyleMenu();
    undoAction = new UndoAction();
    redoAction = new RedoAction();
    //Create Style, Edit and Format menus + Toolbar
    JMenu Edit = createEditMenu();
    JMenu Format = createFormatMenu();
    JMenu Insert = createInsertMenu();
    JToolBar toolbar = createToolbar();
    getContentPane().add("North", toolbar);
    // set up main menu items with ActionListeners
    newDoc = new JMenuItem("New");
    newDoc.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent e)
    newDoc();
    exit = new JMenuItem("Exit");
    exit.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent e)
    exit();
    print = new JMenuItem("Print");
    print.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent e)
    print();
    save = new JMenuItem("Save");
    save.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent e)
    save();
    saveAs = new JMenuItem("Save As...");
    saveAs.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent e)
    saveas();
    open = new JMenuItem("Open...");
    open.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent e)
    open();
    JMenuItem about = new JMenuItem("About");
    about.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent e)
    ab = new About(SimpleTextEditor.this);
    ab.show();
    ab.setLocation(400, 300);
    // Create the popup menu
    popup = createEditMenu().getPopupMenu();
    popup.addSeparator();
    popup.add(createStyleMenu());
    popup.add(createFormatMenu());
    textpane.add(popup);
    // set up Help and File menus
    Help.add(about);
    File.add(newDoc);
    File.add(open);
    File.add(print);
    File.add(save);
    File.add(saveAs);
    File.addSeparator();
    File.add(exit);
    // add the menus to the menubar
    mb.add(File);
    mb.add(Edit);
    mb.add(Format);
    mb.add(Style);
    mb.add(Insert);
    mb.add(Help);
    this.setJMenuBar(mb);
    getContentPane().add("Center", scroller);
    // Add mouse Listener to the textpane for popup events
    textpane.addMouseListener(new MouseAdapter()
    public void mousePressed(MouseEvent e)
    if (e.isPopupTrigger())
    popup.show(textpane, e.getX(), e.getY());
    e.consume();
    public void mouseReleased(MouseEvent e)
    if (e.isPopupTrigger())
    popup.show(textpane, e.getX(), e.getY());
    e.consume();
    //-----------------| Main active methods |------------------
    public void exit()// Main Exit method
    if (DocumentIsUnedited)
    {//Check that document is saved/unedited etc
    dispose();
    setVisible(false);
    System.exit(0);
    else
    switch (showNotSavedDialog("Exit"))
    case JOptionPane.YES_OPTION:
    save();
    exit();
    break;
    case JOptionPane.NO_OPTION:
    DocumentIsUnedited = true;
    exit();
    break;
    case JOptionPane.CANCEL_OPTION:
    break;
    public void newDoc()//Method to create new documents
    if (DocumentIsUnedited)
    initDoc();
    filename = "untitled.txt";
    filetype = ".txt";
    resetTitle();
    else
    switch (showNotSavedDialog("New Document"))
    case JOptionPane.YES_OPTION:
    save();
    newDoc();
    break;
    case JOptionPane.NO_OPTION:
    DocumentIsUnedited = true;
    newDoc();
    break;
    case JOptionPane.CANCEL_OPTION:
    break;
    private void initDoc()// Helper method to initialize a new document
    doc = null;
    doc = (DefaultStyledDocument) edkit.createDefaultDocument();
    doc.addDocumentListener(doclistener);
    textpane.setStyledDocument(doc);
    public void print()
    new TimerTestDialog(this);
    class TimerTestDialog extends JDialog
    TimerTestDialog(Frame parent)
    super(parent);
    setLocationRelativeTo(parent);
    setupDialog();
    setModal(false); // this will allow you to do still stuff with the main frame
    * sorry, using a Timer instead of your original TimerTask - it's simpler
    Timer t = new Timer(2000, ticker);
    t.start();
    private void setupDialog()
    Container c = getContentPane();
    c.setLayout(new BorderLayout());
    c.add(getDisplayPanel(), BorderLayout.CENTER);
    c.add(getButtonPanel(), BorderLayout.SOUTH);
    setSize(300, 150);
    setVisible(true);
    private Component getDisplayPanel()
    label = new JLabel("---", JLabel.CENTER);
    label.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
    JPanel panel = new JPanel(new BorderLayout());
    panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    JPanel backing = new JPanel(new BorderLayout());
    backing.add(label, BorderLayout.NORTH); // this will ensure the label doesn't go all tall
    panel.add(backing, BorderLayout.CENTER);
    return panel;
    private Component getButtonPanel()
    JPanel panel = new JPanel(new BorderLayout());
    panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    JPanel backing = new JPanel(new BorderLayout());
    JButton closeButton = new JButton("close");
    closeButton.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent e)
    dispose();
    backing.add(closeButton, BorderLayout.NORTH);
    panel.add(backing, BorderLayout.EAST);
    return panel;
    private ActionListener ticker = new ActionListener()
    public void actionPerformed(ActionEvent e)
    label.setText(String.valueOf(getRandomNumber()));
    private int getRandomNumber()
    return r.nextInt(10) + 1; // shift from 0-9 to 1-10
    private JLabel label;
    * NOTE - this is the best way to use random stuff in java. if you use instance members
    * you can sometimes get the same result each time. not really sure how that works but
    * i've seen it happen
    private static Random r = new Random();
    public void saveas()
    int n = chooser.showSaveDialog(this);
    if (n == 0)
    filename = chooser.getSelectedFile().getName();
    boolean ext = false;
    setFiletype();
    thisfile = new File(chooser.getCurrentDirectory(), filename);
    DocumentIsSaved = true;
    save();
    resetTitle();
    repaint();
    public void save()// Save method. Used by "Save As..." as well
    if (DocumentIsSaved)
    try
    FileOutputStream out = new FileOutputStream(thisfile);
    if ((filetype.equals(".rtf")) || (filetype.equals(".doc")))
    rtfkit.write(out, doc, 0, doc.getLength());
    else
    edkit.write(out, doc, 0, doc.getLength());
    catch (Exception e)
    System.out.println("" + e.getMessage() + "");
    DocumentIsUnedited = true;
    else
    saveas();
    public void open()// Find a file and read it into the document
    if (DocumentIsUnedited)
    int n = chooser.showOpenDialog(this); // get the outcome of the dialog
    if (n == 0)
    File file = chooser.getSelectedFile();
    filename = chooser.getName(file);
    setFiletype();
    resetTitle();
    initDoc();
    try
    FileInputStream in = new FileInputStream(file);
    if (filetype.equals(".rtf"))
    rtfkit.read(in, doc, 0);
    edkit.read(in, doc, 0);
    catch (Exception e)
    System.out.println("" + e.getMessage() + "");
    thisfile = new File(chooser.getCurrentDirectory(), chooser.getSelectedFile().getName());
    DocumentIsUnedited = true;
    DocumentIsSaved = true;
    resetTitle();
    repaint();
    else
    switch (showNotSavedDialog("Open"))
    case JOptionPane.YES_OPTION:
    save();
    open();
    break;
    case JOptionPane.NO_OPTION:
    DocumentIsUnedited = true;
    open();
    break;
    case JOptionPane.CANCEL_OPTION:
    break;
    private void setFiletype()// Helper method to get the filetype of saved/opened documents
    filetype = null;
    for (int i = 0; i < FileFormats.length; i++)
    if (filename.toLowerCase().endsWith(FileFormats[i]))
    filetype = FileFormats[i];
    else
    for (i = 0; i < filename.length(); i++)
    if (filename.toLowerCase().charAt(i) == '.')
    filetype = filename.substring(i);
    if (filetype == null) filetype = ".txt";
    private void resetTitle()
    this.setTitle("SimpleTextEditor - " + filename);
    private ImageIcon getMyIcon(String filename)
    ImageIcon pic = new ImageIcon("Images/" + filename);
    return pic;
    private int showNotSavedDialog(String title)// Helper method to create "Save? Yes/No/Cancel" dialogs
    int n = JOptionPane.showConfirmDialog(this, "The last document has not been saved. \nDo you want to save it first?",
    title,
    JOptionPane.YES_NO_CANCEL_OPTION,
    JOptionPane.QUESTION_MESSAGE);
    return n;
    //-----------------| Listeners and Helper classes |----------------
    protected class MyDocumentListener implements DocumentListener
    public void insertUpdate(DocumentEvent e)
    SimpleTextEditor.this.DocumentIsUnedited = false;
    public void removeUpdate(DocumentEvent e)
    SimpleTextEditor.this.DocumentIsUnedited = false;
    public void changedUpdate(DocumentEvent e)
    SimpleTextEditor.this.DocumentIsUnedited = false;
    protected class MyUndoableEditListener implements UndoableEditListener
    public void undoableEditHappened(UndoableEditEvent e)
    //Remember the edit and update the menus.
    undo.addEdit(e.getEdit());
    undoAction.updateUndoState();
    redoAction.updateRedoState();
    //Helper class for FileFilter, allows a description to be assigned to a filetype
    protected class SimpleFilter extends javax.swing.filechooser.FileFilter
    String type,des;
    public SimpleFilter(String type, String des)
    this.des = des;
    this.type = type;
    public boolean accept(File f)
    if (f.isDirectory())
    return true;
    else
    if (f.getName().toLowerCase().endsWith(type))
    return true;
    else
    return false;
    public String getDescription()
    return des;
    //------------| Methods to help create menus and toolbar |--------------
    protected JMenu createStyleMenu()
    JMenu menu = new JMenu("Style");
    menu.add(bold);
    menu.add(italic);
    menu.add(underline);
    menu.addSeparator();
    menu.add(new StyledEditorKit.FontSizeAction("12", 12));
    menu.add(new StyledEditorKit.FontSizeAction("14", 14));
    menu.add(new StyledEditorKit.FontSizeAction("18", 18));
    menu.addSeparator();
    menu.add(new StyledEditorKit.FontFamilyAction("Serif", "Serif"));
    menu.add(new StyledEditorKit.FontFamilyAction("SansSerif", "SansSerif"));
    menu.addSeparator();
    Action red = new StyledEditorKit.ForegroundAction("Red", new Color(255, 0, 0));
    red.putValue(Action.SMALL_ICON, getMyIcon("red.gif"));
    menu.add(red);
    Action green = new StyledEditorKit.ForegroundAction("Green", new Color(0, 150, 0));
    green.putValue(Action.SMALL_ICON, getMyIcon("green.gif"));
    menu.add(green);
    Action blue = new StyledEditorKit.ForegroundAction("Blue", new Color(0, 50, 150));
    blue.putValue(Action.SMALL_ICON, getMyIcon("blue.gif"));
    menu.add(blue);
    Action black = new StyledEditorKit.ForegroundAction("Black", new Color(0, 0, 0));
    black.putValue(Action.SMALL_ICON, getMyIcon("black.gif"));
    menu.add(black);
    menu.add(more);
    return menu;
    protected JMenu createEditMenu()
    JMenu menu = new JMenu("Edit");
    menu.add(undoAction);
    menu.add(redoAction);
    menu.addSeparator();
    menu.add(cut);
    menu.add(copy);
    menu.add(paste);
    menu.addSeparator();
    Action selectall = getActionByName(DefaultEditorKit.selectAllAction);
    selectall.putValue(Action.NAME, "Select All");
    menu.add(selectall);
    return menu;
    protected JMenu createFormatMenu()
    JMenu menu = new JMenu("Format");
    menu.add(spellchecker);
    menu.add(alignleft);
    menu.add(alignright);
    menu.add(aligncentre);
    menu.add(alignjustify);
    return menu;
    protected JMenu createInsertMenu()
    JMenu menu = new JMenu("Insert");
    Action insertimage = new InsertImageAction(this);
    menu.add(insertimage);
    Action insertdate = new InsertDateAction();
    menu.add(insertdate);
    Action insertline = new InsertLineAction();
    menu.add(insertline);
    JMenu bullets = new JMenu("Bullet Points");
    bullets.add(new InsertBulletAction(CIRCLE, "Circle"));
    bullets.add(new InsertBulletAction(TRIANGLE, "Triangle"));
    bullets.add(new InsertBulletAction(SQUARE, "Square"));
    menu.add(bullets);
    return menu;
    public JToolBar createToolbar()
    JToolBar bar = new JToolBar();
    JButton newbutton = new JButton(getMyIcon("new.gif"));
    newbutton.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent e)
    newDoc();
    bar.add(newbutton);
    JButton savebutton = new JButton(getMyIcon("save.gif"));
    savebutton.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent e)
    save();
    bar.add(savebutton);
    JButton openbutton = new JButton(getMyIcon("open.gif"));
    openbutton.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent e)
    open();
    bar.add(openbutton);
    bar.addSeparator();
    for (int i = 0; i < tools.length; i++)
    JButton button = new JButton();
    button.setAction(tools[i]);
    button.setIcon(getMyIcon(tools[i].getValue(Action.NAME) + ".gif"));
    button.setText("");
    bar.add(button);
    if ((i == 2) || (i == 6)) bar.addSeparator();
    return bar;
    public void createToolbarActions()
    bold = new StyledEditorKit.BoldAction();
    bold.putValue(Action.NAME, "Bold");
    italic = new StyledEditorKit.ItalicAction();
    italic.putValue(Action.NAME, "Italic");
    underline = new StyledEditorKit.UnderlineAction();
    underline.putValue(Action.NAME, "Underline");
    more = new MoreColorsAction();
    cut = getActionByName(DefaultEditorKit.cutAction);
    cut.putValue(Action.NAME, "Cut");
    copy = getActionByName(DefaultEditorKit.copyAction);
    copy.putValue(Action.NAME, "Copy");
    paste = getActionByName(DefaultEditorKit.pasteAction);
    paste.putValue(Action.NAME, "Paste");
    alignleft = new StyledEditorKit.AlignmentAction("Left Justify", StyleConstants.ALIGN_LEFT);
    alignright = new StyledEditorKit.AlignmentAction("Right Justify", StyleConstants.ALIGN_RIGHT);
    aligncentre = new StyledEditorKit.AlignmentAction("Align Centre", StyleConstants.ALIGN_CENTER);
    alignjustify = new StyledEditorKit.AlignmentAction("Fully Justify", StyleConstants.ALIGN_JUSTIFIED);
    spellchecker = new StyledEditorKit.AlignmentAction("Spell Checker", StyleConstants.ALIGN_JUSTIFIED);
    tools = new Action[]{cut, copy, paste, bold, italic, underline, more, alignleft, alignright, aligncentre, alignjustify, spellchecker};
    // helper methods to enable menu creators to get their actions by name
    private void createActionTable(JTextComponent textComponent)
    actions = new Hashtable();
    Action[] actionsArray = textComponent.getActions();
    for (int i = 0; i < actionsArray.length; i++)
    Action a = actionsArray[i];
    actions.put(a.getValue(Action.NAME), a);
    private Action getActionByName(String name)
    return (Action) (actions.get(name));
    //----------------| Custom Actions |--------------------
    class InsertImageAction extends AbstractAction
    protected SimpleTextEditor parent;
    public InsertImageAction(SimpleTextEditor parent)
    super("Image...");
    this.parent = parent;
    public void actionPerformed(ActionEvent e)
    int n = parent.picChooser.showOpenDialog(parent);
    if (n == 0)
    String filename = picChooser.getSelectedFile().getName();
    File file = new File(picChooser.getCurrentDirectory(), filename);
    Icon pic = new ImageIcon(file.getAbsolutePath());
    textpane.insertIcon(pic);
    SimpleTextEditor.this.repaint();
    class InsertDateAction extends AbstractAction
    public InsertDateAction()
    super("Date");
    public void actionPerformed(ActionEvent ble)
    Calendar c = Calendar.getInstance();
    String[] months = new String[]{"01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"};
    textpane.replaceSelection(c.get(c.DAY_OF_MONTH) + "/" + months[c.get(c.MONTH)] + "/" + c.get(c.YEAR));
    class InsertLineAction extends AbstractAction
    public InsertLineAction()
    super("Horizontal line");
    public void actionPerformed(ActionEvent e)
    Icon pic = new ImageIcon("Images/line.gif");
    textpane.insertIcon(pic);
    class InsertBulletAction extends AbstractAction
    protected int type;
    protected String filenames[] = new String[]{"square.gif", "triangle.gif", "circle.gif"};
    public InsertBulletAction(int type, String name)
    super(name);
    this.type = type;
    this.putValue(SMALL_ICON, new ImageIcon("Images/" + filenames[type]));
    public void actionPerformed(ActionEvent e)
    Icon pic = new ImageIcon("Images/" + filenames[type]);
    textpane.insertIcon(pic);
    textpane.replaceSelection(" ");
    class MoreColorsAction extends AbstractAction
    public MoreColorsAction()
    super("More Colors");
    public void actionPerformed(ActionEvent e)
    AttributeSet as = textpane.getCharacterAttributes();
    SimpleAttributeSet sas = new SimpleAttributeSet(as);
    Color newColor = JColorChooser.showDialog(
    SimpleTextEditor.this,
    "Choose Text Color",
    doc.getForeground(as));
    if (newColor != null)
    StyleConstants.setForeground(sas, newColor);
    textpane.setCharacterAttributes(sas, true);
    SimpleTextEditor.this.repaint();
    class UndoAction extends AbstractAction
    public UndoAction()
    super("Undo");
    setEnabled(false);
    public void actionPerformed(ActionEvent e)
    try
    undo.undo();
    catch (CannotUndoException ex)
    System.out.println("Unable to undo: " + ex);
    ex.printStackTrace();
    updateUndoState();
    redoAction.updateRedoState();
    protected void updateUndoState()
    if (undo.canUndo())
    setEnabled(true);
    putValue(Action.NAME, undo.getUndoPresentationName());
    else
    setEnabled(false);
    putValue(Action.NAME, "Undo");
    class RedoAction extends AbstractAction
    public RedoAction()
    super("Redo");
    setEnabled(false);
    public void actionPerformed(ActionEvent e)
    try
    undo.redo();
    catch (CannotRedoException ex)
    System.out.println("Unable to redo: " + ex);
    ex.printStackTrace();
    updateRedoState();
    undoAction.updateUndoState();
    protected void updateRedoState()
    if (undo.canRedo())
    setEnabled(true);
    putValue(Action.NAME, undo.getRedoPresentationName());
    else
    setEnabled(false);
    putValue(Action.NAME, "Redo");
    //-------------| Very nice Image Previewer 'borrowed' from Sun's Java Tutorial
    class ImagePreview extends JComponent implements PropertyChangeListener
    ImageIcon thumbnail = null;
    File file = null;
    public ImagePreview(JFileChooser fc)
    setPreferredSize(new Dimension(100, 50));
    fc.addPropertyChangeListener(this);
    public void loadImage()
    if (file == null)
    return;
    ImageIcon tmpIcon = new ImageIcon(file.getPath());
    if (tmpIcon.getIconWidth() > 90)
    thumbnail = new ImageIcon(tmpIcon.getImage().getScaledInstance(90, -1,
    Image.SCALE_DEFAULT));
    else
    thumbnail = tmpIcon;

  • Actual date doesn't mtach the calendar display on my iphone

    I am currently traveling, and I noticed, that my phone had the wrong time listed in the diplay. I went to "General Setting" amd manually changed the time and went to change the date and noticed I had an issue. When I open the calendar, it may say "May 8, 2008" but the actual calendar display is "April 8, 2008" All the days of the month line up correctly,and if I click on an event, it display the corret date information, but the calendar heading is April 2008. Also, I have noticed that all my event times are also now incorrect. Any clue what is going on and how to fix it?

    I am in the same timezone as the country where I live. I have gone on my phone and played with all the different setting. It is so bizarre--- my calendar displaysal the correct days for the month of may and says it is May when I lick an event, but the heading at the top say April. I return to the states tomorrow, so I am hping this is corrected when I get back on my regular ATT network.

  • Can I get my calendar to deal in local time, ignoring time zones?

    Can I tell my calendar to not change event times when I travel? I can tell Time Zone Support to use either my home time zone when on or my destination time zone when off, but I want to be able to enter and see local times when I am in either place. For example, if my home is LA and I have 1:00 pm meeting in NY, I don't want to have to enter it as being at 10:00 am before I leave!
    If there is no way to do this, how can I contact Apple to ask them to give me this option?

    Check Settings > Mail, Contacts, Calendars > Time Zone Support
    "Time Zone Support always shows event dates and times in the time zone selected for calendars.
    When off, events will display according to the time zone of your current location."

Maybe you are looking for

  • How do I set it up so that when I reply to a website through Firefox, it is sent through Google and not Outlook

    I use Google for my email server. When I am searching the web on Firefox, I want to reply to a "Contact Me" prompt from the website.....in that case, how do I set Firefox up so that it replies via Google and not Microsoft outlook?

  • Bock a housebank in APP F110

    Hi, I want to block an houbank that already exist in App F110 for a particular co code. Same time it should be available for making manual payments. Can anybody suggest me the way by which i can block it only for APP. Regards, Leena Borker

  • CSS layout, again...at wits end

    I'm tellin' ya, I've been trying to grasp this stuff for 2 weeks, and it's just not working. I am trying to recreate a pretty simple layout that I've used before pre-CSS, using tables. It's a simple top "banner" area, then 2 columns in the middle (on

  • Problem with Object returning previously set values, not current vlaues

    Please help if you can. I can send the full code directly to people if they wish. My problem is I enter title details for a book via an AWT GUI. When the user clicks the OK button it should display a new screen with the values just entered by the use

  • ADF Input Text not showing

    Hi All, Can anyone help me out. I am using Jdev 10.1.3.3 and when I dragged the componet from Data Control as Input ADF W/ label and run the page the input text doesn't appear only the lable. Thanks in advance