Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 270
  • Last Modified:

changing an option pane

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
Samooramad
Asked:
Samooramad
  • 2
  • 2
1 Solution
 
itbemeCommented:
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
 
SamooramadAuthor Commented:
not much obviously...
ok can you do that with a frame.. I need a quick solution
0
 
itbemeCommented:
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
 
SamooramadAuthor Commented:
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now