IView that displays different things depending on event

Hi list,
I need to create an iView that will be receiving different events from other iViews.  This receiving iView will display different things depending on the event (eg. image maps, data sheet, etc).  How should I implement this iView?  Should this iView be multi-component and then the events triggers the correct component?  Or should this iView be multi JSP pages with one component handling the event and calling the correct JSP page?  Or are there any other suggestions/examples out there?
The image map is not simple either.  It has several hotspots on one image map.
Thanks in Advance,
Jovanka

Hi list,
I need to create an iView that will be receiving different events from other iViews.  This receiving iView will display different things depending on the event (eg. image maps, data sheet, etc).  How should I implement this iView?  Should this iView be multi-component and then the events triggers the correct component?  Or should this iView be multi JSP pages with one component handling the event and calling the correct JSP page?  Or are there any other suggestions/examples out there?
The image map is not simple either.  It has several hotspots on one image map.
Thanks in Advance,
Jovanka

Similar Messages

  • Display Different reports depending on values in a User Selectable Dropdown

    Hello,
    I want to create a report which has a Drop-down and depending on the value selected from the drop-down, i want to display different reports.
    Say, a drop-down has 3 values, v1, v2 and v3. Now, if a user selects v1, he/she should see report r1. If v2 is selected, the user should see report r2. if v3 is selected from the drop-down, then report r3 should be visible. All the 3 reports have different structures (even different no. of columns). Also, v1, v2 and v3 are 3 different values belonging to a same picklist type field.
    Do you think this is possible? If yes, How ?
    Any sort of help will be highly appreciated. Thanks in advance.
    Regards,
    Ramil.

    The only way i could see this working would be to create a picklist on a object and then create your three reports placing them within the same folder and name the report something under 30 charters then place the same name in the picklist value and create a weblink to the report which at selection of the report will run either report.

  • ICals on OS X & iOS display different time for same event

    I am in UTC+8 time zone. My boss is in UTC-5 time zone. I have set up sync service on my MBA and iPhone iCals with my company's MS Exchange Server.
    I have a weekly meeting invitation from my boss, my MBA iCal displays this meeting on 10:30pm which is wrong, while my iPhone and MS Server displays 9:30pm which is corret - the meeting takes places on 9:30pm my time.
    All my other iCal events are fine on both devices, only this weekly event displays different time. I have taken with MBA and iPhone to travel around the world over the past half year and switched time zones on them, but they are all set to adjust time zones automatically, and they are with most up-to-date system. Why does MBA iCal displays wrong time? Can I adjust it? This problem exisits on Lion and now also on M Lion.
    Thanks for everyone's attention and help in advance!

    Try using floating time zones. It helped for me.

  • How can I add buttons that do different things to each row of an rpt result

    Hi there,
    I'm trying to figure out how to add buttons to each row of a report. Here is the scenario:
    report query returns a set of data that needs to be "approved". The options are "Append", "Replace", or "Reject" (I want to make the results look like so:)
    Person1 today blah, blah blah... Append button Replace button Reject button
    Person2 today blah, blah, blah... Append button Replace button Reject button
    PersonA today something, blah... Append button Replace button Reject button
    and so on.
    I'd like to set up the page so that there is an append, replace, reject button for each row returned by the report. So when the "Approver" clicks on the append button, something happens for that row, etc. How does one do this? So far I can only get the buttons to show up in the region. I also thought it might be possible to somehow turn the append, replace, reject text into links that called a plsql proceedure that would handle the action, but I'm not having any success with that idea either.
    Edited by: user10361829 on Sep 29, 2009 12:10 PM

    What I've done is make my report query as follows:
    select field_a, field_b, field_c, 'Append', 'Replace', 'Reject'
    from table_x
    where field y = :PX_ID
    That gives me the words (append, replace, reject) in the report. Then I go to the report attributes section and make a link out of the columns (append, replace, reject) so far, so good.
    Next question is how to make clicking on those links activate an update action on tableN. In the column_link section there is a box marked "Request" that looks like it might be relevant because Request is a term connected to buttons, but I've no idea how to use it. Or, can one use the tabluar form element section of the report attributes page to connect the Append (pseudo column) to an action? I've looked at your example (Sam) with the delete button, but what I really need to see is the Apex menu that sets it up because there are so many levels in the interface it is not intuitive (at least for me). I know exactly what I want it to look like but I'm missing the crucial step to get there... Thanks for your help so far.
    Column link section is described below :
    Column Link     Top
    Link Text      flashlight          
         [*Append*][Icon 1][Icon 2][Icon 3][Icon 4][Icon 5]
    Link Attributes      
    Target: *"Page in this application"*     Page: *10*     
    Reset Pagination
    Request Clear Cache      
    Name     Value
    Item 1      Px_page_item flashlight *#????#*          flashlight
    Item 2      flashlight          flashlight
    Item 3      flashlight          flashlight
    URL      
    Page Checksum

  • Action that does different things based on width to height ratio

    I have a few hunderd images I want to run a batch on and I am building the action I will use.
    I need to do something I have not come accross before.
    If the image is taller than wide I need to make the image 1024 pixels high.
    else
    If the image is wider than tall I need to make the image 1024 pixels wide.
    How can I do something like this in an action?
    Will I need to use a script instead?

    Will File > Automate > Fit Image not suffice?
    If not you may have to use a (different) Script as Actions alone (edit) basically don’t allow the user to set conditional operations.

  • IView Displaying Differently with Users

    I have a transactional iView that displays a different screen view (GUI) for different users.
    Is there a setting that needs to be changed or could it be something to do with the Users Authorisations?

    Hi Sudha
    Thanks for the reply.
    I am logging on as both Users.  The interesting thing is that one of the Users gets a pop up message when selecting the iView saying they have mail in their In Box.  This is the one I'm having trouble with.
    Once I have pressed the green tick to acknowledge the message and go into the iView it selects the Manager rather than a member of his staff in the iView.
    When selecting a member of staff in the team viewer the entry does not appear in the iView.

  • PDF file displays different number of text blocks in Acrobat Pro CC 2014 and CS6 versions

    Hi,
    I've inherited a file at work that displays different numbers of text blocks, depending on the version of Acrobat Pro used to view the file. Here's the specific issue:
    As viewed in CC 2014:
    "Chapter 1 - Chapter One Title": Appears as two text blocks -- one for "Chapter 1 - " and one for "Chapter One Title"
    As viewed in CS 6:
    "Chapter 1 - Chapter One Title": Appears as a single text block -- "Chapter 1 - Chapter One Title"
    This occurs only with regard to single-digit chapter numbers that are whole numbers. So:
    Chapter 1, Chapter 5, and Chapter 7 entries appear as two blocks in CC 2014, one block in CS6.
    Chapter 2.0, Chapter 6.1, Chapter 10, entries appear in single blocks in both CC 2014 and CS6.
    The PDF file was created -- I believe -- through the save-to-PDF feature in Word 2010.
    Any idea what's happening here?
    Thanks.
    David

    First of all, there is no such thing as Acrobat CS6 or Acrobat CC 2014. We assume you are referring to Acrobat X and Acrobat XI respectively.
    Secondly, how are you determining how many text blocks are in the PDF file? By use of the text touchup/edit function in Acrobat? If so, how this edit function displays text doesn't necessarily correspond to the actually underlying text fragments in the PDF file. In fact, sometimes it combines fragments based on heuristics. Those heuristics have varied with different version of Acrobat.
    PDF as a file format doesn't know the context of the graphical objects such as text. There is no concept of a line, a sentence, a paragraph, a column, etc. in terms of text. Runs of text are context-insensitive. You will get “breaks” when switching between regular and italics or when unusual paragraph justification is involved.
    Is the actual problem in trying to edit the text or something else?
    If you post a file, and indicate what text we should look at, we can confirm what is actually going on in your file.
              - Dov

  • Displaying different content on Maximize of Portlet

    Hi,
    Is there a way by which i can display different content on Maximize event of a portlet than the one displayed in the normal portlet.
    saw one <render:jspContentUri> taglib which promises to do that. but it only maximizes the existing content and does not change it.
    Any help in this regard would be appreciated.
    thanx in advance
    Gaurang

    Anyone know how to do this on a PageFlow portlet?
    "Chris Jolley" <[email protected]> wrote:
    >
    I assume you are using a regular JSP portlet...
    put a backing file on the portlet (backing files are just java classes
    that extend
    AbstractJSPBacking, see "backing file" property in IDE)
    public boolean preRender(HttpServletRequest request, HttpServletResponse
    response)
    PortletBackingContext pbc = PortletBackingContext.getPortletBackingContext(request);
    WindowState ws = pbc.getWindowState();
    if (ws.getName().equals("maximized"))
    JspContentContext jcc JspContentContext getJspContentContext(request);
    jcc.setContentUri("/mynew.jsp");
    Note: you can put backing files on the Portlet and the JSpContent elements.
    I'm
    not sure if the IDE supports both of these. You may have to crack open
    the .portlet
    file and add the backing file to the JSPContent element.
    <netuix:jspContent backingFile="comn.somecompany.yourBackingFile" contentUri="/portlets/myportlet.jsp"/>
    Gaurang <[email protected]> wrote:
    Hi,
    Is there a way by which i can display different content on Maximizeevent
    of a portlet than the one displayed in the normal portlet.
    saw one <render:jspContentUri> taglib which promises to do that. but
    it only maximizes the existing content and does not change it.
    Any help in this regard would be appreciated.
    thanx in advance
    Gaurang

  • How to display conditional things on the front panel ??

    Hello,
    What I am trying to do is this: The user will select some information from a combo box, and depending upon twhat he has selected I want to display different things based on his selection.
    Any help will be appreciated.
    Thanks,
    Bira_pxi

    You can programmatically change the visibility of any object using property nodes with the "visible?" property.
    If the groups of elements are similarly arranged, use a tab indicator (place tab control...change to indicator) and place each group of FP elements on it's own tab. Now hide the tabs and select the active tab programmatically by writing the desired state to the tab indicator.
    Another option is the use of subpanels.
    Message Edited by altenbach on 08-16-2007 04:11 PM
    LabVIEW Champion . Do more with less code and in less time .

  • Displaying different properties?

    I have an iview which displays different users, and in the displayed properties for the Collection Render I have the following:
    rnd:icon,rnd:displayname(contentLink)
    This displays an icon and the username (with a link!).
    What I want to do is display other properties e.g. Phone number, job description etc. Does anyone know the properties that need to be used or a list where I can find which ones can be used?
    Thanks in advance!

    Hi Phil,
    see http://service.sap.com/nw-howtoguides --> Portal, KM and Collaboration --> KM --> Extending User Details
    With this, you'll see how to use the UME repository and how to map UME properties as KM properties (like: ume:department, ume:company etc).
    Hope it helps
    Detlev

  • BW Report iView that points to QueryView

    I would like to have a BW Report iView that displays the standard icons (ie: Export to Excel, Create graph etc) and displays a BW Query View.  My understanding is that this has to be a BW Report iView and not a BW Query iView because of single sign on will not work with the BW Query iView.
    So appending the following to my URL works for QUERY but what works for QUERYVIEW?
    CMD=LDOC&INFOCUBE=<CUBE>&QUERY=<QUERY NAME>
    Thanks!

    Yes SAP Portal can seamlessly integrate with CMS.

  • How to create a front panel display that lights up with different colours depending on its input signal?

    I am doing a project where I have this array which has different voltage outputs for each grid. How do I create a front panel object that lights up with different colours depending on the voltage input or is there already such a pre-built function?
    In addition, I wish to display these in an array on screen. Is there any pre-built function for this?

    Repulse wrote:
    I am doing a project where I have this array which has different voltage outputs for each grid. How do I create a front panel object that lights up with different colours depending on the voltage input or is there already such a pre-built function?
    The simplest way would be an intensity graph. It gives you a 2D grid where each grid point is colored according to the value of a 2D array. The Z axis color ramp determines the color.
    My second choice would be an array of colorboxes. (They could even be made to look like LEDs (see image, if course you can leave them square too), All you need is a scaling function thap maps voltages into a color ramp lookup table with an 8bit index)
    (Using booleans and color property nodes is relatively clumsy. Booleans are meant for two states because the value is boolean. Since array elements can only differ in value, and not in properties, it will not even work. Color boxes have a color data type which is much more appropriate for this case)
    LabVIEW Champion . Do more with less code and in less time .

  • How to make a form dynamic so that it displays different logos at runtime

    I am working on some assignment wherein I would like to make a form dynamic so that in it's designated image holder it displays different logos/pictures at run time? First of all is there such a possibility?? I am still very new to this forum and also trying to understand the logic/bindings/heirarchy etc. in LCD. Any input would be highly appreciated.
    Thanks in advance

    LC 7 or 8 does not help load logs at runtime. However you can associate all your logs at design time and control their visibility property based on the events. This may help fulfill the requirements you have to an extent however adding number of images at design time will increase the size of the template.

  • 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;

  • After lots of different things, it appears that my Airport won't let me download on to my Nook. It used to but not anymore. Any ideas?

    After lots of different things, it appears that my Airport won't let me download on to my Nook. It used to but not anymore. Any ideas?

    Hi Karen,
    The means that iTunes can no longer locate the songs (mp3/m4a) on the hard-drive and as such they won't even play in iTunes, let alone transfer to your iPod.
    Have you recently re-organised your music folders? If you know where these songs are on your hard-drive then you could clear all of the tracks that display the symbol from iTunes and then add them again from their location either through the 'add folders to library' function or by dragging and dropping them diectly into iTunes from Windows Explorer.
    Nik

Maybe you are looking for

  • Send E-mail to Buyer and Requisitioner while doing GR for a Purchase Order

    Hi All, I  would like to send automatic notification messages to buyers and Requisitioners when goods receipt is completed for Purchase orders (Document type ZE). Notification should be sent only for the purchase requisitions that are created manuall

  • Problem in Tree with in a table

    Hi Experts, I have created a WDC which contains the tree with in a table. I have created a table in the view and a Master column in it. Initially i loaded the tree with some values in my WDDOINIT of my view. I have also created the event handler for

  • Is it possible to export OMF (to ProTools)?

    Is it possible to export OMF (to ProTools)? It is vital for the post of sound to be able to send the edit for further work by professional sounddesigners. I love the idea of FC-X, but if OMF export/import is not possible... Would appreciate any ideas

  • Editing Tips

    Hi, Just wondering.  Only just started using Lightroom this week.  I also heard of Bridge just this week as well.  What is the normal sequence for uploading and editing images?  Do you open Bridge, then browse images - find the image you want do some

  • Stuck at blue Login screen

     Hello. I am experiencing an issue with my laptop, a G61 421SO model, and the issue is showed in a Youtube video. Link: https://www.youtube.com/watch?v=Y7FIDt9SonQ The issue occured after I let my cousin played The Sims 4. She said that after she clo