Undo selection JComboBox

Hi,
How can i add an undo selection functionality in a jComboBox? I know how it works in textcomponents and buttons but i have a problem with jComboBoxs.
Thnx

Hi,
How can i add an undo selection functionality in a
jComboBox? I know how it works in textcomponents and
buttons but i have a problem with jComboBoxs.
ThnxHi,
I won't claim to be an expert in the inner workings of the JComboBox class however from my experience, the way you would implement an undo functionality, at least the way I would do it, would be to implement an ordered collection (List or Stack or Queue, obviously not Set) to store something to remember the selection by...if the actual actual list contents can change dramatically or if the JComboBox is 'editable', then I would suggest storing objects.
Since Java stores objects as references rather than deep copying to create whole object instances, you would not have to worry about a whole ton of memory usage since only 1 copy of every object would ever be created.
Later, when the user invoked "Undo", if the object in question was the combo box, then you would just go to the last item in the list and set the selected index or value (depending on what you saved) to the value in the collection.
I don't have details or much code because I'm on my lunch break at work and don't work with java at my job, but try to come up with it on your own now and if you still can't do it, respond and I'll try to write something when I'm at home. Good Luck!

Similar Messages

  • Undo selection in JComboBox

    Hi,
    How can i add an undo selection functionality in a jComboBox? I know how it works in textcomponents and buttons but i have a problem with jComboBoxs.
    Thnx

    Hi,
    How can i add an undo selection functionality in a
    jComboBox? I know how it works in textcomponents and
    buttons but i have a problem with jComboBoxs.
    ThnxHi,
    I won't claim to be an expert in the inner workings of the JComboBox class however from my experience, the way you would implement an undo functionality, at least the way I would do it, would be to implement an ordered collection (List or Stack or Queue, obviously not Set) to store something to remember the selection by...if the actual actual list contents can change dramatically or if the JComboBox is 'editable', then I would suggest storing objects.
    Since Java stores objects as references rather than deep copying to create whole object instances, you would not have to worry about a whole ton of memory usage since only 1 copy of every object would ever be created.
    Later, when the user invoked "Undo", if the object in question was the combo box, then you would just go to the last item in the list and set the selected index or value (depending on what you saved) to the value in the collection.
    I don't have details or much code because I'm on my lunch break at work and don't work with java at my job, but try to come up with it on your own now and if you still can't do it, respond and I'll try to write something when I'm at home. Good Luck!

  • How do I undo selecting do not save password?

    The first time I logged into my hotmail account Firefox asked the question - did I want Firefox to remember my password? I selected never. Now I wish to undo that selection and select remember. I went to the tools and cleared out my email address, reopened it to try to select remember. That did not work.

    If you select never then you create an exception that you have to remove.
    Remove the site from the exceptions: Tools > Options > Security: Passwords: Exceptions
    * [[Remembering passwords]]

  • How to undo "select distinct" in OBIEE

    Hello guys
    I found that pretty much in all the reports that we created in OBIEE, the presentation service would generate SQL that starts with "select distinct" when I view the query log..
    I'd like to know what configuration in the Admin Tool or presentation service is controlling this behavior of OBIEE. For some reason as I am tuning the performance by running the same query in DB, the same query without "distinct" can go so much faster than the original one from OBIEE.. So I'd like to configure my RPD so that certain reports will not have "select distinct". I know that by default, the BI server will always generate a "distinct", but is there a way to override this default, if not, what might be some performance tuning tactics I can use?
    Any thoughts?
    Thanks
    Edited by: user7276913 on Oct 27, 2009 8:20 PM

    BenS wrote:
    Two issues with this that I encountere:
    When I selected the first suggested option at the Physical Layer for the database, I found the "DISTINCT SUPPORTED" option. There were two columns checked: Value and Default. I was able to unselect Value but not Default.
    (1) What is the difference between Value and Default?
    (2) If I only unselect Value will it stop Answers from adding the DISTINCT to every query created?
    Second, when I selected the source from the business model mapping, it already did not have the DISTINCT box checked. Therefore, I could not limit this at the Logical layer as I would have preferred.
    If you could help me understand the first option it may clarify how to implement option # 2.
    Thanks...1) the defaults are stored in an .ini file and serve the purpose of defining the defaults when you hit the 'revert to default' button.
    If you unselect value, you are telling OBIEE that the database for which you are changing these options does not support the distinct clause, I doubt you wish to do this across the entire application.
    I think you will find that OBIEE applies the distinct :
    1) when the LTS has distinct ticked.
    2) When the column in question is not part of a dimension hierachy key (if it is, your telling the OBIEE server these should be unique, so wont issue the distinct)
    or
    3) the column forms part of a key in either logical BMM layer or as part of a physical key.
    adding the column to a Dim Hierachy wont be an option in most cases, you could try playing with just setting this column as a key on the BMM layer or Physical layer , and let us know if this helps.

  • Help get selected JComboBox in JTable

    i wanne to check which checkbox i select to in my JTable to delete it or get value from its specified raw
    i have a table updated dynamically with action on its jinternalfram
    wanne know which checkboxes i choose from a table

    information is lacking
    how do you "choose" a box
    did you try adding a listener to your table ?

  • Photoshop CS6 - Quick Selection tool freezes Photoshop/ becomes unresponsive for minutes

    After only two selections the tool becomes unresponsive for minutes.
    I'm on a 2.6 Ghz retina MacBook Pro, 16 Gb RAM, and this in connection with an SSD should make this tool very good to use. Operating system: OS X 10.8 "Mountain Lion", latest update.
    Unfortunately, it seems to develop some kind of overload, during which you cannot use Photoshop at all. No commands like "undo selection", "quit", "close file" are accepted.
    There is no beachball, no other signs that Photoshop is working on something.
    Hint: it seems to happen when you option select (subtract from an existing selection).
    Hint: the freeze can be shortened by a tool switch (has to be through clicking on a tool, keyboard commands are frozen as well)
    Hint: the "subtract selection" move that caused the freeze appears after Photoshop comes back to life after a couple of minutes. The subtraction to the selection seems to be random, makes no sense, and is not the regular function of the tool.
    First step after this freeze would be to undo the last selection, and continue working.
    If you do several "add to selection" moves, they add up in a kind of waiting line. If you do the subtract from selection move, this doesn't work, and the freeze happens.
    So far, I have not noticed the freeze when adding to a selection. Adding to a selection was always quick and instant. The bug must sit in the "subtract from selection" code.
    On most freezes, the ants continue walking, I just had one (again with subtracting selection) where even the ants stopped walking.
    I don't think it has anything to do with Photoshop working. I have used the quick selection tool regularly under CS5 on my old machine (which was a museum piece), and while I had to wait sometimes, it was never ground to a freeze/halt like the quick selection tool under CS6.

    Did this work before, or has it always been this way?  Not a bug or everyone with your system would be complaining.  Have not seen that.
    If it has always worked that way a reset of preferences will probably not do anything.
    A reset of preferences will reset to factory defaults, so you will have to reset to saved workspace.
    Do you have at least 10% free disk space? 

  • JComboBox addActionListener?

    Hi, I'm trying to write a program so that when the user makes a selection from the combobox, the selection will be inputted into a string.
    However, whenever I try to run the program it gives me this error:
    "Questions.java": addItemListener(java.awt.event.ItemListener) in javax.swing.JComboBox cannot be applied to (Questions) at line 120, column 15
    This is the part of my code which I think is relevent:
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    import java.io.*;
    public class Questions extends JFrame {
      private Container container;
      private GridBagLayout gbLayout;
      private GridBagConstraints gbConstraints;
      private ButtonGroup radioGroup;
      JLabel correctL, incorrectL, correctNumL, incorrectNumL,
          youSelectL, correctSelectL;
      JButton nextB, exitB, guessB;
      JCheckBox aCB, bCB, cCB, dCB;
      JTextArea questionTA;
      JComboBox selection = new JComboBox();
      public static int qNum[] = new int[20];
      public static String question[] = new String[20];
      public static String choiceA[] = new String[20];
      public static String choiceB[] = new String[20];
      public static String choiceC[] = new String[20];
      public static String choiceD[] = new String[20];
      public static String answer[] = new String[20];
      public static int recordNum = (int) (Math.random() * 20);
      public static int total = 0;
      public static int right = 0;
      public static int wrong = 0;
      public static String whichQselected;
      public static boolean qAnswered = false;
      nextButtonHandler nextHandler;
      guessButtonHandler guessHandler;
      exitButtonHandler exitHandler;
      public Questions() {
        super("Questions");
        setContentPane(new ContentPanel("bg.gif"));
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        container = getContentPane();
        gbLayout = new GridBagLayout();
        container.setLayout(gbLayout);
        gbConstraints = new GridBagConstraints();
        questionTA = new JTextArea(question[recordNum], 3, 23);
        questionTA.setForeground(Color.blue);
        questionTA.setFont(new Font("Impact", Font.PLAIN, 15));
        questionTA.setWrapStyleWord(true);
        questionTA.setLineWrap(true);
        questionTA.setEditable(false);
        correctL = new JLabel("Correct Answers: ");
        correctL.setForeground(Color.magenta);
        correctL.setFont(new Font("Ariel", Font.PLAIN, 10));
        correctNumL = new JLabel("0/0");
        correctNumL.setForeground(Color.magenta);
        correctNumL.setFont(new Font("Ariel", Font.PLAIN, 10));
        incorrectL = new JLabel("Incorrect Answers: ");
        incorrectL.setForeground(Color.red);
        incorrectL.setFont(new Font("Ariel", Font.PLAIN, 10));
        incorrectNumL = new JLabel("0/0");
        incorrectNumL.setForeground(Color.red);
        incorrectNumL.setFont(new Font("Ariel", Font.PLAIN, 10));
        youSelectL = new JLabel("You've selected:");
        youSelectL.setForeground(Color.orange);
        youSelectL.setFont(new Font("Ariel", Font.BOLD, 13));
        correctSelectL = new JLabel("The Correct answer is: ");
        correctSelectL.setForeground(Color.ORANGE);
        correctSelectL.setFont(new Font("Ariel", Font.BOLD, 13));
        nextB = new JButton("Next Question");
        nextHandler = new nextButtonHandler();
        nextB.addActionListener(nextHandler);
        nextB.setBackground(Color.WHITE);
        guessB = new JButton("Guess Picture");
        guessHandler = new guessButtonHandler();
        guessB.addActionListener(guessHandler);
        guessB.setBackground(Color.WHITE);
        exitB = new JButton("Exit");
        exitHandler = new exitButtonHandler();
        exitB.addActionListener(exitHandler);
        exitB.setBackground(Color.WHITE);
        aCB = new JCheckBox(choiceA[recordNum]);
        aCB.setBackground(Color.white);
        bCB = new JCheckBox(choiceB[recordNum]);
        bCB.setBackground(Color.white);
        cCB = new JCheckBox(choiceC[recordNum]);
        cCB.setBackground(Color.white);
        dCB = new JCheckBox(choiceD[recordNum]);
        dCB.setBackground(Color.white);
        //register events
        CheckBoxHandler handler = new CheckBoxHandler();
        aCB.addItemListener(handler);
        bCB.addItemListener(handler);
        cCB.addItemListener(handler);
        dCB.addItemListener(handler);
        //PROBLEM HERE!!!
        selection.addItemListener(this);
        selection.addItem("Geography Questions");
        selection.addItem("Math Questions");
        selection.addItem("Mixed Questions");
        selection.addItem("Music Questions");
        selection.addItem("Sports Questions");
        selection.addItem("TV Questions");
        addComponent(selection, 0, 0, 3, 1);
        addComponent(questionTA, 1, 0, 3, 1);
        addComponent(aCB, 2, 0, 1, 1);
        addComponent(bCB, 3, 0, 1, 1);
        addComponent(cCB, 4, 0, 1, 1);
        addComponent(dCB, 5, 0, 1, 1);
        addComponent(correctL, 2, 1, 1, 1);
        addComponent(correctNumL, 2, 2, 1, 1);
        addComponent(incorrectL, 2, 1, 1, 1);
        addComponent(incorrectNumL, 2, 2, 1, 1);
        addComponent(nextB, 6, 0, 1, 1);
        addComponent(guessB, 6, 1, 1, 1);
        addComponent(exitB, 6, 2, 1, 1);
        addComponent(youSelectL, 7, 0, 2, 1);
        addComponent(correctSelectL, 8, 0, 2, 1);
        gbConstraints.fill = GridBagConstraints.BOTH;
        setSize(420, 350);
        show();
    //ACTION PERFORMED FOR JCOMBOBOX!!
      public void actionPerformed(ActionEvent e) {
        String whichQ[] = {"Geography", "Math",
                          "Mixed", "Music", "Sports", "TV"};
        int Selected = ((JComboBox) (e.getSource())).getSelectedIndex();
        whichQselected = whichQ[Selected];
      }Thanks in advance!

    Also, you have added an item listener and implemented the method from the action listener. Above all, you did not declare your class as implementing the ActionListener interface.

  • UNDO Tablespace Issue - URGENT

    I had issues with UNDO. Here is what happened -
    SQL> alter tablespace UNDO
    2 add datafile '/oracle/TESTDB/data04/TESTDB_undo_04.db' size 100M autoextend on maxsize 10000M;
    SQL> select file_name,bytes/1024/1024 MB, maxbytes/1024/1024 MMB from dba_data_files where tablespace_name='UNDO';
    FILE_NAME MB MMB
    /oracle/TESTDB/data02/TESTDB_undo_01.dbf 6158 10240
    /oracle/TESTDB/data01/TESTDB_undo_02.dbf 7703 0
    /oracle/TESTDB/data03/TESTDB_undo_03.dbf 7636 0
    /oracle/TESTDB/data04/TESTDB_undo_04.db 100 10000
    But after some time this same query gave me this error -
    SQL> select file_name,bytes/1024/1024 MB, maxbytes/1024/1024 MMB from dba_data_files where tablespace_name='UNDO';
    FILE_NAME MB MMB
    /oracle/TESTDB/data02/TESTDB_undo_01.dbf 6158 10240
    /oracle/TESTDB/data01/TESTDB_undo_02.dbf 7703 0
    /oracle/TESTDB/data03/TESTDB_undo_03.dbf 7636 0
    /oracle/TESTDB/data04/TESTDB_undo_04.db
    Users then started complaining about it.
    Queries like this also started giving us these problems -
    SQL> select file_id,file_name,bytes/1024/1024 MB, maxbytes/1024/1024 MMB,status from dba_data_files where tablespace_name='UNDO';
    select file_id,file_name,bytes/1024/1024 MB, maxbytes/1024/1024 MMB,status from dba_data_files where tablespace_name='UNDO'
    ERROR at line 1:
    ORA-00376: file 67 cannot be read at this time
    ORA-01110: data file 67: '/oracle/TESTDB/data04/TESTDB_undo_04.db'
    Then I though of bouncing the database but then it also giving some problem -
    SQL> shutdown immediate;
    ORA-00376: file 67 cannot be read at this time
    ORA-01110: data file 67: '/oracle/TESTDB/data04/TESTDB_undo_04.db'
    SQL> exit
    Disconnected from Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    TESTDB - /oracle/TESTDB/data03> sqlplus / as sysdba
    SQL*Plus: Release 11.1.0.7.0 - Production on Fri Jul 30 09:27:24 2010
    Copyright (c) 1982, 2008, Oracle. All rights reserved.
    Connected.
    SQL> shutdown abort;
    ORACLE instance shut down.
    SQL> startup;
    ORACLE instance started.
    Total System Global Area 4175568896 bytes
    Fixed Size 2160352 bytes
    Variable Size 3137341728 bytes
    Database Buffers 1023410176 bytes
    Redo Buffers 12656640 bytes
    Database mounted.
    ORA-00376: file 67 cannot be read at this time
    ORA-01110: data file 67: '/oracle/TESTDB/data04/TESTDB_undo_04.db'
    Thought of recovering the this tablespace but still getting this error -
    RMAN> recover tablespace "UNDO";
    Starting recover at 30-JUL-10
    starting full resync of recovery catalog
    full resync complete
    allocated channel: ORA_SBT_TAPE_1
    channel ORA_SBT_TAPE_1: SID=278 device type=SBT_TAPE
    channel ORA_SBT_TAPE_1: Data Protection for Oracle: version 5.5.1.0
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: SID=277 device type=DISK
    RMAN-00571: ===========================================================
    RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
    RMAN-00571: ===========================================================
    RMAN-03002: failure of recover command at 07/30/2010 09:34:17
    ORA-00376: file 67 cannot be read at this time
    ORA-01110: data file 67: '/oracle/TESTDB/data04/TESTDB_undo_04.db'
    Will greatly appreciate if someone can give some advice here.

    TESTDB - /oracle/TESTDB/data04> ls -ltr
    total 25751072
    drwxr-xr-x 2 oracle dba 256 Apr 9 10:09 lost+found
    -rw-r----- 1 oracle dba 104865792 Jul 30 09:08 TESTDB_undo_04.db
    -rw-r----- 1 oracle dba 104865792 Jul 30 09:50 TESTDB_paipas_idx_256k_a_01
    -rw-r----- 1 oracle dba 104865792 Jul 30 09:50 TESTDB_cmwdgt_tab_1m_a_01
    -rw-r----- 1 oracle dba 104865792 Jul 30 09:50 TESTDB_cmwdgt_idx_256k_a_01
    -rw-r----- 1 oracle dba 104865792 Jul 30 09:50 TESTDB_cmpcc_idx_256k_a_01
    -rw-r----- 1 oracle dba 232792064 Jul 30 09:50 TESTDB_cmcap_tab_1m_a_01
    -rw-r----- 1 oracle dba 104865792 Jul 30 09:50 TESTDB_cmcap_idx_256k_a_01
    -rw-r----- 1 oracle dba 504373248 Jul 30 09:50 TESTDB_cctlrpt_tab_1m_a_01
    -rw-r----- 1 oracle dba 1356865536 Jul 30 09:50 TESTDB_ccstgrpt_tab_1m_a_01
    -rw-r----- 1 oracle dba 4481622016 Jul 30 09:50 TESTDB_ccoprpt_tab_1m_a_01
    -rw-r----- 1 oracle dba 653271040 Jul 30 09:50 TESTDB_ccindrpt_idx_256K_a_01
    -rw-r----- 1 oracle dba 2752520192 Jul 30 09:50 TESTDB_cccnv_tab_1m_a_02.dbf
    -rw-r----- 1 oracle dba 168828928 Jul 30 09:50 TESTDB_ccadmrpt_tab_1m_a_01
    -rw-r----- 1 oracle dba 104865792 Jul 30 09:50 TESTDB_cmwos_idx_256k_a_01
    -rw-r----- 1 oracle dba 104865792 Jul 30 09:50 TESTDB_cmgcd_idx_256k_a_01
    -rw-r----- 1 oracle dba 104865792 Jul 30 09:50 TESTDB_cmfos_idx_256k_a_01
    -rw-r----- 1 oracle dba 247472128 Jul 30 09:52 TESTDB_cmpcc_tab_1m_a_01
    -rw-r----- 1 oracle dba 104865792 Jul 30 09:53 TESTDB_cmpe_tab_1m_a_01
    -rw-r----- 1 oracle dba 104865792 Jul 30 09:53 TESTDB_cmpe_idx_256k_a_01
    -rw-r----- 1 oracle dba 104865792 Jul 30 09:54 TESTDB_cmgcd_tab_1m_a_01
    -rw-r----- 1 oracle dba 247472128 Jul 30 09:57 TESTDB_cmwos_tab_1m_a_01
    -rw-r----- 1 oracle dba 364912640 Jul 30 09:58 TESTDB_cmfos_tab_1m_a_01
    -rw-r----- 1 oracle dba 916004864 Jul 30 09:58 TESTDB_sysaux_02.dbf

  • Multiple Selection with JCombo Box

    I want to make a multiple - selection JComboBox enables the user to select many items from JComboBox and copy items from one JComboBox to another.How can I do this?

    Hello,
    ComboBoxModel allows only single selection. It's better to use a JList instead because it isnt worthwhile the effort to create another multi-selection model.
    regards,
    Tim

  • Undo tablespace keeps on growing

    We have a 3rd party application running on our oracle(10.2.0.4) database running on 64bit solaris(sparc) machine.
    Since few days my undo started going up. I increased the size from 2g to 5g. Still it is at more then 90%levels.
    I ran this query to see which session is using maximum undo
    SELECT a.sid, b.name, a.value
    FROM v$sesstat a, v$statname b
    WHERE a.statistic# = b.statistic#
    AND a.statistic# = 176
    ORDER BY a.value DESC
    From this i found the session which is using max undo.
    When i query this sid from v$session i see this is inactive
    my undo retention is set to 9000 and undo management is auto
    how can i check if i have expired undo blocks that are not being used

    >
    Since few days my undo started going up. I increased the size from 2g to 5g. Still it is at more then 90%levels.
    I ran this query to see which session is using maximum undo
    SELECT a.sid, b.name, a.value
    FROM v$sesstat a, v$statname b
    WHERE a.statistic# = b.statistic#
    AND a.statistic# = 176
    ORDER BY a.value DESC
    From this i found the session which is using max undo.
    When i query this sid from v$session i see this is inactive
    my undo retention is set to 9000 and undo management is auto
    >
    With an UNDO_RETENTION of 2.5 hours set, I am not surprised that you use up to (or even more than) 5g space in the UNDO tablespace! I would even call that moderate.
    What is your concern? If you don't have the space for your UNDO tablespace, lower UNDO_RETENTION accordingly. Notice that UNDO_RETENTION is the wish to preserve before images for that long time even if their transaction did already commit. Why have you set it to that (relatively high) value of 2.5 hours?
    Kind regards
    Uwe
    http://uhesse.wordpress.com

  • Getting index of a string array based on user selection in a comboBox

    I'm not really sure how to phrase my questions, but here goes.
    I have created a string array that holds the values of a ComboBox. Based on which selection the user makes in the comboBox, I need the program to then perform particular calcualtions (based on their selection). I have tried using an ItemListener, but that doesn't seem to work. I've also tried using the ActionListener connected to the ComboBox, again...without results. I'm not sure what I'm looking for exactly, but I know what I want it to do, I'm just not finding the right way to do it. Can anyone help me figure this out?

    Here is my entire code. I'm completely confused at where to put the ActionListener or how to make it do what I want. Right now I just have it set up to display a simple message in the displayArea, just so that I could see if it was working. I think once I figure out how to get the right index from the ComboBox array, then I'll be able to add the code I need to perform the calcualtions...it's just getting to that step that's not going so well! Any help is appreciated.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.text.DecimalFormat;
    import java.lang.String;
    public class MortCalcSR5 extends JFrame implements ActionListener
         int term = 0;
         double principal = 0;
         double rate = 0;
         double monthlyPyment = 0;
         double interest = 0;
         String[] loanChoices = {" ", "7 years @ 5.35%", "15 years @ 5.5%", "30 years @ 5.75%"};
         //create panel for input
         JPanel inputPanel = new JPanel();
              JLabel mortAmtLabel = new JLabel("Mortgage Amount $");
              JTextField mortAmtField = new JTextField(15);
              JLabel loanSelectionLabel = new JLabel("Loan Selection");
              JComboBox loanSelection = new JComboBox(loanChoices);
              JTextField loanSelected = new JTextField(15);
         //create button panel
         JPanel buttonPanel = new JPanel();
              JButton calcButton = new JButton("Calculate");
              JButton clearButton = new JButton("Clear");
              JButton exitButton = new JButton("Exit");
         //create panel for payment information
         JPanel paymentPanel = new JPanel();
              JLabel paymentLabel = new JLabel("Monthly Payment $");
              JTextField paymentField = new JTextField(15);
         //create panel for text box information
         JPanel textPanel = new JPanel();
              JLabel numPaymentLabel = new JLabel("Payment #");
              JLabel balLabel = new JLabel("Balance");
              JLabel ytdPrincLabel = new JLabel("Principal");
              JLabel ytdIntLabel = new JLabel("Interest");
         //create payment for display area
         JPanel displayPanel = new JPanel(new FlowLayout());
              JTextArea displayArea = new JTextArea(10,30);
              JScrollPane scroll = new JScrollPane(displayArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
         public MortCalcSR5()
              //set size of GUI display
              setSize(400,450);
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              Container pane = getContentPane();
              JScrollPane scroll = new JScrollPane (displayArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
              FlowLayout layout = new FlowLayout(FlowLayout.LEFT);
              pane.setLayout(layout);
              //add components to the inputPanel
              GridLayout layout2 = new GridLayout(4,1);
              inputPanel.setLayout(layout2);
              inputPanel.add(mortAmtLabel);
              inputPanel.add(mortAmtField);
              mortAmtField.setText(" ");
              inputPanel.add(loanSelectionLabel);
              inputPanel.add(loanSelection);
              loanSelection.addActionListener(this);
              pane.add(inputPanel);
              //add components to buttonPanel
              FlowLayout layout3 = new FlowLayout(FlowLayout.CENTER, 10, 10);
              buttonPanel.setLayout(layout3);
              buttonPanel.add(calcButton);
              buttonPanel.add(clearButton);
              buttonPanel.add(exitButton);
              pane.add(buttonPanel);
              //add listeners to buttons
              calcButton.addActionListener(this);
              clearButton.addActionListener(this);
              exitButton.addActionListener(this);
              //add components to outputPanel
              FlowLayout layout4 = new FlowLayout(FlowLayout.LEFT, 10,10);
              paymentPanel.setLayout(layout4);
              paymentPanel.add(paymentLabel);
              paymentPanel.add(paymentField);
              pane.add(paymentPanel);
              //add components to textPanel
              FlowLayout layout5 = new FlowLayout(FlowLayout.LEFT, 10,10);
              textPanel.setLayout(layout5);
              textPanel.add(balLabel);
              textPanel.add(ytdPrincLabel);
              textPanel.add(ytdIntLabel);
              pane.add(textPanel);
              //add components to displayPanel
              FlowLayout layout6 = new FlowLayout(FlowLayout.CENTER,10,10);
              displayPanel.setLayout(layout6);
              displayPanel.add(scroll);
              pane.add(displayPanel);
              setContentPane(pane);
              setVisible(true);
         public void actionPerformed(ActionEvent event)
              String fs = (String)loanSelection.getSelectedItem();
              if (fs.equals("7 years @ 5.35%"))          {
                   displayArea.setText("yay");
              else
                   displayArea.setText("blah");
              JButton command = (JButton)event.getSource();
              if(command==calcButton)  //calculate button clicked - run payment event
                   Payment();
              if(command==clearButton) //clear button clicked - clear all fields
                   mortAmtField.setText(null);
                   paymentField.setText(null);
                   displayArea.setText(null);
                   loanSelected.setText(null);  //hidden text field still needs to be cleared
                   //loanChoices = null;
              if(command==exitButton)  //exit button clicked - exit program
                   System.exit(0);
         public void Payment()
              //perform the calculations
    //          int mortAmt = Integer.parseInt(mortAmtField.getText());
         //     double loanSelect = Double.parseDouble((String)loanSelected.getText());
              displayArea.append("Calcualations performed!");
         public static void main(String[] args)
              new MortCalcSR5();
    /*/calculations
         int mortAmt = Integer.parseInt(mortAmtField.getText());  //get text user entered in mortAmt field - parse it from a string to integer
         int loanTerm = Integer.parseInt(loanTermField.getText());  //get text user entered in loanTerm field - parse it from a string to integer
         double interestRate = Double.parseDouble(interestRateField.getText());  //get text user entered in interestRate field - parse it from a string to double
         int moTerm = (loanTerm*12);  //calculate monthly loan term
         double moInterest = ((interestRate/100)/12);  //calculate monthly interest rate
         double payment = mortAmt*(moInterest/(1-Math.pow(1/(1+moInterest), moTerm)));  //calculate monthly payment amount
         valid = true;  //number format is accepted
         paymentField.setText(Double.toString(payment));  //display output
    */

  • Problem drawing circles and ellipses

    I want my program to draw an ellipse and circle. As we all know, theyre different.
    I used the drawOval() method in java.awt.Graphics to do this.
    Here is the crucial lines of the code:
    public void paintComponent(Graphics g)
              super.paintComponent(g);
              if(currentShape!=null)
                   if (currentShape.shapeType()==RECTANGLE)
                        g.drawRect(currentShape.getStartingX(),currentShape.getStartingY(),currentShape.getLength(),currentShape.getWidth());
                   else if (currentShape.shapeType()==ELLIPSE)
                        g.drawOval(currentShape.getStartingX(),currentShape.getStartingY(),currentShape.getLength(),currentShape.getWidth());
                   else if (currentShape.shapeType()==CIRCLE)
                        g.drawOval(currentShape.getStartingX(),currentShape.getStartingY(),currentShape.getLength(),currentShape.getLength());
              if (shapeCount>0)
                   for (int c=0;c<shapeCount;c++)
                        if (myShapes[c].shapeType()==RECTANGLE)
                             g.drawRect(myShapes[c].getStartingX(),myShapes[c].getStartingY(),myShapes[c].getLength(),myShapes[c].getWidth());     
                        else if (myShapes[c].shapeType()==ELLIPSE)
                             g.drawOval(myShapes[c].getStartingX(),myShapes[c].getStartingY(),myShapes[c].getLength(),myShapes[c].getWidth());     
                        else if (myShapes[c].shapeType()==CIRCLE)
                             g.drawOval(myShapes[c].getStartingX(),myShapes[c].getStartingY(),myShapes[c].getLength(),myShapes[c].getLength());     
         }I am bemused because, it doesn't work. When I try to draw the circle, it doesn't draw a circle but an ellipse but as you can see I set the length and height parameters of the cricle to the length!
    here are my other codes, see for yourself.
    import javax.swing.JFrame;
    import javax.swing.JButton;
    import javax.swing.JComboBox;
    import javax.swing.JCheckBox;
    import javax.swing.JPanel;
    import javax.swing.JLabel;
    import java.awt.BorderLayout;
    import java.awt.FlowLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    public class DrawFrame extends JFrame
         JButton undo, clear;
         JComboBox colors, shapes;
         JCheckBox isFilled;
         JPanel top,bottom;
         JLabel statusBar;
         DrawPanel canvas;
         String shapeList[] = {"Rectangle","Ellipse","Circle","Triangle"};
         String colorList[] = {"Red","Orange","Yellow","Green","Blue","Violet"};
         public DrawFrame()
              super("Java Drawings");
              setLayout(new BorderLayout());
              top = new JPanel();
              top.setLayout(new FlowLayout());
              undo = new JButton("Undo");
              clear = new JButton("Clear");
              shapes = new JComboBox(shapeList);
              colors = new JComboBox(colorList);
              isFilled = new JCheckBox("Filled",true);     
              top.add(undo);
              top.add(clear);
              top.add(shapes);
              top.add(colors);
              top.add(isFilled);
              add(top,BorderLayout.NORTH);
              statusBar = new JLabel("Program Started");
              canvas = new DrawPanel(statusBar);
              add(canvas,BorderLayout.CENTER);
              bottom = new JPanel();
              statusBar = canvas.getStatusLabel();
              bottom.setLayout(new FlowLayout(FlowLayout.LEFT));
              bottom.add(statusBar);
              add(bottom,BorderLayout.SOUTH);
              //default settings
              canvas.setShapeType(0);
              eventHandler handler = new eventHandler();
              shapes.addActionListener(handler);
         private class eventHandler implements ActionListener
              public void actionPerformed(ActionEvent e)
                   if(e.getSource()==shapes)
                        canvas.setShapeType(shapes.getSelectedIndex());
                        //System.out.println("Selected Index"+shapes.getSelectedIndex());
         public static void main(String args[])
              DrawFrame app = new DrawFrame();
              app.setSize(500,300);
              app.setVisible(true);
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import java.awt.Graphics;
    import java.awt.Color;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseMotionListener;
    import java.awt.event.MouseListener;
    public class DrawPanel extends JPanel
         private int shapeCount;
         private int shapeType;
         private int currentColor;
         private boolean filledShape;
         public JLabel statusLabel;
         private Shape myShapes[]=new Shape[100];
         private Shape currentShape;
         private final int RECTANGLE=0,ELLIPSE=1,CIRCLE=2,TRIANGLE=3;
         private boolean draw=false;
         public DrawPanel(JLabel statusBar)
              shapeCount=0;
              statusLabel = statusBar;
              mausHandler mouseEventsHandler = new mausHandler();
              addMouseListener(mouseEventsHandler);
              addMouseMotionListener(mouseEventsHandler);
              setBackground(Color.white);
              setVisible(true);
         public void setShapeType(int shapeType)
              this.shapeType=shapeType;
         public void setCurrentColor()
         public void isFilledShape()
         public void clearLastShape()
              shapeCount--;
              repaint();
         public void clearDrawing()
              shapeCount=0;
              repaint();
         public JLabel getStatusLabel()
              return statusLabel;
         public void paintComponent(Graphics g)
              super.paintComponent(g);
              if(currentShape!=null)
                   if (currentShape.shapeType()==RECTANGLE)
                        g.drawRect(currentShape.getStartingX(),currentShape.getStartingY(),currentShape.getLength(),currentShape.getWidth());
                   else if (currentShape.shapeType()==ELLIPSE)
                        g.drawOval(currentShape.getStartingX(),currentShape.getStartingY(),currentShape.getLength(),currentShape.getWidth());
                   else if (currentShape.shapeType()==CIRCLE)
                        g.drawOval(currentShape.getStartingX(),currentShape.getStartingY(),currentShape.getLength(),currentShape.getLength());
              if (shapeCount>0)
                   for (int c=0;c<shapeCount;c++)
                        if (myShapes[c].shapeType()==RECTANGLE)
                             g.drawRect(myShapes[c].getStartingX(),myShapes[c].getStartingY(),myShapes[c].getLength(),myShapes[c].getWidth());     
                        else if (myShapes[c].shapeType()==ELLIPSE)
                             g.drawOval(myShapes[c].getStartingX(),myShapes[c].getStartingY(),myShapes[c].getLength(),myShapes[c].getWidth());     
                        else if (myShapes[c].shapeType()==CIRCLE)
                             g.drawOval(myShapes[c].getStartingX(),myShapes[c].getStartingY(),myShapes[c].getLength(),myShapes[c].getLength());     
         private class mausHandler implements MouseListener, MouseMotionListener
              public void mouseClicked(MouseEvent e)
              public void mouseEntered(MouseEvent e)
              public void mouseExited(MouseEvent e)
              public void mousePressed(MouseEvent e)
                   statusLabel.setText("Pressed at ("+e.getX()+","+e.getY()+")");
                   if (shapeType==RECTANGLE)
                        currentShape = new Square(e.getX(),e.getY());     
                   else if (shapeType==ELLIPSE)
                        currentShape = new Circle(e.getX(),e.getY());     
                        System.out.println("Oval");
                   else if (shapeType==CIRCLE)
                        currentShape = new Circle(e.getX(),e.getY());     
                        System.out.println("Circle");
              public void mouseDragged(MouseEvent e)
                   statusLabel.setText("Dragged at ("+e.getX()+","+e.getY()+")");
                   currentShape.setDimensions(e.getX() - currentShape.getStartingX(),e.getY() - currentShape.getStartingY());
                   repaint();
              public void mouseReleased(MouseEvent e)
                   statusLabel.setText("Released at ("+e.getX()+","+e.getY()+")");
                   currentShape.setDimensions(e.getX() - currentShape.getStartingX(),e.getY() - currentShape.getStartingY());
                   myShapes[shapeCount] = currentShape;
                   shapeCount++;
                   currentShape=null;
                   repaint();
              public void mouseMoved(MouseEvent e)
                   statusLabel.setText("("+e.getX()+","+e.getY()+")");
    }

    Here are my other classes btw:
    import java.awt.Graphics;
    public interface Shape
         public abstract double getArea();
         public abstract double getVolume();
         public abstract String getShape();
         public abstract int getLength();
         public abstract int getWidth();
         public abstract double getRadius();
         public abstract double getHeight();
         public abstract void setDimensions(int length, int width);
         public abstract String toString();
         public abstract int shapeType();
         public abstract int getStartingX();
         public abstract int getStartingY();
    import java.awt.Graphics;
    public class Square extends TwoDimShape
         public Square(int x,int y)
              super("Square",x,y);
         public void setDimensions(int length,int width)
              super.length = length;
              super.width = width;
         public double getArea()
              return super.getArea() + (super.getLength()*super.getWidth());
         public String toString()
              return String.format(super.toString()+"\nOrigin: ("+getStartingX()+","+getStartingY()+")"+"\nArea: "+getArea()+"\nLength: "+getLength()+"\nWidth: "+getWidth());
         public int shapeType()
              return 0;
    import java.awt.Graphics;
    public class TwoDimShape implements Shape
         protected String shape;
         protected int length;
         protected int width;
         protected double radius;
         protected int x;
         protected int y;
         public TwoDimShape(String shape, int x, int y)
              this.shape = shape;
              this.x=x;
              this.y=y;          
         public TwoDimShape(String shape, double radius)
              this.shape=shape;
              this.radius=radius;
         public void setDimensions(int length, int width)
              this.length=length;
              this.width=width;
         public int getStartingX()
              return x;
         public int getStartingY()
              return y;
         public String getShape()
              return shape;
         public int getLength()
              return length;
         public int getWidth()
              return width;
         public double getRadius()
              return radius;
         public double getHeight()
              return 0.0;
         public double getArea()
              return 0.0;
         public double getVolume()
              return 0.0;
         public String toString()
              return String.format(shape +" ,2D shape with Area: ");
         public int shapeType()
              return -1;
    import java.awt.Graphics;
    public class Circle extends TwoDimShape
         public Circle(int x,int y)
              super("Square",x,y);
         public void setDimensions(int length,int width)
              super.length = length;
              super.width = width;
         public double getArea()
              return super.getArea() + (super.getLength()/2)*(super.getWidth()/2)*Math.PI;
         public String toString()
              return String.format(super.toString()+"\nOrigin: ("+getStartingX()+","+getStartingY()+")"+"\nArea: "+getArea()+"\nLength: "+getLength()+"\nWidth: "+getWidth());
         public int shapeType()
              return 1;
    }

  • VBA 4198 error command fail with ActiveDocument.Save

    I am getting 4198 error run time error with on the ActiveDocument.Save line below
        If optSave.Value Then                                   '  
    If save & close option selected...
            'Change the status of the Normal template to unchanged. If changes were
            '   made to the Normal template, the changes are not saved when you exit Word.
            NormalTemplate.Saved = True
            ' Prevent ActiveDocument from reporting that it has changed
            ActiveDocument.AttachedTemplate.Saved = True
            If frmAssemble.optCtlA_F9 Then
                ' Prevent Document too big to spell check error by setting current spell check to true.
                ActiveDocument.SpellingChecked = True
                ActiveDocument.ShowSpellingErrors = False
                ' Perform Ctrl A followed by F9 equivalent to update all the document fields
                Selection.WholeStory        ' Ctrl-A = Select the entire document
                Selection.Fields.Update     ' F9
                Selection.EscapeKey         ' Undo Select all
                Selection.Collapse Direction:=wdCollapseStart
            End If
            If ActiveDocument.Revisions.Count >= 1 Then
                'This should not happen
                MsgBox Prompt:="Accepting " & ActiveDocument.Revisions.Count & " in " & ActiveDocument.Name & ".", _
                    Buttons:=vbInformation, Title:="Saving Finished Assembly"
                ActiveDocument.AcceptAllRevisions
            End If
            ' Prevent ActiveDocument from reporting that it has changed
            ActiveDocument.AttachedTemplate.Saved = True
            ' Trap final save errors
            On Error GoTo FinalSaveError
            ' Save the new document
            ActiveDocument.Save
            ' Turn off Trapping
            On Error GoTo 0
            DeltaStopTime = Timer
            DisplayStatus "Save Time:  " & Elapsed(DeltaStartTime, DeltaStopTime)
            'Reset Delta Start Timer
            DeltaStartTime = DeltaStopTime
        End If
    The document contains embedded word documents and excel documents and works fine until enough other sections are added so that the created file is about 5 Meg.  The final document should be 10 meg.   If I remove the embedded documents it works. 
    If I trap  the 4198 code and use resume next the first save turns to a save as.   On exiting word the program will request to save multiple times.    My guess is one for every object embedded (11).   What is wrong?

    Hi RN
    Could you please provide the error message you're getting? There's no convenient (public) source for error numbers and messages to look it up...
    If you try to save this kind of document as an end-user do you also encounter problems? Does doing that provide any additional information about what's bothering Word?
    Which version of Word is involved with the problem?
    Could you please be specific about what you mean by "other sections are added": What (type of content) is being added?
    Cindy Meister, VSTO/Word MVP,
    my blog

  • HELP! Need Pricing Report

    I need a report with the following information:
    Material, Material description, marked for deletion flag, List Price, Standard Price (cost)
    Is this something that available in SAP or can I do this report using SQ01, if yes, what tables can I use?
    Please help

    You can create your own pricing reports with the transaction "V/LA".
    The path is IMG-Sales and Distribution-Basic functions-Pricing-Maintain Pricing reports.
    <b>Step 1</b>
    Enter a short text name, consisting of two characters, the first of which must be a letter, and the title of a pricing report that you would like to create. On the next data screen you will see all key fields used in conditions, listed in alphabetical order. Select all key fields that should be taken into consideration in the pricing report.
    <b>Step 2:</b>
    If you choose “Edit -> continue with AND”, all condition tables are evaluated, that contain at least one of the selected key fields. If you choose “Edit -> continue with AND”, all condition tables are evaluated, that contain at least one of the selected key fields. In the next dialog box, mark all condition tables that are to be evaluated.
    <b>Step 3:</b>
    Choose “Continue to list structure” to define the screen structure for the pricing report. Make sure that on the next screen all key fields from the selected tables appear. Fields, that are not used as selection criteria when displaying the list later, can be removed by undoing selection in the “Selection” column. Fields can be marked as obligatory fields on the selection screen. The structure of the pricing reports means that information can be placed in different places in the list. The layout contains the following elements:
    Page Header
    Group Header
    Item
    To execute this report, use the transaction V/LD.
    Path: Logistics-SD-Master Data-Information system-Conditions and Pricing-Pricing reports
    <b>Also, check the existing reports in V/LD like 28/15/17.</b>
    Regards,
    Gauravjit
    Reward Points if resolution is helpful.

  • There is a Problem in JPopupMenu,

    If iam using the JPopupMenu which has JTable added inside in it.
    after showing that JPopupMenu,i could not able to select JCombobox through mouse , which is also placed in my frame.
    If anyone know about this, please let me know it will help me out
    in great deal.
    thanks
    arun

    try posting some code.

Maybe you are looking for