Solved

changing an option pane

Posted on 2004-10-03
4
261 Views
Last Modified: 2010-04-17
Hi experts,
I would like to adjust the folling code:

private void print()
{
  int exit = JOptionPane.showConfirmDialog
  ( null,"Are you sure you want to print ?","Timeport . . .",JOptionPane.YES_NO_OPTION);

    f(exit==JOptionPane.YES_OPTION)
       {printPage(); }
}

I need it to include either 3 check boxes or those round ones (I believe they are called radio buttons) so that the user may choose which pages to print(please I need you to tell me also how to know if a check box has been checked)

I would also like to change the buttons from (yes and no) to (Print and Cancel)

thank you
0
Comment
Question by:Samooramad
  • 2
  • 2
4 Comments
 
LVL 3

Expert Comment

by:itbeme
ID: 12212733
How much do you know about java?
JOptionPane is flexible in only certain ways.  It is designed mostly for informational and confirmation prompts.  You'll probably want to use a JFrame.

Here's an example of a drop down list under the warningbutton that uses JOptionPane.
http://www.cs.cf.ac.uk/Dave/HCI/HCI_Handout_CALLER/node97.html
0
 

Author Comment

by:Samooramad
ID: 12216549
not much obviously...
ok can you do that with a frame.. I need a quick solution
0
 
LVL 3

Accepted Solution

by:
itbeme earned 500 total points
ID: 12223759
The example I referenced you will allow you to use a drop down list for your three items
If you want help with that let me know.


One thing I thought of - I believe with a Frame there is no easy way to keep the window on top, ( user clicks on window behind and it comes to front and your print box disappears) Not sure my java getting a little rusty

If you put this code in your class file after all brackets you can launch a jframe by calling
JFrame callitsomething = new Myjframe();



class Myjframe extends JFrame{
      
      Myjframe() {
            super("Print");
             setSize(150,150);
             setVisible(true);
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            JLabel melab = new JLabel("acksdfadsf");
            JPanel panel = new JPanel();
            JButton melab3 = new JButton("acksdfadsf");
            panel.add(melab);
            panel.add(melab3);
            this.setContentPane(panel);
            
      }
}

This tutorial should get you through rest
http://java.sun.com/docs/books/tutorial/uiswing/components/button.html
0
 

Author Comment

by:Samooramad
ID: 12224882
I really would prefer check boxes or something similar. ok, thanks for the example. will try it and see if it works out

thanks
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now