Acting Up Action

Hi ,
Can somebody tell me about acting up action. What will be infotypes to be maintained.
secondly i have a confusion which i tried to solve through sdn threads but yet not mu ch clear that during organisational re
assignment is it neccessary for person to go to another org unit or subsidary .
if person gets promoted to his managers place in same org unit then will it be considered as change of position or the
organisational re assignment.
Kind Regards ,
Shruti

shruthi
if he gets promoted Run promotion action
if u want to do it thru organisational reassigment that the reason for that action shd be done as promotion

Similar Messages

  • Coding actions

    Hi.
    I was wondering how can I code actions for automator. I want, for example, to have shell scripts to act as actions if possible, or, I don't know what, python scripts, whatever else.
    I was wondering how is that possible.
    Thanks

    You can of course use Automator's "Run Shell Script" action to make a quick and dirty "glue" action for your personal needs. If you want something with a slick UI for distribution, head on over to Xcode and review the Automator developer docs. Basically you set up a gui in Interface Builder (use size small controls!), then connect the parameter bits to your script with Cocoa Bindings.

  • How can you set Dos date as YYYYMMDD in After Action script?

    Hellos...
    I have been trying the standard method to get the DOS date as a format string YYYYMMDD
    It seems to cause the AfterAction script to bomb.
    I am trying this script ...
    <?xml version='1.0' encoding='UTF-8'?>
    <!DOCTYPE Waveset PUBLIC 'waveset.dtd' 'waveset.dtd'>
    <Waveset>
    <ResourceAction name='ISSHP-enable-email'>
    <ResTypeAction restype='Windows Active Directory' timeout='60000'>
    <act>
    rem Action for MSE2007 test/development to Enable-Mailbox a new AD User created by IDM.
    rem Set up environment as necessary (copy of idmadm account's environment)
    rem Local script environment settings
         SET LogFileDrive=C
    SET LogFileDir=%LogFileDrive%:\Sun\ADAfterActionsLog\
    SET DBtoUse=idmex.sks.local\Mailbox Database
    rem set TODAYDATE as yyyyddmm and TIMENOW as hhmmssdd to be used in the Log file name
         set TIMENOW=%time:~0,2%%time:~3,2%%time:~6,2%%time:~9,2%
         for /F "tokens=2-4 delims=. " %i in ('date /t') do set TODAYDATE=%k%j%i
    set >> %LogFileDir%AfterActionLog.txt
    rem PS Commands from here...
    exit
    </act>
    </ResTypeAction>
    </ResourceAction>
    </Waveset>
    But the line
    for /F "tokens=2-4 delims=. " %i in ('date /T') do set TODAYDATE=%k%j%i
    is causing problems..
    How have others managed to turn date /T into YYYYMMDD within an after action ??
    I know in our Gateway date /T will output (today): pe 29.01.2010
    GF

    The output from the for command when run in the cmd shell is as expected.
    I have tried both batch and command line variable settings in my action script i.e.
    for /F "tokens=2,3,4 delims=. " %i in ('date /T') do echo %k%j%i
    and
    for /F "tokens=2,3,4 delims=. " %%i in ('date /T') do echo %%k%%j%%i
    with no joy. I suspect that its the Gateway launched shell executor that is having problems with the for do command.
    Anyways, using
    set todaysdate=%date:~9,4%%date:~6,2%%date:~3,2%
    solves my problem. Just curious why the for construct bombs in the resource action.
    Thanks. GF

  • Problem with action script calculations

    I have a simple action script 3 code that will not calculate the correct answer on my PC.  I'm running flash cs5 on Window 7 OS.  I can move the file to another machine running  flash cs4 and it works, but when I run it on my laptop, I get funky answers.  see cold below.  I have uninstalled and reinstalled cs5 , run the cleanscript for cs5 and cs4 to make sure everything was removed.  I have uninstalled and reinstalled flash player.  but nothing seems to work.  Any help will be appreciated.  It acts like Action Script 3 is corrupt or something else that related to Action Script 3.  Everything else seems to work.  I also have a preloader running with the same issue.  It is should be showing the percentage completed but it go 2 5 50 4 32 or something funky like that.  Please help.
    the code I'm using.
    function calculateTotal(evtObject:MouseEvent):void {
       var price:Number;
       var totalCost:Number;
       var numberOfJerseys:Number;
       if (jerseyType.text == "2") {
        price = 12;
          if (jerseyType.text == "1") {
        price = 10;
       if (playerNames.text == "Y" || playerNames.text == "y") {
        price += 1.50;
       numberOfJerseys = int(numberOfPlayers.text) +int(numberOfCoaches.text);
       totalCost = numberOfJerseys*price;
       total.text = String(totalCost);
    calc_btn.addEventListener(MouseEvent.CLICK, calculateTotal);     
    the preloader percentage is
    var percent:int = amtLoaded*100
    percent_txt.text = String(percent);

    HELLO,
                  just check       navigateToURL()

  • Customer service regarding credit card mishandling possible credit fraud

    To whom it may concern,
    On Tue morning I placed a order for a sprint prepaid galaxy s3 and a go pro hero package through the early black friday preview deal.  I had both items in my cart and checked out the go pro package with promo code.  I then immediatley went back into my shopping cart and proceed to put in my galaxy promo code and the item was not longer available and sold out.  I then called customer service to see about why this was removed from my cart and how I could order one.  I was told that item was sold out and nothing could be done.
    I then relealized in the confusion that I entered the wrong credit card in the system and wanted to change the form of payment to the correct card.  I was told that they will take my credit card information and I gave the CR rep my credit card and was put on hold.  I then was taken off hold and another CR rep was on the line and I started the whole process again giving my credit card information waiting for an authorization from her, which she gave me. (This whole process took approx 45 min by the way).
    I then get to work and decide to check the status of my order at best buy and I am suprised to see my initial credit card info was used to process the order, not the new credit card that was given and told authorized.
    I call CR again and the order was checked on on they said that the payment was authorized for the intial credit card and basically there is nothing I can do to change it.  I tell my story to the CR and she sees that I did request my credit card payment to be changed but can do nothing for me not even cancel the order and reissue it with my proper CC number.
    I ask to speak to a supervisor Angela and she again tells me their is nothing can be done with my order is being processed and by the original credit card was used as authorized.
    My major concern at this point is who did I give my credit card # twice too.  She tells me the agent I was speaking with and I demanded that we get connected with this agent to see what happened with my CC info.  She informs me that this can not happen.  I ask what as a supervisor is going to be done.  She offers no remedy for the multiply issues I was having.  I had to tell her that I would like to escalate this issue, she then said she can issue a ticket # 148428368.  I then ask for the call to be reviewed and I would like a transcript of the conversations I had with the CR rep and how it effects my credit card security.  I am posting this so this get rectified and more people are aware of the dangers your company practices of handling credit card numbers to the CR reps.  I feel this situation could of been handled much differently and want to hear a solution to my issues.
    Concered Customer,

    Hi wildwest99,
    I sincerely apologize if this phone agent didn’t handle your request to change your payment source as you expected them to. It sounds like they tried to change the payment source, thought it went through, but obviously it didn’t change.
    We would never give a copy of our recordings to a customer but we would cooperate fully with any ongoing police investigation. Has this second credit card been used without your authorization? If so, you need to contact the local authorities in order for them to open an investigation.
    I can say that many calls are reviewed and if this agent didn’t act appropriately action will be taken. This action will of course will be treated internally. Other than providing you a transcript of this call, or sharing if any action is taken in regards to this agent, is there anything specific you would ask of me?
    Thanks for posting,
    Allan|Senior Social Media Specialist | Best Buy® Corporate
     Private Message

  • How to skip first screen that is not selection screen.

    Hi Experts
    I am working on a module pool program where in I am required to call a transaction with skip first screen. the first screen of this transaction is self made screen with screen painter with input boxes and a submit button with an OK_CODE. now I am able to get all the input boxes filled during the call, however as the ok_code is missing it is not skipping first screen, neither does the PAI of first screen of called transaction is getting fired, is there any way to fire it?

    I discovered that once I set the parameter of sy-ucomm and then called the transaction it worked. check the code if you need the help on same
    ACTION = 'VW'.
      value = 'V01'.
      SET PARAMETER ID 'SPM' FIELD SPMON.
      SET PARAMETER ID 'VRS' FIELD VRSIO.
      SET PARAMETER ID 'VKB' FIELD WA_INDEX-L_VKBUR.
      SET PARAMETER ID 'DFM' FIELD ZSDTPLANVRSIO-DAT_FRM.
      SET PARAMETER ID 'DFT' FIELD ZSDTPLANVRSIO-DAT_TO.
      set PARAMETER ID 'ACT' field action.
      set PARAMETER ID 'OKC' field value.
    call TRANSACTION 'ZPLAN_INT' AND SKIP FIRST SCREEN.{/code}
    this OKC parameter id holds the value for sy-ucomm and the screen 100 of the called transaction has been skiped and ALV was displayed direct away.
    MODULE STATUS_0100 OUTPUT.
      SET PF-STATUS 'ZAO_MAIN'.
      SET TITLEBAR 'ZAO'.
      if pass <> 1.
      get PARAMETER ID 'ACT' FIELD action.
      get PARAMETER ID 'SPM' FIELD SPMON.
      get PARAMETER ID 'VRS' FIELD VRSIO.
      get PARAMETER ID 'VKB' FIELD knvv-VKBUR.
      get PARAMETER ID 'DFM' FIELD ZSDTPLANVRSIO-DAT_FRM.
      get PARAMETER ID 'DFT' FIELD ZSDTPLANVRSIO-DAT_TO.
      get PARAMETER ID 'OKC' field sy-ucomm.
    set PARAMETER ID 'ACT' field action.
      endif. {/code}

  • Xml report in new window

    hi all,
    actually we are generating xml document for a report and showing the content on the browser with 'response' object . we need to show that in a new window,.
    we restricted the browser buttons for security reasons , so because it was opening in the same window we cannot go back to our application . the alternative i got is that changing the xml file type association to any other editor instead of Internet browser but this is not a solution
    please help me
    thanks in advance
    with regards
    satya

    hi all,
    my problem was solved, once again many thanks to jean Francois.
    Try this:
    function newWindow() {
    window.open("", "exportWindow");
    EmployeeInfoForm.action = EmployeeInfoForm.action +
    "?command=export";
    EmployeeInfoForm.target = "exportWindow";
    EmployeeInfoForm.submit();
    Regards,
    Jean-Francois
    i made a small change to EmployeeInfoForm.action not to append "?command=export" every time when this script calls
    var act= EmployeeInfoForm.action;
    EmployeeInfoForm.action = EmployeeInfoForm.action +
    "?command=Export";
    EmployeeInfoForm.action=act;
    Apart from this solution meanwhile i tried out one alternative,
    when user chooses xml
    docName=someName
    docType=xml
    if(docType.equalsIgnoreCase("xml"))
                   response.setContentType("text/plain");
                   //docName= URLEncoder.encode("\""+"a"+".xml" + "\"");
              docName= "\""+docName+".xml" + "\"";
                   System.out.println(docName);
                   docType="txt";
              response.setHeader("Content-Disposition", "attachment; filename=" + docName + "." + docType);
    ServletOutputStream sos = response.getOutputStream();
                   sos.write(dataBytes);
    sos.close();
    just i made the filename as someName as "someName.xml.txt" with qoutes.
    so that with extension .txt makes to open in notepad rather than to browser , thus avoiding my problem of opening the content of same browser window, this worked fine, but when saving this document i expected the file name as "someName.xml" with qoutes so that the file will save with .xml but i see someName.xml withoutqoutes. when i save this, the file was saved as someName.xml .txt.
    but when user types his own file name xyz than the file was saved xyz.xml
    can any suggest me how can i save the file name with qoutes.
    and can anyone explain me whats happening when i do like this
    with regards
    satya

  • How can I "hide" borders for buttons ?

    Hello!
    I have a toolbar with several buttons on it. If I run my application, these buttons appears initially with a border around.
    I made a custom button, class which implements MouseListener (extends JButton of course) and for each event like mousePressed(...), mouseEntered(...) I set a specific border for my button.
    If I move the mouse cursor over the button the border will not be visible because I use (setBorder(...) in my class) an EmptyBorder(...). I want to happen this when my application starts.
    With respect,
    Cristian

    I changed a little your code to figure what's wrong; here it is modified code:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.border.*;
    public class Test extends JFrame {
         public Test () {
              getContentPane ().setLayout (new FlowLayout ());
              ImageIcon icon = new ImageIcon("images/"+"save.gif");
              Action actionNew = new AbstractAction("save", icon) {
                   public void actionPerformed(ActionEvent e) {
              JToolBar toolBar = new JToolBar();
              CustomButton save = new CustomButton(actionNew, "save");
              toolBar.add(save);
              getContentPane ().add (toolBar);
              setDefaultCloseOperation (EXIT_ON_CLOSE);
              setTitle ("Button without border");
              pack ();
              setLocationRelativeTo (null);
              show ();
         public class CustomButton extends JButton {
              private Border emptyBorder;
              private Border lineBorder;
              public CustomButton (Action act,String text) {
                   super((Icon)act.getValue(Action.SMALL_ICON));
                   //super (text);
                   setFocusPainted (false);
                   emptyBorder = BorderFactory.createEmptyBorder (1, 1, 1, 1);
                   lineBorder = BorderFactory.createLineBorder (Color.BLACK);
                   setBorder (emptyBorder);
                   setToolTipText(text);
                   addMouseListener (new MouseAdapter () {
                        public void mouseEntered (MouseEvent event) {
                             setBorder (lineBorder);
                        public void mouseExited (MouseEvent event) {
                             setBorder (emptyBorder);
              public static void main (String[] parameters) {
                   new Test ();
         }And I realized that if I put my buttons on a toolbar they will be bordered and I don't now if I need to customize the toollbar too in order not show borders arround.
    To run this code you should have an image called save.gif placed in images directory.
    Thanks Levi, I will search further !
    Kind regards,
    Cristian

  • FWSM not reaching it´s Syslog Server

    Hi,
    I have a FWSM Ver. 4.1(5) configured in transparent mode. My problem is that the FWSM is not reaching the Syslog Server. The FWSM can reach other Servers in the  10.10.113.0/24 Subnet, which is the Syslog Server´s Subnet.
    What can be causing this behavior? Why is it that I can ping some host but no others on the same Subnet?  I have 5 Bridge Groups on ths FWSM and I have a management IP address for each BVI.
    Thank you in Advanced.

    quote:
    Originally posted by:
    CaioToOn!
    Hi, Woo.
    In your code you're sending also the variables thru GET, as
    you see in
    http://www.example.comcom/?act=admin&action=login&login=true&air=true"
    Have you tried to remove the GET arguments? Passing the URL
    just as "
    http://www.example.comcom/"
    and sending the variables act, action, login and air also in the
    POST data?
    Bye,
    CaioToOn!
    Hello, Thanks for the help.
    The variables I'm sending through GET are different to the
    ones I'm attempting to send through POST. The GET variables are
    needed to make the server run the correct PHP script.
    I did remove the variables and attempt to try POST to
    "test.php" without any variables but it didn't help, it still isn't
    POSTing anything - it's just sending a GET request.

  • AbstractAction -- JButton

    class QueryAction extends AbstractAction
    // Constructor
    QueryAction(String name)
    super(name);
    String iconFileName = "Images/" + name + ".gif";
    if(new File(iconFileName).exists())
    putValue(SMALL_ICON, new ImageIcon(iconFileName));
    public void aFunc(){
    QueryAction anAction = new QueryAction("Compile Query");
    JButton button = new JButton(anAction);
    toolBar.add(button);
    in other function, I'm trying to disable the button with that particular description string (i.e. "Compile Query"):
    Component[] comp = toolBar.getComponents();
    for (int i=0; i<comp.length; i++){
    JButton aButton = (JButton)comp;
    Action act = aButton.getAction();
    if(act.getValue(Action.NAME).equals("Compile Query"));
    aButton.setEnable(false);
    break;
    But I got NullPointerException for the statement :
    act.getValue(Action.NAME)
    Anybody has an idea how to solve this...?? thx

    Seems to me that your toolBar contains a button which has no action assigned to it.
    Try this: keep a reference to your QueryAction in your class and disable it instead of the button (this feature is one of the reason to use actions afterall):
    public class XYPanel {
      private QueryAction queryAction = new QueryAction();
      private class QueryAction {
        public QueryAction() {
          super("Compile Query");
        // how about using a class resource instead of a file
        // - better for using jars in your app
        putValue(SMALL_ICON, new ImageIcon(getClass().getResource("query.gif")));  
      public void aFunc() {
        toolBar.add(queryAction);
      public void anotherFunc()
        queryAction.setEnabled(false);

  • Translating PHP Script to Coldfusion

    Hello,
    I need to translate this code (which is in PHP) to coldfusion, is there anyone who can help me please it´s urgent, thanks a lot.
    <?
    $ref = $_GET['Reference'];
    $act = $_GET['Action'];
    $par = $_GET['Param'];
    switch ($act) {
    case "DETAIL":
    echo "Reference=".$ref. "&Action=".$act."&Reponse=".$montant;
    break;
    case "ERREUR":
    echo "Reference=".$ref. "Action=".$act. "Reponse=OK";
    break;
    case "ACCORD":
    echo "Reference=".$ref. "Action=".$act. "Reponse=OK";
    break;
    case "REFUS":
    echo "Reference=".$ref. "Action=".$act. "Reponse=OK";
    break;
    case "ANNULATION":
    echo "Reference=".$ref. "Action=".$act. "Reponse=OK";
    break;
    ?>  

    When you're approaching the task of "translating PHP to ColdFusion," and when you find yourself with just-a-moment where you are not "up to your earlobes in alligators" (i.e. when you can recall that "your original objective was to drain the moat ..."), then do try to step back and look at the forest not just the trees.  ColdFusion actually has a rather different philosophy toward designing applications, which can be summed up (I think) like this:
    Most web-tools (PHP, dot-Net, even Ruby and Perl) give you the ability to "write a program" that just happens to produce an HTML output.
    Content-management (CMS) systems are "really-nifty programs that have already been written for you."
    ColdFusion is an application-server system that uses an XML-based declarative syntax.  It is implemented on the back-end using a "just in time" compiler that cranks out the (Java and JavaScript) code for you.  Although many of the "tags" implement conventional procedural-programming constructs such as "switch" and "if" and "loop" and "call," you'll notice that many more do not.
    A good example of the difference between them, for me, is the <cftransaction> tag.  This tag declares to ColdFusion that the enclosed block is supposed to "be a database transaction."  This means, without you having to say anything further, that:
    A database transaction should be started.
    If all of the code within this block completes successfully, the database transaction should be committed.
    If an exception occurs within this block, the database transaction should be rolled-back (in addition to anything else that should happen as a consequence of an exception having occurred).
    The ColdFusion Engine parses that declarative tag and automagically generates the necessary Java code to implement it correctly, on-the-fly, then executes that code immediately.  You don't have to be consciously aware that this is happening, even though as an application designer you can.
    This strategy is especially useful when an application needs to be "scaled up" to run on multiple servers.  When ColdFusion is configured for that environment, the code that it on-the-fly generates is a little bit different.  But the page that you wrote, isn't.

  • Radio Button in Struts

    Hi,
    Is there a way that I can preselect a radio button by using taglib in Struts?
    For example:
    In regular html code:
    <input type="radio" name="gender" value="female" checked>Female
    <input type="radio" name="gender" value="male">Male
    But with taglib, I can't use "checked"
    <html:radio property="gender" value="female">Female</html:radio>
    <html:radio property="gender" value="male">Male</html:radio>
    Is there any way I can make the radio button checked?
    I have also posted this message to JSP forum couple of days ago.

    This may be redundant but the descriptions above weren't clear to me and I was using a DynaActionForm for my JSP. So here is the solution with a little more detail if you are using a org.apache.struts.action.DynaActionForm.
    No javascript needed.
    In your struts-config.xml file specify a <form-property> like so...
    <form-bean name="myName" type="org.apache.struts.action.DynaActionForm">
    <form-property name="action" type="java.lang.String" initial="rework" />
    </form-bean>
    The value of the attribute 'name' in the form-property element needs to match the name of your radio button in your jsp page. In this example 'action' is the name of my radio buttons. Here is my JSP <html:radio> tag.
    <logic:iterate id="act" name="actions" type="org.apache.struts.util.LabelValueBean">
    <html:radio idName="act" property="action" value="value" /><bean:write name="act" property="label"/>
    </logic:iterate>
    Notice that the value of the attribute 'property' in the <html:radio> element has a value of 'action' which matches the form-property 'name' attribute.
    Now the only thing left is your controller Action. Here is a code snippet of what it should look like...
    ArrayList alActions = new ArrayList();
    alActions.add(new LabelValueBean("Rework", "rework"));
    alActions.add(new LabelValueBean(Unpublish, "unpublish"));
    params.getRequest().setAttribute("actions", alActions);
    Now the attribute you are setting in the request object ("actions") should match the <logic:iterate> 'name' attribute.
    That should be it. The Rework radio button will be select by default with this example code.
    Hope that helps.
    - Bacon -

  • Mapping the servlets' methods

    take a look at the following please:
    package somePackage;
    import java.io.IOException;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    public class Employees extends HttpServlet {
         private static final long serialVersionUID = 1L;
         public Employees() {
            super();
         protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
              MapAction(request, response);
         protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
              MapAction(request, response);
         public void MapAction(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
              String action = request.getParameter("act");
              if(action == null) ShowEmployees(request, response);
              else if(action.equals("1")) InsertEmployee(request, response);
              else if(action.equals("2")) UpdateEmployee(request, response);
              else if(action.equals("3")) DeleteEmployee(request, response);
              else ShowBadRequestError(request, response);
         public void ShowEmployees(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
         public void InsertEmployee(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
         public void UpdateEmployee(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
         public void DeleteEmployee(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
         public void ShowBadRequestError(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    }as you can see that i am mapping the query string "act" (which represent an action on the servlet) to one of the servlets' methods using
    the basic Switch statement, i know that this addressed under web frameworks specially MVCs, but so far am looking for the ways i can
    handle that using generic code rather than using framework, so are there any other ways to map to the servlet methods other than switch
    or if statements?

    Take a look at the various REST implementations out there. Another possibility is to use reflection to map some kind of construct such as Service#Method to automatically locate the problem class and method to invoke.
    As an aside, your methods other than doGet and doPost should probably be private.
    - Saish

  • PrintDialog in WordProcessor

    Hi,
    Im trying to insert this dummy print function in my Wordprocessor, the code generates a new dialog with a textfield and continues generating random numbers every 2 seconds in the textfield.
    Here is the code for the wordprocessor & print functions
    Any help much appreciated..........
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.util.*;
    import java.sql.*;
    import javax.swing.*;
    import javax.swing.text.*;
    import javax.swing.event.*;
    import javax.swing.border.*;
    import javax.swing.text.rtf.*;
    import javax.swing.undo.*;
    public class WordProcessor extends JFrame
    protected JTextPane m_monitor;
    protected StyleContext m_context;
    protected DefaultStyledDocument m_doc;
    protected RTFEditorKit m_kit;
    protected JFileChooser m_chooser;
    protected SimpleFilter m_rtfFilter;
    protected JToolBar m_toolBar;
    protected JComboBox m_cbFonts;
    protected JComboBox m_cbSizes;
    protected SmallToggleButton m_bBold;
    protected SmallToggleButton m_bItalic;
    protected String m_fontName = "";
    protected int m_fontSize = 0;
    protected boolean m_skipUpdate;
    protected int m_xStart = -1;
    protected int m_xFinish = -1;
    protected SimpleFilter m_jpgFilter;
    protected SimpleFilter m_gifFilter;
    protected ColorMenu m_foreground;
    protected ColorMenu m_background;
    protected JComboBox m_cbStyles;
    protected Hashtable m_styles;
    protected UndoManager m_undo = new UndoManager();
    protected Action m_undoAction;
    protected Action m_redoAction;
    protected String[] m_fontNames;
    protected String[] m_fontSizes;
    protected FontDialog m_fontDialog;
    protected ParagraphDialog m_paragraphDialog;
    protected FindDialog m_findDialog;//////////////////////////////////////
    public WordProcessor() {
    super("Text Editor");
    setSize(600, 400);
    m_monitor = new JTextPane();
    m_kit = new RTFEditorKit();
    m_monitor.setEditorKit(m_kit);
    m_context = new StyleContext();
    m_doc = new DefaultStyledDocument(m_context);
    m_monitor.setDocument(m_doc);
    JScrollPane ps = new JScrollPane(m_monitor);
    getContentPane().add(ps, BorderLayout.CENTER);
    JMenuBar menuBar = createMenuBar();
    setJMenuBar(menuBar);
    m_chooser = new JFileChooser();
    m_chooser.setCurrentDirectory(new File("."));
    m_rtfFilter = new SimpleFilter("rtf", "RTF Documents");
    m_chooser.setFileFilter(m_rtfFilter);
    m_gifFilter = new SimpleFilter("gif", "GIF images");
    m_jpgFilter = new SimpleFilter("jpg", "JPG images");
    CaretListener lst = new CaretListener() {
    public void caretUpdate(CaretEvent e) {
    showAttributes(e.getDot());
    m_monitor.addCaretListener(lst);
    FocusListener flst = new FocusListener() {
    public void focusGained(FocusEvent e) {
    if (m_xStart>=0 && m_xFinish>=0)
    if (m_monitor.getCaretPosition()==m_xStart) {
    m_monitor.setCaretPosition(m_xFinish);
    m_monitor.moveCaretPosition(m_xStart);
    else
    m_monitor.select(m_xStart, m_xFinish);
    public void focusLost(FocusEvent e) {
    m_xStart = m_monitor.getSelectionStart();
    m_xFinish = m_monitor.getSelectionEnd();
    m_monitor.addFocusListener(flst);
    WindowListener wndCloser = new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    System.exit(0);
    addWindowListener(wndCloser);
    showAttributes(0);
    showStyles();
    m_doc.addUndoableEditListener(new Undoer());
    setVisible(true);
    protected JMenuBar createMenuBar() {
    JMenuBar menuBar = new JMenuBar();
    JMenu mFile = new JMenu("File");
    mFile.setMnemonic('f');
    ImageIcon iconNew = new ImageIcon("file_new.gif");
    Action actionNew = new AbstractAction("New", iconNew) {
    public void actionPerformed(ActionEvent e) {
    m_doc = new DefaultStyledDocument(m_context);
    m_monitor.setDocument(m_doc);
    showAttributes(0);
    showStyles();
    m_doc.addUndoableEditListener(new Undoer());
    JMenuItem item = mFile.add(actionNew);
    item.setMnemonic('n');
    ImageIcon iconOpen = new ImageIcon("file_open.gif");
    Action actionOpen = new AbstractAction("Open...", iconOpen) {
    public void actionPerformed(ActionEvent e) {
    WordProcessor.this.setCursor(
    Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    Thread runner = new Thread() {
    public void run() {
    if (m_chooser.showOpenDialog(WordProcessor.this) !=
    JFileChooser.APPROVE_OPTION)
    return;
    WordProcessor.this.repaint();
    File fChoosen = m_chooser.getSelectedFile();
    // Recall that text component read/write operations are
    // thread safe. Its ok to do this in a separate thread.
    try {
    InputStream in = new FileInputStream(fChoosen);
    m_doc = new DefaultStyledDocument(m_context);
    m_kit.read(in, m_doc, 0);
    m_monitor.setDocument(m_doc);
    in.close();
    showAttributes(0);
    showStyles();
    m_doc.addUndoableEditListener(new Undoer());
    catch (Exception ex) {
    //ex.printStackTrace();
    System.out.println("Problems encountered: Note that RTF"
    + " support is still under development.");
    WordProcessor.this.setCursor(Cursor.getPredefinedCursor(
    Cursor.DEFAULT_CURSOR));
    runner.start();
    item = mFile.add(actionOpen);
    item.setMnemonic('o');
    ImageIcon iconSave = new ImageIcon("file_save.gif");
    Action actionSave = new AbstractAction("Save...", iconSave) {
    public void actionPerformed(ActionEvent e) {
    WordProcessor.this.setCursor(
    Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    Thread runner = new Thread() {
    public void run() {
    if (m_chooser.showSaveDialog(WordProcessor.this) !=
    JFileChooser.APPROVE_OPTION)
    return;
    WordProcessor.this.repaint();
    File fChoosen = m_chooser.getSelectedFile();
    // Recall that text component read/write operations are
    // thread safe. Its ok to do this in a separate thread.
    try {
    OutputStream out = new FileOutputStream(fChoosen);
    m_kit.write(out, m_doc, 0, m_doc.getLength());
    out.close();
    catch (Exception ex) {
    ex.printStackTrace();
    // Make sure chooser is updated to reflect new file
    m_chooser.rescanCurrentDirectory();
    WordProcessor.this.setCursor(Cursor.getPredefinedCursor(
    Cursor.DEFAULT_CURSOR));
    runner.start();
    item = mFile.add(actionSave);
    item.setMnemonic('s');
    mFile.addSeparator();
    Action actionExit = new AbstractAction("Exit") {
    public void actionPerformed(ActionEvent e) {
    System.exit(0);
    item = mFile.add(actionExit);
    item.setMnemonic('x');
    menuBar.add(mFile);
    m_toolBar = new JToolBar();
    JButton bNew = new SmallButton(actionNew, "New document");
    m_toolBar.add(bNew);
    JButton bOpen = new SmallButton(actionOpen, "Open RTF document");
    m_toolBar.add(bOpen);
    JButton bSave = new SmallButton(actionSave, "Save RTF document");
    m_toolBar.add(bSave);
    JMenu mEdit = new JMenu("Edit");
    mEdit.setMnemonic('e');
    Action action = new AbstractAction("Copy",
    new ImageIcon("edit_copy.gif"))
    public void actionPerformed(ActionEvent e) {
    m_monitor.copy();
    item = mEdit.add(action);
    item.setMnemonic('c');
    item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C,
    KeyEvent.CTRL_MASK));
    action = new AbstractAction("Cut",
    new ImageIcon("edit_cut.gif"))
    public void actionPerformed(ActionEvent e) {
    m_monitor.cut();
    item = mEdit.add(action);
    item.setMnemonic('t');
    item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X,
    KeyEvent.CTRL_MASK));
    action = new AbstractAction("Paste",
    new ImageIcon("edit_paste.gif"))
    public void actionPerformed(ActionEvent e) {
    m_monitor.paste();
    item = mEdit.add(action);
    item.setMnemonic('p');
    item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V,
    KeyEvent.CTRL_MASK));
    mEdit.addSeparator();
    m_undoAction = new AbstractAction("Undo",
    new ImageIcon("edit_undo.gif"))
    public void actionPerformed(ActionEvent e) {
    try {
    m_undo.undo();
    catch (CannotUndoException ex) {
    System.err.println("Unable to undo: " + ex);
    updateUndo();
    item = mEdit.add(m_undoAction);
    item.setMnemonic('u');
    item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Z,
    KeyEvent.CTRL_MASK));
    m_redoAction = new AbstractAction("Redo",
    new ImageIcon("edit_redo.gif"))
    public void actionPerformed(ActionEvent e) {
    try {
    m_undo.redo();
    catch (CannotRedoException ex) {
    System.err.println("Unable to redo: " + ex);
    updateUndo();
    item = mEdit.add(m_redoAction);
    item.setMnemonic('r');
    item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Y,
    KeyEvent.CTRL_MASK));
    mEdit.addSeparator();
    Action findAction = new AbstractAction("Find...",
    new ImageIcon("edit_find.gif"))
    public void actionPerformed(ActionEvent e) {
    WordProcessor.this.repaint();
    if (m_findDialog==null)
    m_findDialog = new FindDialog(WordProcessor.this, 0);
    else
    m_findDialog.setSelectedIndex(0);
    Dimension d1 = m_findDialog.getSize();
    Dimension d2 = WordProcessor.this.getSize();
    int x = Math.max((d2.width-d1.width)/2, 0);
    int y = Math.max((d2.height-d1.height)/2, 0);
    m_findDialog.setBounds(x + WordProcessor.this.getX(),
    y + WordProcessor.this.getY(), d1.width, d1.height);
    m_findDialog.show();
    item = mEdit.add(findAction);
    item.setMnemonic('f');
    item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F,
    KeyEvent.CTRL_MASK));
    Action replaceAction = new AbstractAction("Replace...") {
    public void actionPerformed(ActionEvent e) {
    WordProcessor.this.repaint();
    if (m_findDialog==null)
    m_findDialog = new FindDialog(WordProcessor.this, 1);
    else
    m_findDialog.setSelectedIndex(1);
    Dimension d1 = m_findDialog.getSize();
    Dimension d2 = WordProcessor.this.getSize();
    int x = Math.max((d2.width-d1.width)/2, 0);
    int y = Math.max((d2.height-d1.height)/2, 0);
    m_findDialog.setBounds(x + WordProcessor.this.getX(),
    y + WordProcessor.this.getY(), d1.width, d1.height);
    m_findDialog.show();
    item = mEdit.add(replaceAction);
    item.setMnemonic('r');
    item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_H,
    KeyEvent.CTRL_MASK));
    menuBar.add(mEdit);
    GraphicsEnvironment ge = GraphicsEnvironment.
    getLocalGraphicsEnvironment();
    m_fontNames = ge.getAvailableFontFamilyNames();
    m_toolBar.addSeparator();
    m_cbFonts = new JComboBox(m_fontNames);
    m_cbFonts.setMaximumSize(m_cbFonts.getPreferredSize());
    m_cbFonts.setEditable(true);
    ActionListener lst = new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    m_fontName = m_cbFonts.getSelectedItem().toString();
    MutableAttributeSet attr = new SimpleAttributeSet();
    StyleConstants.setFontFamily(attr, m_fontName);
    setAttributeSet(attr);
    m_monitor.grabFocus();
    m_cbFonts.addActionListener(lst);
    m_toolBar.add(m_cbFonts);
    m_toolBar.addSeparator();
    m_fontSizes = new String[] {"8", "9", "10", "11", "12", "14",
    "16", "18", "20", "22", "24", "26", "28", "36", "48", "72"};
    m_cbSizes = new JComboBox(m_fontSizes);
    m_cbSizes.setMaximumSize(m_cbSizes.getPreferredSize());
    m_cbSizes.setEditable(true);
    m_fontDialog = new FontDialog(this, m_fontNames, m_fontSizes);
    m_paragraphDialog = new ParagraphDialog(this);
    lst = new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    int fontSize = 0;
    try {
    fontSize = Integer.parseInt(m_cbSizes.
    getSelectedItem().toString());
    catch (NumberFormatException ex) { return; }
    m_fontSize = fontSize;
    MutableAttributeSet attr = new SimpleAttributeSet();
    StyleConstants.setFontSize(attr, fontSize);
    setAttributeSet(attr);
    m_monitor.grabFocus();
    m_cbSizes.addActionListener(lst);
    m_toolBar.add(m_cbSizes);
    m_toolBar.addSeparator();
    ImageIcon img1 = new ImageIcon("font_bold1.gif");
    ImageIcon img2 = new ImageIcon("font_bold2.gif");
    m_bBold = new SmallToggleButton(false, img1, img2,
    "Bold font");
    lst = new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    MutableAttributeSet attr = new SimpleAttributeSet();
    StyleConstants.setBold(attr, m_bBold.isSelected());
    setAttributeSet(attr);
    m_monitor.grabFocus();
    m_bBold.addActionListener(lst);
    m_toolBar.add(m_bBold);
    img1 = new ImageIcon("font_italic1.gif");
    img2 = new ImageIcon("font_italic2.gif");
    m_bItalic = new SmallToggleButton(false, img1, img2,
    "Italic font");
    lst = new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    MutableAttributeSet attr = new SimpleAttributeSet();
    StyleConstants.setItalic(attr, m_bItalic.isSelected());
    setAttributeSet(attr);
    m_monitor.grabFocus();
    m_bItalic.addActionListener(lst);
    m_toolBar.add(m_bItalic);
    JMenu mFormat = new JMenu("Format");
    mFormat.setMnemonic('o');
    item = new JMenuItem("Font...");
    item.setMnemonic('o');
    lst = new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    WordProcessor.this.repaint();
    AttributeSet a = m_doc.getCharacterElement(
    m_monitor.getCaretPosition()).getAttributes();
    m_fontDialog.setAttributes(a);
    Dimension d1 = m_fontDialog.getSize();
    Dimension d2 = WordProcessor.this.getSize();
    int x = Math.max((d2.width-d1.width)/2, 0);
    int y = Math.max((d2.height-d1.height)/2, 0);
    m_fontDialog.setBounds(x + WordProcessor.this.getX(),
    y + WordProcessor.this.getY(), d1.width, d1.height);
    m_fontDialog.show();
    if (m_fontDialog.getOption()==JOptionPane.OK_OPTION) {
    setAttributeSet(m_fontDialog.getAttributes());
    showAttributes(m_monitor.getCaretPosition());
    item.addActionListener(lst);
    mFormat.add(item);
    item = new JMenuItem("Paragraph...");
    item.setMnemonic('p');
    lst = new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    WordProcessor.this.repaint();
    AttributeSet a = m_doc.getCharacterElement(
    m_monitor.getCaretPosition()).getAttributes();
    m_paragraphDialog.setAttributes(a);
    Dimension d1 = m_paragraphDialog.getSize();
    Dimension d2 = WordProcessor.this.getSize();
    int x = Math.max((d2.width-d1.width)/2, 0);
    int y = Math.max((d2.height-d1.height)/2, 0);
    m_paragraphDialog.setBounds(x + WordProcessor.this.getX(),
    y + WordProcessor.this.getY(), d1.width, d1.height);
    m_paragraphDialog.show();
    if (m_paragraphDialog.getOption()==JOptionPane.OK_OPTION) {
    setAttributeSet(m_paragraphDialog.getAttributes(), true);
    showAttributes(m_monitor.getCaretPosition());
    item.addActionListener(lst);
    mFormat.add(item);
    mFormat.addSeparator();
    JMenu mStyle = new JMenu("Style");
    mStyle.setMnemonic('s');
    mFormat.add(mStyle);
    item = new JMenuItem("Update");
    item.setMnemonic('u');
    lst = new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    String name = (String)m_cbStyles.getSelectedItem();
    Style style = m_doc.getStyle(name);
    int p = m_monitor.getCaretPosition();
    AttributeSet a = m_doc.getCharacterElement(p).
    getAttributes();
    style.addAttributes(a);
    m_monitor.repaint();
    item.addActionListener(lst);
    mStyle.add(item);
    item = new JMenuItem("Reapply");
    item.setMnemonic('r');
    lst = new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    String name = (String)m_cbStyles.getSelectedItem();
    Style style = m_doc.getStyle(name);
    setAttributeSet(style);
    item.addActionListener(lst);
    mStyle.add(item);
    mFormat.addSeparator();
    m_foreground = new ColorMenu("Selection Foreground");
    m_foreground.setColor(m_monitor.getForeground());
    m_foreground.setMnemonic('f');
    lst = new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    MutableAttributeSet attr = new SimpleAttributeSet();
    StyleConstants.setForeground(attr, m_foreground.getColor());
    setAttributeSet(attr);
    m_foreground.addActionListener(lst);
    mFormat.add(m_foreground);
    MenuListener ml = new MenuListener() {
    public void menuSelected(MenuEvent e) {
    int p = m_monitor.getCaretPosition();
    AttributeSet a = m_doc.getCharacterElement(p).
    getAttributes();
    Color c = StyleConstants.getForeground(a);
    m_foreground.setColor(c);
    public void menuDeselected(MenuEvent e) {}
    public void menuCanceled(MenuEvent e) {}
    m_foreground.addMenuListener(ml);
    // Bug Alert! JEditorPane background color
    // doesn't work as of Java 2 FCS.
    m_background = new ColorMenu("Selection Background");
    m_background.setColor(m_monitor.getBackground());
    m_background.setMnemonic('b');
    lst = new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    MutableAttributeSet attr = new SimpleAttributeSet();
    StyleConstants.setBackground(attr, m_background.getColor());
    setAttributeSet(attr);
    m_background.addActionListener(lst);
    mFormat.add(m_background);
    ml = new MenuListener() {
    public void menuSelected(MenuEvent e) {
    int p = m_monitor.getCaretPosition();
    AttributeSet a = m_doc.getCharacterElement(p).
    getAttributes();
    Color c = StyleConstants.getBackground(a);
    m_background.setColor(c);
    public void menuDeselected(MenuEvent e) {}
    public void menuCanceled(MenuEvent e) {}
    m_background.addMenuListener(ml);
    // Bug Alert! Images do not get saved.
    mFormat.addSeparator();
    item = new JMenuItem("Insert Image");
    item.setMnemonic('i');
    lst = new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    m_chooser.addChoosableFileFilter(m_gifFilter);
    m_chooser.addChoosableFileFilter(m_jpgFilter);
    m_chooser.setFileFilter(m_gifFilter);
    m_chooser.removeChoosableFileFilter(m_rtfFilter);
    Thread runner = new Thread() {
    public void run() {
    if (m_chooser.showOpenDialog(WordProcessor.this) !=
    JFileChooser.APPROVE_OPTION)
    return;
    WordProcessor.this.repaint();
    File fChoosen = m_chooser.getSelectedFile();
    ImageIcon icon = new ImageIcon(fChoosen.getPath());
    int w = icon.getIconWidth();
    int h = icon.getIconHeight();
    if (w<=0 || h<=0) {
    JOptionPane.showMessageDialog(WordProcessor.this,
    "Error reading image file\n"+
    fChoosen.getPath(), "Warning",
    JOptionPane.WARNING_MESSAGE);
    return;
    MutableAttributeSet attr = new SimpleAttributeSet();
    StyleConstants.setIcon(attr, icon);
    int p = m_monitor.getCaretPosition();
    try {
    m_doc.insertString(p, " ", attr);
    catch (BadLocationException ex) {}
    // Its ok to do this outside of the event-dispatching
    // thread because the chooser is not visible here.
    m_chooser.addChoosableFileFilter(m_rtfFilter);
    m_chooser.setFileFilter(m_rtfFilter);
    m_chooser.removeChoosableFileFilter(m_gifFilter);
    m_chooser.removeChoosableFileFilter(m_jpgFilter);
    runner.start();
    item.addActionListener(lst);
    mFormat.add(item);
    menuBar.add(mFormat);
    m_toolBar.addSeparator();
    m_cbStyles = new JComboBox();
    m_cbStyles.setMaximumSize(m_cbStyles.getPreferredSize());
    m_cbStyles.setEditable(true);
    m_toolBar.add(m_cbStyles);
    lst = new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    if (m_skipUpdate || m_cbStyles.getItemCount()==0)
    return;
    String name = (String)m_cbStyles.getSelectedItem();
    int index = m_cbStyles.getSelectedIndex();
    int p = m_monitor.getCaretPosition();
    // New name entered
    if (index == -1) {
    m_cbStyles.addItem(name);
    Style style = m_doc.addStyle(name, null);
    AttributeSet a = m_doc.getCharacterElement(p).
    getAttributes();
    style.addAttributes(a);
    return;
    // Apply the selected style
    Style currStyle = m_doc.getLogicalStyle(p);
    if (!currStyle.getName().equals(name)) {
    Style style = m_doc.getStyle(name);
    setAttributeSet(style);
    m_cbStyles.addActionListener(lst);
    JMenu mTools = new JMenu("Tools");
    mTools.setMnemonic('t');
    Action spellAction = new AbstractAction("Print...",
    new ImageIcon("tools_abc.gif"))
    public void actionPerformed(ActionEvent e) {
    SpellChecker checker = new SpellChecker(WordProcessor.this);
    WordProcessor.this.setCursor(Cursor.getPredefinedCursor(
    Cursor.WAIT_CURSOR));
    checker.start();
    item = mTools.add(spellAction);
    item.setMnemonic('s');
    item.setAccelerator(KeyStroke.getKeyStroke(
    KeyEvent.VK_F7, 0));
    menuBar.add(mTools);
    m_toolBar.addSeparator();
    m_toolBar.add(new SmallButton(spellAction,
    "Spell checker"));
    getContentPane().add(m_toolBar, BorderLayout.NORTH);
    return menuBar;
    protected void showAttributes(int p) {
    m_skipUpdate = true;
    AttributeSet a = m_doc.getCharacterElement(p).
    getAttributes();
    String name = StyleConstants.getFontFamily(a);
    if (!m_fontName.equals(name)) {
    m_fontName = name;
    m_cbFonts.setSelectedItem(name);
    int size = StyleConstants.getFontSize(a);
    if (m_fontSize != size) {
    m_fontSize = size;
    m_cbSizes.setSelectedItem(Integer.toString(m_fontSize));
    boolean bold = StyleConstants.isBold(a);
    if (bold != m_bBold.isSelected())
    m_bBold.setSelected(bold);
    boolean italic = StyleConstants.isItalic(a);
    if (italic != m_bItalic.isSelected())
    m_bItalic.setSelected(italic);
    Style style = m_doc.getLogicalStyle(p);
    name = style.getName();
    m_cbStyles.setSelectedItem(name);
    if (m_styles!=null && m_styles.get(name)==null) {
    style = m_doc.addStyle(name, null);
    a = m_doc.getCharacterElement(p).getAttributes();
    style.addAttributes(a);
    m_styles.put(name, style);
    m_skipUpdate = false;
    protected void setAttributeSet(AttributeSet attr) {
    setAttributeSet(attr, false);
    protected void setAttributeSet(AttributeSet attr,
    boolean setParagraphAttributes)
    if (m_skipUpdate)
    return;
    int xStart = m_monitor.getSelectionStart();
    int xFinish = m_monitor.getSelectionEnd();
    if (!m_monitor.hasFocus()) {
    xStart = m_xStart;
    xFinish = m_xFinish;
    if (setParagraphAttributes)
    m_doc.setParagraphAttributes(xStart,
    xFinish - xStart, attr, false);
    else if (xStart != xFinish)
    m_doc.setCharacterAttributes(xStart,
    xFinish - xStart, attr, false);
    else {
    MutableAttributeSet inputAttributes =
    m_kit.getInputAttributes();
    inputAttributes.addAttributes(attr);
    protected void showStyles() {
    m_skipUpdate = true;
    if (m_cbStyles.getItemCount() > 0)
    m_cbStyles.removeAllItems();
    Enumeration en = m_doc.getStyleNames();
    while (en.hasMoreElements()) {
    String str = en.nextElement().toString();
    m_cbStyles.addItem(str);
    m_styles = new Hashtable();
    m_skipUpdate = false;
    protected void updateUndo() {
    if(m_undo.canUndo()) {
    m_undoAction.setEnabled(true);
    m_undoAction.putValue(Action.NAME,
    m_undo.getUndoPresentationName());
    else {
    m_undoAction.setEnabled(false);
    m_undoAction.putValue(Action.NAME, "Undo");
    if(m_undo.canRedo()) {
    m_redoAction.setEnabled(true);
    m_redoAction.putValue(Action.NAME,
    m_undo.getRedoPresentationName());
    else {
    m_redoAction.setEnabled(false);
    m_redoAction.putValue(Action.NAME, "Redo");
    public Document getDocument() { return m_doc; }
    public JTextPane getTextPane() { return m_monitor; }
    public void setSelection(int xStart, int xFinish, boolean moveUp) {
    if (moveUp) {
    m_monitor.setCaretPosition(xFinish);
    m_monitor.moveCaretPosition(xStart);
    else
    m_monitor.select(xStart, xFinish);
    m_xStart = m_monitor.getSelectionStart();
    m_xFinish = m_monitor.getSelectionEnd();
    public static void main(String argv[]) {
    new WordProcessor();
    class Undoer implements UndoableEditListener
    public Undoer() {
    m_undo.die();
    updateUndo();
    public void undoableEditHappened(UndoableEditEvent e) {
    UndoableEdit edit = e.getEdit();
    m_undo.addEdit(e.getEdit());
    updateUndo();
    // Class SmallButton unchanged from section 4.8
    class SmallButton extends JButton implements MouseListener
    protected Border m_raised;
    protected Border m_lowered;
    protected Border m_inactive;
    public SmallButton(Action act, String tip) {
    super((Icon)act.getValue(Action.SMALL_ICON));
    m_raised = new BevelBorder(BevelBorder.RAISED);
    m_lowered = new BevelBorder(BevelBorder.LOWERED);
    m_inactive = new EmptyBorder(2, 2, 2, 2);
    setBorder(m_inactive);
    setMargin(new Insets(1,1,1,1));
    setToolTipText(tip);
    addActionListener(act);
    addMouseListener(this);
    setRequestFocusEnabled(false);
    public float getAlignmentY() { return 0.5f; }
    public void mousePressed(MouseEvent e) {
    setBorder(m_lowered);
    public void mouseReleased(MouseEvent e) {
    setBorder(m_inactive);
    public void mouseClicked(MouseEvent e) {}
    public void mouseEntered(MouseEvent e) {
    setBorder(m_raised);
    public void mouseExited(MouseEvent e) {
    setBorder(m_inactive);
    // Class SimpleFilter unchanged from section 14.1.9
    class SimpleFilter extends javax.swing.filechooser.FileFilter
    private String m_description = null;
    private String m_extension = null;
    public SimpleFilter(String extension, String description) {
    m_description = description;
    m_extension = "."+extension.toLowerCase();
    public String getDescription() {
    return m_description;
    public boolean accept(File f) {
    if (f == null)
    return false;
    if (f.isDirectory())
    return true;
    return f.getName().toLowerCase().endsWith(m_extension);
    // Class SmallToggleButton unchanged from section 4.8
    class SmallToggleButton extends JToggleButton implements ItemListener
    protected Border m_raised;
    protected Border m_lowered;
    public SmallToggleButton(boolean selected, ImageIcon imgUnselected,
    ImageIcon imgSelected, String tip)
    super(imgUnselected, selected);
    setHorizontalAlignment(CENTER);
    setBorderPainted(true);
    m_raised = new BevelBorder(BevelBorder.RAISED);
    m_lowered = new BevelBorder(BevelBorder.LOWERED);
    setBorder(selected ? m_lowered : m_raised);
    setMargin(new Insets(1,1,1,1));
    setToolTipText(tip);
    setRequestFocusEnabled(false);
    setSelectedIcon(imgSelected);
    addItemListener(this);
    public float getAlignmentY() { return 0.5f; }
    public void itemStateChanged(ItemEvent e) {
    setBorder(isSelected() ? m_lowered : m_raised);
    // Class ColorMenu unchanged from section 12.5
    class ColorMenu extends JMenu
    protected Border m_unselectedBorder;
    protected Border m_selectedBorder;
    protected Border m_activeBorder;
    protected Hashtable m_panes;
    protected ColorPane m_selected;
    public ColorMenu(

    Sorry about that...newbie here....
    Here we go.....what im having trouble doing is inserting this print dialog into my menu
    Here is the print snippet
    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
                                         //The popup window in this case is not modal. This means that the
                                         //user isnt required to respond to the popup before the program continues running
                 * 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.CENTER);
                panel.add(backing, BorderLayout.LINE_END);
                return panel;
            private ActionListener ticker = new ActionListener()
                public void actionPerformed(ActionEvent e)
                    label.setText(String.valueOf(getRandomNumber()));
            private int getRandomNumber()
                return r.nextInt(1000) + 1;       // shift from 0-9 to 1-1000
            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();
    Here is my menu code
    Action actionPrint = new AbstractAction("Print...", iconPrint) {
          public void actionPerformed(ActionEvent e) {
            WordProcessor.this.setCursor(
              Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            Thread runner = new Thread() {
              public void run() {
              //this is where I want to put the print function, so when the user click on print the print dialog box will appear

  • Illustrator autosave recovery file...

    Two questions...
    I just downloaded Illustrator CC and it crashed while I was working on it.
    1) How/where do I recover the file
    2) Where do I set the autosave options?
    Thanks
    R.

    I Found this link, and it works
    all you must do is to load the action when you open a file and play it
    by setting intervals such as 30 secs
    and not in the post but can set two save options so it saves two versions of recent changes almost like a history
    design.tutsplus.com/tutorials/autosave-in-adobe-illustrator-using-the-actions-palette--vec tor-4698
    SCRIPTING 
    Autosave in Adobe Illustrator Using the Actions Palette
    by Iaroslav Lazunov24 Aug 201140 Comments
    187
    53
    26
    If you participate in vector graphics forums, then you might have seen the question "Is there an Autosave feature in Adobe Illustrator?" and theorists would always say "no, there is not," more often advising to save the work through the Save and Save As commands.
    These people are not familiar with these fluttering feelings of delight of a true artist, when vector is so nicely flexible and filled with the desired beauty, when you forget about the time and space, not even mentioning some trivial Shift + S. If you're one of those artists, I can teach you how to create an "Auto Save" on your own. This technique was developed by my friend Igor Tchernitsyn.
    Step 1
    Create a new file (File > New) and name it in the open dialog box. Open the Action palette (Window > Action). Activate the Create New Set button and name it "Autosave."
    Step 2
    Activate the Create New Action button and leave the name that is given by default as "Action 1."
    Re-activate the Create New Action button and leave the name that is given by default as "Action 2."
    Stop Action recording with the Stop Playing / Recording button.
    Step 3
    Select "Action 1" and start action recording, by pressing the Begin Recording button.
    Select "Action 2" and click on the Play Current Selection button.
    Stop Action recording by pressing the Stop Playing / Recording button.
    Step 4
    Select "Action 2," and turn off the Toggle Item in front of "Action 1," by removing it from the palette. Now start action recording by pressing the Begin Recording button.
    Step 5
    Select "Action 1" and activate the Play Current Selection button.
    If you participate in vector graphics forums, then you might have seen the question "Is there an Autosave feature in Adobe Illustrator?" and theorists would always say "no, there is not," more often advising to save the work through the Save and Save As commands.
    These people are not familiar with these fluttering feelings of delight of a true artist, when vector is so nicely flexible and filled with the desired beauty, when you forget about the time and space, not even mentioning some trivial Shift + S. If you're one of those artists, I can teach you how to create an "Auto Save" on your own. This technique was developed by my friend Igor Tchernitsyn.
    Step 1
    Create a new file (File > New) and name it in the open dialog box. Open the Action palette (Window > Action). Activate the Create New Set button and name it "Autosave."
    Step 2
    Activate the Create New Action button and leave the name that is given by default as "Action 1."
    Re-activate the Create New Action button and leave the name that is given by default as "Action 2."
    Stop Action recording with the Stop Playing / Recording button.
    Step 3
    Select "Action 1" and start action recording, by pressing the Begin Recording button.
    Select "Action 2" and click on the Play Current Selection button.
    Stop Action recording by pressing the Stop Playing / Recording button.
    Step 4
    Select "Action 2," and turn off the Toggle Item in front of "Action 1," by removing it from the palette. Now start action recording by pressing the Begin Recording button.
    Step 5
    Select "Action 1" and activate the Play Current Selection button.
    Step 6
    Wait until the record is complete and stop it by activating the Stop Playing / Recording button.
    Step 7
    Turn on the Toggle Item in front of "Action 1."
    Action that works in a closed cycle is ready, now you need to check if it works.
    Step 8
    Select the Set "Autosave" and click on Play Current Selection button.
    If you correctly repeated all the above mentioned routine operations, you will see how the Action works non-stop, irritating your eyes with continuous blinking. Now stop Action, by clicking Stop Playing / Recording button.
    Step 9
    Select Action 1 and start action recording, by pressing the Begin Recording button.
    Now write a new action in the Action, to do this go to File > Save As.
    Choose a folder on the disk to which we will save our work.
    Stop recording with action button Stop Playing / Recording. Note that there is a new recording in "Action 1."
    Step 10
    Now select the recording "Save As" in "Action 1" and drag it to one step up, as shown below.
    Step 11
    Select the recording "Save As" in "Action 1," and while holding down Alt, move it before "Play Action" recording in "Action 2."
    Step 12
    Now let's test the created "Autosave" action to work. Select the Set "Autosave" button and start the action with the Play Current Selection.
    Step 13
    Start drawing, preferably something complex using a number of layers and effects, and the action will automatically save your brilliant creation. Everything is fine, but why do we need an immediate saving of all that goes out of your brilliant pen. Set the time interval between the savings. Choose the Playback Option from the menu of the Action palette.
    Activate the "Pause For" option and set the time interval between the acts and action. I set the max - 100 seconds, that means the interval between the savings will be 200 seconds.
    Of course, you can set time interval you like. The Action is ready, before you start working do not forget to turn it on by pressing the Play Current Selection button, and turn it off at the end by pressing the Stop Playing / Recording button.
    Step 14
    In order not to create an action of the autosave from the beginning each time, save it. Press the Stop Playing / Recording button and open the Action palette menu and select Save Action and save it in a convenient place.
    Advertisement
    Step 15
    To download this action to the palette, open the Action palette menu and choose Load Action.
    Conclusion
    Hopefully, this technique is as useful for you as it is for me, and you will not be freaking out the next time your power turns off.
    ENd
    i tried it and it works as long as all steps are followed

Maybe you are looking for