Program prints when i press CANCEL

this is the print method:
public int print(Graphics g, PageFormat pageFormat, int pageIndex) throws PrinterException
     Graphics2D  g2 = (Graphics2D) g;
     g2.setColor(Color.black);
     int fontHeight=g2.getFontMetrics().getHeight();
     int fontDesent=g2.getFontMetrics().getDescent();
     //leave room for page number
     double pageHeight = pageFormat.getImageableHeight()-fontHeight;
     double pageWidth = pageFormat.getImageableWidth();
     double tableWidth = (double) table.getColumnModel().getTotalColumnWidth();
     double scale = 1;
     if (tableWidth >= pageWidth)
          scale =  pageWidth/tableWidth;
     double headerHeightOnPage = table.getTableHeader().getHeight()*scale;
     double tableWidthOnPage = tableWidth*scale;
     double oneRowHeight = (table.getRowHeight() + table.getRowMargin())*scale;
     int numRowsOnAPage = (int)((pageHeight-headerHeightOnPage)/oneRowHeight);
     double pageHeightForTable = oneRowHeight*numRowsOnAPage;
     int totalNumPages = (int)Math.ceil(((double)table.getRowCount())/numRowsOnAPage);
     if(pageIndex>=totalNumPages)
          return NO_SUCH_PAGE;
     g2.translate(pageFormat.getImageableX(),pageFormat.getImageableY());
     g2.drawString("Page: "+(pageIndex+1),
                                           (int)pageWidth/2-35,
                                           (int)(pageHeight+fontHeight-fontDesent));//bottom center
     g2.translate(0f,headerHeightOnPage);
     g2.translate(0f,-pageIndex*pageHeightForTable);
     //If this piece of the table is smaller than the size available,
     //clip to the appropriate bounds.
     if (pageIndex + 1 == totalNumPages)
          int lastRowPrinted = numRowsOnAPage * pageIndex;
          int numRowsLeft = table.getRowCount() - lastRowPrinted;
          g2.setClip(0, (int)(pageHeightForTable * pageIndex),
                                   (int) Math.ceil(tableWidthOnPage),
                                   (int) Math.ceil(oneRowHeight * numRowsLeft));
     //else clip to the entire area available.
     else
          g2.setClip(0, (int)(pageHeightForTable*pageIndex),
                                   (int) Math.ceil(tableWidthOnPage),
                                   (int) Math.ceil(pageHeightForTable));
     g2.scale(scale,scale);
     table.paint(g2);
     g2.scale(1/scale,1/scale);
     g2.translate(0f,pageIndex*pageHeightForTable);
     g2.translate(0f, -headerHeightOnPage);
     g2.setClip(0, 0,(int) Math.ceil(tableWidthOnPage),(int)Math.ceil(headerHeightOnPage));
     g2.scale(scale,scale);
     table.getTableHeader().paint(g2);//paint header at top
     return Printable.PAGE_EXISTS;
}this is the print button:
JButton print = new JButton("Print Results");
print.addActionListener(
     new ActionListener()
          public void actionPerformed(ActionEvent evt)
               PrinterJob pj = PrinterJob.getPrinterJob();
               pj.setPrintable(ScienceOlympiadProgram.this);
               pj.printDialog();
               try
                    pj.print();
               catch (Exception PrintException)
);everything works properly. when i run the program, the print button does its job, prints the data almost the way i want it (that will be fixed later) but the only problem is when i press Cancel on the dialog box, the program prints anyway. seems like an easy fix, but I'm mentally wiped. any suggestions are greatly appreciated!
thank you,
Hristo

That's because you never test the value returned by printDialog().
{color:#0000ff}http://java.sun.com/javase/6/docs/api/java/awt/print/PrinterJob.html#printDialog(){color}
Returns:
    true if the user does not cancel the dialog; false otherwise.
Also, an empty catch block is not advisable, in case of an Exception you won't know what went wrong.if (pj.printDialog ()) {
   try {
      pj.print ();
   } catch (PrinterException ex) {
       ex.printStackTrace ();
}db

Similar Messages

  • Ive just done a restore on my iphone 3gs ios 5.0.1 and when it asks me to put a in my itunes password the email adress in isn't mine and when i press cancel it pops up again with a different one this happened about 5 times n then it went away anyone no y?

    Ive just done a restore on my iphone 3gs ios 5.0.1 and when it asks me to put a in my itunes password the email adress in isn't mine and when i press cancel it pops up again with a different email does anyone know why?
    some i get are
    sha**anhall@sha**anhall.com
    m**t_uniQue.apple.com
    s**[email protected]
    put astricks's there because i dont wanna get in toruble :/

    And I don't have any cracked apps

  • When i open ibook, the iTunes store asks for my password. it goes away when i press cancel or when i put in my password. why is this happening?

    When I open IBook, the ITunes store asks for my password.  It goes away when I press cancel or enter my password.  It seems unnecessary to me.  Why is it doing this?  I already paid for the book. 

    If you are trying to update information for your apple id then go to appleid.apple.com and click on manage your apple ID... you'll probably have to enter your old email address/password

  • Which trigger fires when i press cancel query button in oracle d2k forms.

    hi all,
    i have simply press then enter query but didn't enter anything in form and then press the cancel query. so i just want to know that what trigger will fire when i press the cancel query button in d2k form.
    Regards,
    kam.

    Why not ask into Forms<br>
    <br>
    Nicolas.

  • How do I stop the error message coming up when I press cancel on file dialog

    I am using the file dialog and if I press cancel an error box pops up with error 43 operation cancelld by user. Can we get rid of this, as it is bloody enoying, any ideas
    cheers

    Contrary to the rest of the nice folk here, I say do NOT turn off automatic error handling!
    You will regret it if a day comes where you forgot to handle an error properly and you have a hard time determining its source.
    If you truly want to ignore the error in this mode, you can wire the error out terminal into anything (even a wall). Once an error out terminal is wired, the error will not pop up automatically. This does not mean you should use this as a standard course of action. You should normally handle your errors properly.
    Try to take over the world!

  • CanonPIXMA3500 will not print when I press button. I turn it on early before I start using pc. Why ?

    Why can't I get the printer to print when I pres the "print" button. I also try clicking ctrl and P but nothing happens.
    I have a canon PIXMA 3500 series wireless printer I set up according to instructions. What am I doing wrong?? 

    Hi, StarFFire!
    So that the Community can help you better, we will need to know exactly which operating system is running on your computer and which applications you're trying to print from. That, and any other details you'd like to give will help the Community better understand your issue!
    If this is a time-sensitive matter, our US-based technical support team is standing by, ready to help 24/7 via Email at http://bit.ly/EmailCanon or by phone at 1-800-OK-CANON (1-800-652-2666) weekdays between 10 AM and 10 PM ET (7 AM to 7 PM PT).
    Thanks and have a great day!

  • How To Make A Program Which When I Press A Button The Number Goes Up One?

    I have already made this:
    import java.awt.Container;
    import java.awt.LayoutManager;
    import java.awt.FlowLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JTextField;
    import javax.swing.JButton;
    public class Lab04 extends JFrame
    private Container content;
    private LayoutManager layout;
    private JLabel number, division, modulus, space;
    private JTextField text;
    private String string;
    private ActionListener listener;
    private char char1;
    private int x, Add1, Add2;
    private JButton bAdd;
    public Lab04()
    formatWindow();
    listener = new Handler();
    bAdd = createAndAddButton("+1");
    number = createAndAddLabel("Current Number: 0");
    division = createAndAddLabel(" n DIV 4 = 0");
    space = createAndAddLabel(" ");
    modulus = createAndAddLabel(" n MOD 4 = 0");
    public void formatWindow()
    content = getContentPane();
    layout = new FlowLayout();
    content.setLayout(layout);
    private JLabel createAndAddLabel(String s)
    JLabel temp = new JLabel();
    temp.setText(s);
    content.add(temp);
    return temp;
    private JTextField createAndAddTextField(int x)
    JTextField temp = new JTextField(x);
    temp.addActionListener(listener);
    content.add(temp);
    return temp;
    private JButton createAndAddButton(String s)
    JButton temp = new JButton();
    temp.setText(s);
    temp.addActionListener(listener);
    content.add(temp);
    return temp;
    private void process()
    int x = 0;
    Add1 = x +1;
    private void output()
    number.setText("Current Number: "+x+1);
    private class Handler implements ActionListener
    public void actionPerformed(ActionEvent e)
    process();
    output();
    public static void main(String[] args)
    //create graphics window
    Lab04 window = new Lab04();
    //configure graphics window
    window.setSize(200, 150);
    window.setLocation(300, 175);
    window.setTitle("Unit 3 Lab03: Filling Out Forms");
    window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    //display graphics window
    window.setVisible(true);
    And all it does is it gives me the number 01, what should I do?

    public void process{
    int x = 0;
    Add1 = x +1;
    }just what is this supposed to do? every time you call it, it create a primitive x with value 0, and then makes Add1 equal to x+1. that will be 1 no matter how many times you call it.

  • How to stay back on same section of a report after pressing cancel button

    Hi,
    How we can stay back on a same section of a report page when I press Cancel button or Apply Changes button from linked Data Entry Form. For instance if I have a 200 rows in a report and I scroll down to 80th row and press Edit button when called a data entry form. Now when I press Cancel it again re-load the report from the start of the page.
    Any idea!
    Thanks
    Sabahat

    Hi Sajid,
    Thanks for reply.
    I have used RETURN statement like below.
    SUBMIT RFWT0010 WITH vendor       = 'X'
                     WITH i_lifnr  IN i_lifnr
                     WITH i_bukrs  IN i_kunnr
                     WITH test         = 'X'
                      AND RETURN.
    The output of RFWT0010 is displayed. but on pressing "back" button on toolbar, the flow is coming back  from RFWT0010 to calling report. I want that On pressing ENTER button of keyboard. The flow should come back to calling report.
    Regards,
    Ratnesh

  • Adding a bookmark does not save the bookmark if you press cancel

    When i click
    bookmarks -> bookmark this page
    It comes up with a popup saying "Page Bookmarked". Naturally, I hardly ever want to change the name of my bookmarked items so I click cancel. My bookmark is gone. Either it is getting deleted when i press cancel to the annoying popup that comes up, or its not getting saved in the first place.
    I consider this a HCI bug. If you want to argue that this is the correct functionality that you would expect, I must disagree. Bookmarking has always been a single click procedure and I'm not sure why pressing "cancel" would mean the bookmark is not stored. I have lost countless bookmarks from pages that I have thought were bookmarked but then when I tried to access them the next day, they were gone.

    Hi Cor-el. Thanks for the tip. I agree with everything else you have said. It is good to have the functionality for accidental bookmarking.
    However, my quarm is with the text "Page Bookmarked". Essentially what you have said means that it is actually a lie. It hasnt been bookmarked at all until I press confirm. Perhaps you should change the text that pops up since it is quite misleading. Perhaps "Bookmark Page" or "Page Bookmark" would suit it better. The extra "ed" means that it's actually referring to the verb and not the noun which is why it confuses me.
    I know it is a small thing, but it has annoyed me enough times to be bothered to sign up to these forums and ask the question.
    Thanks

  • Error 43 occured by pressing cancel

    When I use the cancel button on one of the vi's which can write or read data I get an error 43 (is also written in the help file). What can I do to make sure I will not get this messagebox with the error when I press cancel.
    Thank you for you help.

    In that case, a workaround would be to modify the built-in read/write VIs that you are using. Double click on them to open them up, and look for the Error Handler VI somewhere near the end of the dataflow. You can either remove this, which would result in no error reporting at all, or unbundle the error cluster and feed the "code" value into the selector for a case statement. Have a case for value 43 which outputs a "no error" (eg. create a standard Error In control, right-click on it on the block diagram and choose "Change to Constant") and make the other (default) case simply a feed-through of the original error cluster wire.
    Make sure you save the modified VIs in a different location, otherwise you'll overwrite the ones that came with LabVIEW

  • Why do I get the following exception when I press the cancel buuton?

    My code is not complete as I am stubbing my code. Can someone tell me why i get the following exception
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
            at Phonebook.createNew(Phonebook.java:244)
            at Phonebook.actionPerformed(Phonebook.java:222)
            at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:19
    95)
            at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.jav
    a:2318)
            at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel
    .java:387)
            at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242
            at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonL
    istener.java:236)
            at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:2
    72)
            at java.awt.Component.processMouseEvent(Component.java:6038)
            at javax.swing.JComponent.processMouseEvent(JComponent.java:3265)
            at java.awt.Component.processEvent(Component.java:5803)
            at java.awt.Container.processEvent(Container.java:2058)
            at java.awt.Component.dispatchEventImpl(Component.java:4410)
            at java.awt.Container.dispatchEventImpl(Container.java:2116)
            at java.awt.Component.dispatchEvent(Component.java:4240)
            at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322
            at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986)
            at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
            at java.awt.Container.dispatchEventImpl(Container.java:2102)
            at java.awt.Window.dispatchEventImpl(Window.java:2429)
            at java.awt.Component.dispatchEvent(Component.java:4240)
            at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
            at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThre
    ad.java:273)
            at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.
    java:183)
            at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
    ad.java:173)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
            at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)in the following code whenever I press the cancel button in the part of code that tests fro when a user clicks the create button.
         Filename:     ContactsListInterface.java
         Date:           16 March 2008
         Programmer:     Yucca Nel
         Purpose:     Provides a GUI for entering names and contact numbers into a telephone directory.
                        Also allows options for searching for a specific name and deleting of data from the record
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.text.*;
    import java.io.*;
    import java.util.*;
    import java.text.*;
    public class Phonebook extends JFrame implements ActionListener
    { //start of class
         // construct fields, buttons, labels,text boxes, ArrayLists etc
         JTextPane displayPane = new JTextPane();
         JLabel listOfContacts = new JLabel("List Of Contacts");               // creates a label for the scrollpane
         JButton createButton = new JButton("Create");
         JButton searchButton = new JButton("Search");
         JButton modifyButton = new JButton("Modify");
         JButton deleteButton = new JButton("Delete");
         ArrayList fNameList = new ArrayList();
         ArrayList sNameList = new ArrayList();
         ArrayList hList = new ArrayList();
         ArrayList wList = new ArrayList();
         ArrayList cList = new ArrayList();
         public String name, surname, home, work, cell;
         // create an instance of the ContactsListInterface
         public Phonebook()
         { // start of cli()
              super("Phonebook Interface");
         } // end of cli()
         public JMenuBar createMenuBar()
         { // start of the createMenuBar()
              // construct and populate a menu bar
              JMenuBar mnuBar = new JMenuBar();                    // creates a menu bar
              setJMenuBar(mnuBar);
              JMenu mnuFile = new JMenu("File",true);               // creates a file menu in the menu bar which is visible
                   mnuFile.setMnemonic(KeyEvent.VK_F);
                   mnuFile.setDisplayedMnemonicIndex(0);
                   mnuFile.setToolTipText("File Options");
                   mnuBar.add(mnuFile);
              JMenuItem mnuFileExit = new JMenuItem("Save And Exit");     // creates an exit option in the file menu
                   mnuFileExit.setMnemonic(KeyEvent.VK_X);
                   mnuFileExit.setDisplayedMnemonicIndex(1);
                   mnuFileExit.setToolTipText("Close Application");
                   mnuFile.add(mnuFileExit);
                   mnuFileExit.setActionCommand("Exit");
                   mnuFileExit.addActionListener(this);
              JMenu mnuEdit = new JMenu("Edit",true);               // creates a menu for editing options
                   mnuEdit.setMnemonic(KeyEvent.VK_E);
                   mnuEdit.setDisplayedMnemonicIndex(0);
                   mnuEdit.setToolTipText("Edit Options");
                   mnuBar.add(mnuEdit);
              JMenu mnuEditSort = new JMenu("Sort",true);          // creates an option for sorting entries
                   mnuEditSort.setMnemonic(KeyEvent.VK_S);
                   mnuEditSort.setDisplayedMnemonicIndex(0);
                   mnuEdit.add(mnuEditSort);
              JMenuItem mnuEditSortByName = new JMenuItem("Sort By Name");          // to sort entries by name
                   mnuEditSortByName.setMnemonic(KeyEvent.VK_N);
                   mnuEditSortByName.setDisplayedMnemonicIndex(8);
                   mnuEditSortByName.setToolTipText("Sort entries by first name");
                   mnuEditSortByName.setActionCommand("Name");
                   mnuEditSortByName.addActionListener(this);
                   mnuEditSort.add(mnuEditSortByName);
              JMenuItem mnuEditSortBySurname = new JMenuItem("Sort By Surname");     // to sort entries by surname
                   mnuEditSortBySurname.setMnemonic(KeyEvent.VK_R);
                   mnuEditSortBySurname.setDisplayedMnemonicIndex(10);
                   mnuEditSortBySurname.setToolTipText("Sort entries by surname");
                   mnuEditSortBySurname.setActionCommand("Surname");
                   mnuEditSortBySurname.addActionListener(this);
                   mnuEditSort.add(mnuEditSortBySurname);
              JMenu mnuHelp = new JMenu("Help",true);                    // creates a menu for help options
                   mnuHelp.setMnemonic(KeyEvent.VK_H);
                   mnuHelp.setDisplayedMnemonicIndex(0);
                   mnuHelp.setToolTipText("Help options");
                   mnuBar.add(mnuHelp);
              JMenuItem mnuHelpHelp = new JMenuItem("Help");          // creates a help option for help topic
                   mnuHelpHelp.setMnemonic(KeyEvent.VK_P);
                   mnuHelpHelp.setDisplayedMnemonicIndex(3);
                   mnuHelpHelp.setToolTipText("Help Topic");
                   mnuHelpHelp.setActionCommand("Help");
                   mnuHelpHelp.addActionListener(this);
                   mnuHelp.add(mnuHelpHelp);
              JMenuItem mnuHelpAbout = new JMenuItem("About");     // creates a about option for info about api
                   mnuHelpAbout.setMnemonic(KeyEvent.VK_T);
                   mnuHelpAbout.setDisplayedMnemonicIndex(4);
                   mnuHelpAbout.setToolTipText("About this program");
                   mnuHelpAbout.setActionCommand("About");
                   mnuHelpAbout.addActionListener(this);
                   mnuHelp.add(mnuHelpAbout);
              return mnuBar;
         } // end of the createMenuBar()
         // create the content pane
         public Container createContentPane()
         { // start of createContentPane()
              //construct and populate panels and content pane
              JPanel labelPanel = new JPanel(); // panel is only used to put the label for the textpane in
                   labelPanel.setLayout(new FlowLayout());
                   labelPanel.add(listOfContacts);
              JPanel displayPanel = new JPanel();// panel is used to display all the contacts and thier numbers
                   setTabsAndStyles(displayPane);
                   displayPane = addTextToTextPane();
                   displayPane.setEditable(false);
              JScrollPane scrollPane = new JScrollPane(displayPane);
                   scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); // pane is scrollable vertically
                   scrollPane.setWheelScrollingEnabled(true);// pane is scrollable by use of the mouse wheel
                   scrollPane.setPreferredSize(new Dimension(400,320));
              displayPanel.add(scrollPane);
              JPanel workPanel = new JPanel();// panel is used to enter, edit and delete data
                   workPanel.setLayout(new FlowLayout());
                   workPanel.add(createButton);
                        createButton.setToolTipText("Create a new entry");
                        createButton.addActionListener(this);
                   workPanel.add(searchButton);
                        searchButton.setToolTipText("Search for an entry by name number or surname");
                        searchButton.addActionListener(this);
                   workPanel.add(modifyButton);
                        modifyButton.setToolTipText("Modify an existing entry");
                        modifyButton.addActionListener(this);
                   workPanel.add(deleteButton);
                        deleteButton.setToolTipText("Delete an existing entry");
                        deleteButton.addActionListener(this);
              labelPanel.setBackground(Color.red);
              displayPanel.setBackground(Color.red);
              workPanel.setBackground(Color.red);
              // create container and set attributes
              Container c = getContentPane();
                   c.setLayout(new BorderLayout(30,30));
                   c.add(labelPanel,BorderLayout.NORTH);
                   c.add(displayPanel,BorderLayout.CENTER);
                   c.add(workPanel,BorderLayout.SOUTH);
                   c.setBackground(Color.red);
              // add a listener for the window closing and save
              addWindowListener(
                   new WindowAdapter()
                        public void windowClosing(WindowEvent e)
                             int answer = JOptionPane.showConfirmDialog(null,"Are you sure you would like to save all changes and exit?","File submission",JOptionPane.YES_NO_OPTION);
                             if(answer == JOptionPane.YES_OPTION)
                                  System.exit(0);
              return c;
         } // end of createContentPane()
         protected void setTabsAndStyles(JTextPane displayPane)
         { // Start of setTabsAndStyles()
              // set Font style
              Style fontStyle = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE);
              Style regular = displayPane.addStyle("regular", fontStyle);
              StyleConstants.setFontFamily(fontStyle, "SansSerif");
              Style s = displayPane.addStyle("bold", regular);
              StyleConstants.setBold(s,true);
         } // End of setTabsAndStyles()
         public JTextPane addTextToTextPane()
         { // start of addTextToTextPane()
              Document doc = displayPane.getDocument();
              try
              { // start of tryblock
                   // clear previous text
                   doc.remove(0,doc.getLength());
                   // insert titles of columns
                   doc.insertString(0,"NAME\tSURNAME\tHOME NO\tWORK NO\tCELL NO\n",displayPane.getStyle("bold"));
              } // end of try block
              catch(BadLocationException ble)
              { // start of ble exception handler
                   System.err.println("Could not insert text.");
              } // end of ble exception handler
              return displayPane;
         } // end of addTextToTextPane()
         // code to process user clicks
         public void actionPerformed(ActionEvent e)
         { // start of actionPerformed()
              String arg = e.getActionCommand();
              // user clicks create button
              if(arg.equals("Create"))
                   createNew();
              if(arg.equals("Search"))
              if(arg.equals("Modify"))
              if(arg.equals("Delete"))
              if(arg.equals("Exit"))
         } // end of actionPerformed()
         // method to create a new contact
         public void createNew()
         { // start of create new contact()
              name = JOptionPane.showInputDialog(null,"Please enter the new contacts first name or press cancel to exit.");
              if(name == null)     finish();                         // if user clicks cancel
              if(name.length() <=0)
                   JOptionPane.showMessageDialog(null,"You did not enter a valid name.\nPlease make sure you enter data correctly.","Error",JOptionPane.ERROR_MESSAGE);
                   createNew();                                   // To return to the create method
              surname = JOptionPane.showInputDialog(null,"Please enter the new contacts surname or press cancel to exit.");
              if(surname == null)     finish();                         // if user clicks cancel
              if(surname.equals(""))
                   int answer = JOptionPane.showConfirmDialog(null,"You did not enter a surname.\nAre you sure you wish to leave the surname empty?","No data entered",JOptionPane.YES_NO_OPTION);   // Asks if data was valid
                   if(answer == JOptionPane.NO_OPTION)
                        surname = JOptionPane.showInputDialog(null,"Please enter the new contacts surname.");
              home = JOptionPane.showInputDialog(null,"Please enter the new contacts home number or press cancel to exit.");
              if(home == null)   finish();                    // if user clicks cancel
              work = JOptionPane.showInputDialog(null,"Please enter the new contacts work number or press cancel to exit.");
              if(work == null)     finish();                    // if user clicks cancel
              cell = JOptionPane.showInputDialog(null,"Please enter the new contacts cell number or press cancel to exit.");
              if(cell == null)     finish();                    // if user clicks cancel
         } // end of create new contact()
         // method to close applicatin
         public void finish()
         // method to search a contact
         public static void main(String[] args)
         { // start of main()
              // Set look and feel of interface
              try
              { // start of try block
                   UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
              } // end of try block
              catch(Exception e)
              { // start of catch block
                   JOptionPane.showMessageDialog(null,"There was an error in setting the look and feel of this application","Error",JOptionPane.INFORMATION_MESSAGE);
              } // end  of catch block
              Phonebook p = new Phonebook();
              p.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
              p.setJMenuBar(p.createMenuBar());
              p.setContentPane(p.createContentPane());
              p.setSize(520,500);
              p.setVisible(true);
              p.setResizable(false);
         } // end of main()
    } //end of class

    Yucca wrote:
    Line 244 is where I test for if the user actuallu entered a String at all. Is there an alternative way of writing that code?
    if(name.length() <=0)
                   JOptionPane.showMessageDialog(null,"You did not enter a valid name.\nPlease make sure you enter data correctly.","Error",JOptionPane.ERROR_MESSAGE);
                   createNew();                                   // To return to the create method
    Change:
    if(name == null)     finish();     To
    if(name == null) {
        finish();
        return;
    }

  • My safari is blocked. When I press a window comes up sasking Are you sure you want to submit this form again and it will not let me cancel or submit

    My safari is blocked. When I press a window comes up sasking Are you sure you want to submit this form again? and it will not allow me to cancel or submit

    These are your options:
    1. Restore the iPhoto library from the most recent backup that predates the issue.
              Advantages: Always works, if library damage is causing the problem and the backup is intact.
              Disadvantages: Impossible if you don't have a backup. All changes made since the backup are lost.
    2. Repair or rebuild the library. Be sure to back it up first.
              Advantages: May solve the problem with no loss of data.
              Disadvantages: May fail. May take a long time if the library is large.
    3. Scavenge the library with a third-party application called "iPhoto Library Manager," which you can find in a web search. From the application's menu bar (not the iPhoto menu bar), select Library ▹ Rebuild.
              Advantages: All images should be preserved.
              Disadvantages: All books, calendars, and slideshows will be lost.

  • How can print a report from form 6i,  when I press a button?

    hi Friends,
    How can print a report from form 6i, when I press a button?
    When i press a button from Form 6i, the report should print through printer.
    I have done it by using report parameter DESTYPE Printer but problem is that when I press a button printer dialogue box appear and then I give command Print to printer, I don’t want to show Printer dialogue box.
    I want when I press a button form Forms 6i , printer will print my report directly.
    Please send me the solution of this problem.
    Best regards,
    Shahzad

    Hi
    If You are using Client server application then to passing to Add all Print Parameter in the Host Command.
    Means Print command in unix to Host(lp.............) and Other Parameter to file name of the report to print.
    If You not Use Client Server Application the Also Passing a Host Command in Button-Pressed Event and Run.

  • The button on my Ipod Touch (the big one just below the screen) will not work when I press it. Nothing happens, when before it would wake my IPod out of sleep mode, and exit out of programs I was using. Now, no reactions. What should I do?

    The button on my Ipod Touch (the big one just below the screen) will not work when I press it. Nothing happens, when before it would wake my IPod out of sleep mode, and exit out of programs I was using (ex. ITunes or Safari to main screen) . Now, no reactions. When I press the button, it appears to be more indented then it was before. What should I do? Do I need to get it fixed or replaced, or is this a problem I can fix on my own? Whatever it is, I really need some advice. Thanks in advance.

    Try:
    fix for Home button
    iPhone Home Button Not Working or Unresponsive? Try This Fix
    - If you have iOS 5 and later you can turn on Assistive Touch it add the Home and other buttons to the iPods screen. Settings>General>Accessibility>Assistive Touch
    - If not under warranty Apple will exchange your iPod for a refurbished one for:
    Apple - Support - iPod - Repair pricing
    You can do it an an Apple store by:
    Apple Retail Store - Genius Bar
    or sent it in to Apple. See:
    Apple - Support - iPod - Service FAQ
    - There are third-party places like the following that will repair the Home button. Google for more.
    iPhone Repair, Service & Parts: iPod Touch, iPad, MacBook Pro Screens

  • Is there a reason I can't print wirelessly in Aperture? I am able to from other programs. When I try to print in Aperture, the printer tells me it's offline.

    Aperture won't print a photo wirelessly. My other programs print fine wirelessly. Anybody know why? I'm using OS X 10.6.8, Aperture 3.2.4 on an iMac with an Epson Artisan printer. When I try to print in Aperture, the printer utility tells me the printer is offline. But it isn't. I am shooting in RAW, by the way.

    I don't have much, but ... make sure you are selecting the entry for the _wireless printer_.  It's been some time since I did this — and a few OS's and Aperture versions ago — but I remember that there were multiple entries for my printer: USB, Ethernet, Wireless, and mounted to other computers on the network.

Maybe you are looking for

  • Is there a way to load music to my ipod from purchases from Realplayer, etc

    Hi. Let me start off by saying I am a computer idiot. It took me 20 minutes to figure out how/where to post my question. I apologize if I ended up posting in the wrong place and I apologize in advance for my babble. Here is my question(s). I have a I

  • Serial Number not on Sim Card tray

    Serial Number Lookup: I have an iphone 4 that will not charge, and is dead.  I know the serial number is supposed to be on the Sim Card Tray, but it is not. I can't even do an Apple Chat if I don't have my serial number.  I have all of my appleID pas

  • MapViewer base map image is not loading on OBIEE 11.1.1.6.4

    Hi Experts , We are facing issue in OBIEE 11.1.1.6.4 and OBIEE 11.1.1.6.5. The background maps are not loading. The measure is getting plotted the as per postal code but the background map is not coming up. The Issue is only with External maps. It is

  • Should I keep the battery in the machine or not?

    I've heard some people say that when you're not using your laptop's battery (ie. you're on AC) you should take it out. This supposedly stops it from "wearing out" too quickly or something in that direction. Is there any truth to this?

  • How to use UDL file in Powershell script?

    Hello Scripting Guys, I have a VBScript that works great for connecting to an Oracle DB using a .UDL file. Here is the important part of the script: Set dataconnect = CreateObject("ADODB.Connection") Path= "File name=C:\UDLs\TEST.udl" dataconnect.Con