Series of JDialog boxes

Hi everyone,
While installing any software we usually come across a series of dialog boxes with 'Back'
and 'Next' buttons; I have to do something similar in our project. I am generating a series of dialog boxes without any problem using JDialog in Swing. But the problem is
When the user enters some values in first dialog box and clicks 'Next' button and goes to the
second dialog box and then comes back to the first dialog box using the 'Back' button in the second dialog box, I have to display the first dialog box with those values which the user entered previously so that he need not enter them again. How to do this?
Thanks in advance. (I actually did it successfully by using event handling, but is there a better way of doing it like writing the values entered by the user into some text file and then retrieving them from the text file while displaying the dialog box?)

Here's one way. Your dialog class should implement an interface such as
public interface InputPage
public void takeState (Hashtable ht);
public void giveState (Hashtable ht);
A "director" class maintains the sequence of InputPage implementations
and listens for "next" and "back" events. When a page comes into view,
that director invokes takeState(); and when a page goes out of view, the
director invokes giveState(). In this way, the pages propogate the data
back and forth.

Similar Messages

  • Help needed: Creating web link in JDialog Box

    I'm in need of this urgently, any help would be much appreciated. I'm currently display some information in a JDialog box when an item is clicked in a JApplet.
    I need to display a weblink within the dialog box.
    Thanks anyone

    I am using JDeveloper 10.1.3.3.0. Thanks Heaps

  • How do I fill and show/hide a series of text boxes based on checkboxes?

    I have a series of checkboxes on a form (each of which requires some additional information to be entered) and a series of text boxes further down the page to house any necessary detailed information. 
    I have hidden the detail fields and coded the form so that for each of these checkboxes that is checked a row of detail text boxes appears with the checkbox title in the activiy type field, and if a checkbox is subsequently un-checked the last row of detail text boxes is hidden. 
    The problem with this is that if the user unchecks any box other than the most recently checked one the data for the option they just unchecked still shows, but the data for the last option they selected does not. 
    Does anyone have a solution that would make sure the detail fields for the boxes that are checked is displayed in the detail text boxes that are showing when a checkbox is unchecked, regardless of the order in which the boxes are checked/unchecked?
    This is what my form looks like, with the example where Cash Withdrawals is unchecked but appears in the detail and Remote Deposit Capture is checked but was hidden with the last line:
    The detail groups are named Act1.child, Act2.child, etc. where the description field (filled in the example above) is Act1.type, Act2.type, etc.
    Here is the script I'm using on the checkboxes to achieve what I'm getting now:
    var useSet = this.getField("Set").value;
    var clrSet = this.getField("Clr").value;
    var useType = useSet + ".type";
    var clrType = clrSet + ".type";
    if (this.getField("CheckboxName").value != "Off") {
        this.getField(useType).value = "Check Box Desription";
        this.getField(useSet).display = display.visible;
    else if (this.getField("CheckboxName").value == "Off") {
        this.getField(clrType).value = "";
        this.getField(clrSet).display = display.hidden;
    and here is the script for the hidden boxes that determine what sets are filled and what sets are cleared and hidden:
    Custom Calculation Script for "Set":
    var sOne = this.getField("Act1.type").value.length;
    var sTwo = this.getField("Act2.type").value.length;
    var sThr = this.getField("Act3.type").value.length;
    var sFour = this.getField("Act4.type").value.length;
    var sFive = this.getField("Act5.type").value.length;
    var sSix = this.getField("Act6.type").value.length;
    var sSev = this.getField("Act7.type").value.length;
    if (sOne == 0) {event.value = "Act1"}
    else if (sTwo == 0) {event.value = "Act2"}
    else if (sThr == 0) {event.value = "Act3"}
    else if (sFour == 0) {event.value = "Act4"}
    else if (sFive == 0) {event.value = "Act5"}
    else if (sSix == 0) {event.value = "Act6"}
    else {event.value = "Act7"}
    Custom Calculation Value for "Clr":
    var cOne = this.getField("Act1.type").value.length;
    var cTwo = this.getField("Act2.type").value.length;
    var cThr = this.getField("Act3.type").value.length;
    var cFour = this.getField("Act4.type").value.length;
    var cFive = this.getField("Act5.type").value.length;
    var cSix = this.getField("Act6.type").value.length;
    var cSev = this.getField("Act7.type").value.length;
    if (cSev != 0) {event.value = "Act7"}
    else if (cSix != 0) {event.value = "Act6"}
    else if (cFive != 0) {event.value = "Act5"}
    else if (cFour != 0) {event.value = "Act4"}
    else if (cThr != 0) {event.value = "Act3"}
    else if (cTwo != 0) {event.value = "Act2"}
    else {event.value = "Act1"}

    Hi Andi,
    Please consider the following “solution” too.
    Preliminaries
    An indicator can be considered a variable in JavaScript.
    If P is an indicator, m(P) refers to the value of the indicator.
    Data for Control
    There are four checkboxes: C0, C1, C2 and C3.
    There is an indicator for each checkbox: CP0, CP1, CP2 and CP3.
    If checkbox Ci is checked then checkbox indicator CPi has the value i+1; in other words, m(CPn) = i+1. If checkbox Ci is not checked then checkbox indicator CPi has the value 0; in other words, m(CPn) = 0.
    There are four sets of detail fields: A0, A1, A2 and A3.
    There is a detail fields indicator for each detail fields: AP0, AP1, AP2 and AP3. If detail fields Ak have the details for the checked checkbox Ci then APk has the value i+1; in other words, m(APk) = i+1. If detail fields Ak do not have any details for any of the checked or unchecked checkbox then APk has the value 0; in other words, m(APk) = 0.
    The sets of detail fields are organized in sequence. The “top” or “first” set is AP0. It is followed by AP1. Then followed by AP2. The “bottom” or “last” set is AP3.
    Consider an example with one checkbox selected. In this case m(CP2) = 3; m(AP0) = 3; m(CPi) = 0 for i=0, 1, 3; and m(APk) = 0 for k=0, 1, 3. See the following diagram too (see Figure 1).
    Events, Processes and Additional Data for Control
    Computation begins when a user event is captured by the system (such as a mouse up event in an AcroForm field like a button or a checkbox).
    Checking Process
    If a checkbox is checked (TNj), it is noted with an indicator (P0).
    Shift Process
    Given a noted checkbox, the search for a candidate set of detail fields to use for the noted checkbox begins.
    The first candidate is the bottom of the sequence. This is also the current candidate, k. Thus k=3.
    The current candidate is remembered by marking (TSk,j) the detail fields indicator (APk).
    If k=0 then the shift process ends and the current candidate is the candidate.
    If k > 0 and m(APk-1) = 0, the current candidate becomes APk-1 and step 8c is repeated.
    If k > 0 and m(APk-1) != 0, then the shift process ends and the current candidate is the candidate.
    Unchecking Process
    If m(CPi) != 0 and m(CPi) = m(APk), then the checkbox can be unchecked (TRk,i).
    Shift Process
    If m(APk)=0 and m(APk+1) > 0 then shift (TSk,m(APk+1)). At the end of this shift, m(APk) > 0 and m(APk+1) = 0. Let k = k + 1.
    If m(APk+1)>0 then repeat 9a. If m(APk+1)=0 then the shifting process ends.
    Last Events and Proceses
    Details fields can be initialized (TIk,j) and displayed (TDk,j) or cleared (TCk,j) and hidden (THk,j). These actions depend only on m(APk). However it would be a good idea to trigger these functions right after a shift process ends and on affected details fields.
    Process Diagram of One Checked Checkbox
    Figure 1 is a process model of the checkbox process with one checked checkbox.
    Figure 1 Checkbox Process Model
    Regards,
    John

  • Focus on JTextfield in JDialog box

    A JDialog box is being opened from a menu.
    There is only one JTextfield on the dialog box and 2 buttons.
    The focus is not on any of the components in the dialog box and I want it on the textfield by default.
    I have tried all the requestFocus(),requestDefaultFocus(),grabfocus() etc and none of them work.
    There is an eventListener added to the JTextfield could this be the problem.

    I am a little supprised that the focus is not given to the text field if that is the only thing on the dialog.
    You could try detecting the display of the dialog and then giving the focus to the text field. Focus will not be given to a component if the component cant be displayed at that time. My guess is that the dialog is still hidden when you are trying to set the focus and that is what is causing the problem.

  • KeyEvent calling JDialog box flickers

    On a JFrame I have a button with an ActionPerformed() method. On pressing the button a dialog box pops up on the screen as it is meant to do. This functionality is also needed to be assigned to the 'F1' key as well. In the same class I have a keyReleased() method that listens when the F1 key is pressed. For the VK_F1 KeyEvent I have put the same lines of code that I put in the ActionPerformed() method of the button. When F1 is pressed, the JDialog appears but it flickers for the first few seconds which is annoying. Does any one know why the JDialog box flickers and how to solve this.

    has any one got any sugguestions how to solve a flickering JDialog box in general???

  • Problem with JDialog box

    Hi Guys,
    I have a problem with the JDialog box. The close button (Cross mark of the box) is not displayed when I was trying to use my custom LookAndFeel and Custom theme. I am pasting the code sample here.
    import java.awt.Color;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import javax.swing.Icon;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.LookAndFeel;
    import javax.swing.SwingUtilities;
    import javax.swing.UIDefaults;
    import javax.swing.UIManager;
    import javax.swing.plaf.ColorUIResource;
    import com.jgoodies.looks.plastic.Plastic3DLookAndFeel;
    import com.jgoodies.looks.plastic.PlasticTheme;
    import com.medplexus.looks.plastic.theme.SkyGreen;
    public class TestTheDialog implements ActionListener {
    JFrame mainFrame = null;
    JButton myButton = null;
    public TestTheDialog() {
    mainFrame = new JFrame("TestTheDialog Tester");
    mainFrame.addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {System.exit(0);}
    try{
         MyLookAndFeel.setCurrentTheme(new CustomLaF());
         UIManager.setLookAndFeel(new MyLookAndFeel());
         SwingUtilities.updateComponentTreeUI(mainFrame);
         CustomDialog cd = new CustomDialog();
         cd.setDefaultLookAndFeelDecorated(true);
    catch(Exception e){
    myButton = new JButton("Test the dialog!");
    myButton.addActionListener(this);
    mainFrame.setLocationRelativeTo(null);
    mainFrame.getContentPane().add(myButton);
    mainFrame.setSize(200, 150);
    //mainFrame.pack();
    mainFrame.setVisible(true);
    public void actionPerformed(ActionEvent e) {
    if(myButton == e.getSource()) {
    System.err.println("Opening dialog.");
    CustomDialog myDialog = new CustomDialog(mainFrame, true, "Do you like Java?");
    System.err.println("After opening dialog.");
    if(myDialog.getAnswer()) {
    System.err.println("The answer stored in CustomDialog is 'true' (i.e. user clicked yes button.)");
    else {
    System.err.println("The answer stored in CustomDialog is 'false' (i.e. user clicked no button.)");
    static class CustomLaF extends PlasticTheme {
    protected ColorUIResource getPrimary1() {
    return new ColorUIResource(255,128,0);
    public ColorUIResource getPrimary2() {
              return (new ColorUIResource(Color.white));
         public ColorUIResource getPrimary3() {
              return (new ColorUIResource(255,128,0));
    public ColorUIResource getPrimaryControl() {
    return new ColorUIResource(Color.GREEN);
    protected ColorUIResource getSecondary1() {
    return new ColorUIResource(Color.CYAN);
    protected ColorUIResource getSecondary2() {
              return (new ColorUIResource(Color.gray));
         protected ColorUIResource getSecondary3() {
              return (new ColorUIResource(235,235,235));
         protected ColorUIResource getBlack() {
              return BLACK;
         protected ColorUIResource getWhite() {
              return WHITE;
         private Object getIconResource(String s) {
    return LookAndFeel.makeIcon(getClass(), s);
    private Icon getHastenedIcon(String s, UIDefaults uidefaults) {
    Object obj = getIconResource(s);
    return (Icon) ((javax.swing.UIDefaults.LazyValue) obj).createValue(uidefaults);
    static class MyLookAndFeel extends Plastic3DLookAndFeel {
              protected void initClassDefaults(UIDefaults table) {
                   super.initClassDefaults(table);
              protected void initComponentDefaults(UIDefaults table) {
                   super.initComponentDefaults(table);
                   Object[] defaults = {
                             "MenuItem.foreground",new ColorUIResource(Color.white),
                             "MenuItem.background",new ColorUIResource(Color.gray),
                             "MenuItem.selectionForeground",new ColorUIResource(Color.gray),
                             "MenuItem.selectionBackground",new ColorUIResource(Color.white),
                             "Menu.selectionForeground", new ColorUIResource(Color.white),
                             "Menu.selectionBackground", new ColorUIResource(Color.gray),
                             "MenuBar.background", new ColorUIResource(235,235,235),
                             "Menu.background", new ColorUIResource(235,235,235),
                             "Desktop.background",new ColorUIResource(235,235,235),
                             "Button.select",new ColorUIResource(255,128,0),
                             "Button.focus",new ColorUIResource(255,128,0),
                             "TableHeader.background", new ColorUIResource(255,128,0),
                             "TableHeader.foreground", new ColorUIResource(Color.white),
                             "ScrollBar.background", new ColorUIResource(235,235,235),
                             "OptionPane.questionDialog.border.background", new ColorUIResource(Color.gray),
                             "OptionPane.errorDialog.titlePane.foreground", new ColorUIResource(Color.white),
                             "OptionPane.questionDialog.titlePane.background", new ColorUIResource(255,128,0),
                             "InternalFrame.borderColor", new ColorUIResource(Color.gray),
                             "InternalFrame.activeTitleForeground", new ColorUIResource(Color.white),
                             "InternalFrame.activeTitleBackground", new ColorUIResource(Color.gray),
                             "InternalFrame.borderColor", new ColorUIResource(Color.white),
                             "Table.selectionBackground",new ColorUIResource(255,128,0)
                   table.putDefaults(defaults);
    public static void main(String argv[]) {
    TestTheDialog tester = new TestTheDialog();
    package CustomThemes;
    import javax.swing.JDialog;
    import java.awt.event.ActionListener;
    import javax.swing.JPanel;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JButton;
    import java.awt.event.ActionEvent;
    public class CustomDialog extends JDialog implements ActionListener {
    private JPanel myPanel = null;
    private JButton yesButton = null;
    private JButton noButton = null;
    private boolean answer = false;
    public boolean getAnswer() { return answer; }
    public CustomDialog(){
    public CustomDialog(JFrame frame, boolean modal, String myMessage) {
    super(frame, modal);
    setTitle("Guess?");
    myPanel = new JPanel();
    getContentPane().add(myPanel);
    myPanel.add(new JLabel(myMessage));
    yesButton = new JButton("Yes");
    yesButton.addActionListener(this);
    myPanel.add(yesButton);
    noButton = new JButton("No");
    noButton.addActionListener(this);
    myPanel.add(noButton);
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    pack();
    setLocationRelativeTo(frame);
    setVisible(true);
    public void actionPerformed(ActionEvent e) {
    if(yesButton == e.getSource()) {
    System.err.println("User chose yes.");
    answer = true;
    setVisible(false);
    else if(noButton == e.getSource()) {
    System.err.println("User chose no.");
    answer = false;
    setVisible(false);
    Thanks and Regards
    Kumar.

    Hi All,
    I am using the JGoodies Look and feel (looks2.0.1.jar). I wrote my own custom LookAndFeel and Theme , but the problem with this is the JDialog/JOptionPane dialog boxes are displayed with out the close button (cross button on the titlebar).
    I am pasting the code here.
    import java.awt.Color;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import javax.swing.Icon;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.LookAndFeel;
    import javax.swing.SwingUtilities;
    import javax.swing.UIDefaults;
    import javax.swing.UIManager;
    import javax.swing.plaf.ColorUIResource;
    import com.jgoodies.looks.plastic.Plastic3DLookAndFeel;
    import com.jgoodies.looks.plastic.PlasticTheme;
    import com.medplexus.looks.plastic.theme.SkyGreen;
    public class TestTheDialog implements ActionListener {
        JFrame mainFrame = null;
        JButton myButton = null;
        public TestTheDialog() {
            mainFrame = new JFrame("TestTheDialog Tester");
            mainFrame.addWindowListener(new WindowAdapter() {
                    public void windowClosing(WindowEvent e) {System.exit(0);}
            try{
                 MyLookAndFeel.setCurrentTheme(new CustomLaF());
                 UIManager.setLookAndFeel(new MyLookAndFeel());
                 //Plastic3DLookAndFeel.setCurrentTheme(new SkyGreen());
                 //UIManager.setLookAndFeel(new Plastic3DLookAndFeel());
                 SwingUtilities.updateComponentTreeUI(mainFrame);
                 CustomDialog cd = new CustomDialog();
                 cd.setDefaultLookAndFeelDecorated(true);
            catch(Exception e){
            myButton = new JButton("Test the dialog!");
            myButton.addActionListener(this);
            mainFrame.setLocationRelativeTo(null);
            mainFrame.getContentPane().add(myButton);
            mainFrame.setSize(200, 150);
            //mainFrame.pack();
            mainFrame.setVisible(true);
        public void actionPerformed(ActionEvent e) {
            if(myButton == e.getSource()) {
                System.err.println("Opening dialog.");
                CustomDialog myDialog = new CustomDialog(mainFrame, true, "Do you like Java?");
                System.err.println("After opening dialog.");
                if(myDialog.getAnswer()) {
                    System.err.println("The answer stored in CustomDialog is 'true' (i.e. user clicked yes button.)");
                else {
                    System.err.println("The answer stored in CustomDialog is 'false' (i.e. user clicked no button.)");
        static class CustomLaF extends PlasticTheme {
            protected ColorUIResource getPrimary1() {
              return new ColorUIResource(255,128,0);
            public ColorUIResource getPrimary2() {
                  return (new ColorUIResource(Color.white));
             public ColorUIResource getPrimary3() {
                  return (new ColorUIResource(255,128,0));
            public ColorUIResource getPrimaryControl() {
              return new ColorUIResource(Color.GREEN);
            protected ColorUIResource getSecondary1() {
              return new ColorUIResource(Color.CYAN);
            protected ColorUIResource getSecondary2() {
                  return (new ColorUIResource(Color.gray));
             protected ColorUIResource getSecondary3() {
                  return (new ColorUIResource(235,235,235));
             protected ColorUIResource getBlack() {
                  return BLACK;
             protected ColorUIResource getWhite() {
                  return WHITE;
             private Object getIconResource(String s) {
                return LookAndFeel.makeIcon(getClass(), s);
            private Icon getHastenedIcon(String s, UIDefaults uidefaults) {
                Object obj = getIconResource(s);
                return (Icon) ((javax.swing.UIDefaults.LazyValue) obj).createValue(uidefaults);
          static class MyLookAndFeel extends Plastic3DLookAndFeel {
                  protected void initClassDefaults(UIDefaults table) {
                       super.initClassDefaults(table);
                  protected void initComponentDefaults(UIDefaults table) {
                       super.initComponentDefaults(table);
                       Object[] defaults = {
                                 "MenuItem.foreground",new ColorUIResource(Color.white),
                                 "MenuItem.background",new ColorUIResource(Color.gray),
                                 "MenuItem.selectionForeground",new ColorUIResource(Color.gray),
                                 "MenuItem.selectionBackground",new ColorUIResource(Color.white),
                                 "Menu.selectionForeground", new ColorUIResource(Color.white),
                                 "Menu.selectionBackground", new ColorUIResource(Color.gray),
                                 "MenuBar.background", new ColorUIResource(235,235,235),
                                 "Menu.background", new ColorUIResource(235,235,235),
                                 "Desktop.background",new ColorUIResource(235,235,235),
                                 "Button.select",new ColorUIResource(255,128,0),
                                 "Button.focus",new ColorUIResource(255,128,0),
                                 "TableHeader.background", new ColorUIResource(255,128,0),
                                 "TableHeader.foreground", new ColorUIResource(Color.white),
                                 "ScrollBar.background",  new ColorUIResource(235,235,235),
                                 "OptionPane.questionDialog.border.background", new ColorUIResource(Color.gray),
                                 "OptionPane.errorDialog.titlePane.foreground", new ColorUIResource(Color.white),
                                 "OptionPane.questionDialog.titlePane.background", new ColorUIResource(255,128,0),
                                 "InternalFrame.borderColor", new ColorUIResource(Color.gray),
                                 "InternalFrame.activeTitleForeground", new ColorUIResource(Color.white),
                                 "InternalFrame.activeTitleBackground", new ColorUIResource(Color.gray),
                                 "InternalFrame.borderColor", new ColorUIResource(Color.white),
                                 "Table.selectionBackground",new ColorUIResource(255,128,0)
                       table.putDefaults(defaults);
        public static void main(String argv[]) {
            TestTheDialog tester = new TestTheDialog();
    import javax.swing.JDialog;
    import java.awt.event.ActionListener;
    import javax.swing.JPanel;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JButton;
    import java.awt.event.ActionEvent;
    public class CustomDialog extends JDialog implements ActionListener {
        private JPanel myPanel = null;
        private JButton yesButton = null;
        private JButton noButton = null;
        private boolean answer = false;
        public boolean getAnswer() { return answer; }
        public CustomDialog(){
        public CustomDialog(JFrame frame, boolean modal, String myMessage) {
            super(frame, modal);
            setTitle("Guess?");
            myPanel = new JPanel();
            getContentPane().add(myPanel);
            myPanel.add(new JLabel(myMessage));
            yesButton = new JButton("Yes");
            yesButton.addActionListener(this);
            myPanel.add(yesButton);       
            noButton = new JButton("No");
            noButton.addActionListener(this);
            myPanel.add(noButton);
            setDefaultCloseOperation(EXIT_ON_CLOSE);
            pack();
            setLocationRelativeTo(frame);
            setVisible(true);
        public void actionPerformed(ActionEvent e) {
            if(yesButton == e.getSource()) {
                System.err.println("User chose yes.");
                answer = true;
                setVisible(false);
            else if(noButton == e.getSource()) {
                System.err.println("User chose no.");
                answer = false;
                setVisible(false);
    }Thanks and Regards
    Kumar.

  • JDialog boxes

    Hi,
    Just a bit curious whats the best way to creat a JDialog box?
    I currently have have one main panel, with one button. When the user clicks this button, it brind up the dialog box. I dont think i have done this correctly, as when the dialog box populates, when I move it around on the screen, it erases the contents off the panel that called the dialog (erases the contents when i move the dialog accross the screen.
    Can any one help me set out the correct constructors for the DIalog and the panel calling it?
    thanks in advance
    public public class PanelA extends JPanel {
    public class Dialoig Box extends JDialog {
    public class GUI {
    public () {
    //code here to add a jbutton to panelA
    //code here to add PanelA to the frame
    //inner class here . Action listener for the button
    class CheckButtonActionListener
    implements ActionListener {
    public void actionPerformed(ActionEvent event) {
    //Main method here
    Main frame = new Main();

    import javax.swing.*;
    public class Main extends javax.swing.JFrame {
        public Main() {
            initComponents();
        private void initComponents() {
            jPanel1 = new javax.swing.JPanel();
            jButton1 = new javax.swing.JButton();
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            setTitle("Test Dialog Box");
            jButton1.setText("jButton1");
            jButton1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton1ActionPerformed(evt);
            jPanel1.add(jButton1);
            getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);
            java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
            setBounds((screenSize.width-401)/2, (screenSize.height-411)/2, 401, 411);
        private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
            JDialog dialog = new DialogBox(this,true);
            dialog.setVisible(true);
        public static void main(String args[]) {
            new Main().setVisible(true);
        // Variables declaration - do not modify
        private javax.swing.JButton jButton1;
        private javax.swing.JPanel jPanel1;
        // End of variables declaration
        public class DialogBox extends javax.swing.JDialog {
            public DialogBox(java.awt.Frame parent, boolean modal) {
                super(parent, modal);
                initComponents();
            private void initComponents() {
                jPanel1 = new javax.swing.JPanel();
                jButton1 = new javax.swing.JButton();
                setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
                setTitle("Dialog Box");
                jButton1.setText("jButton1");
                jButton1.addActionListener(new java.awt.event.ActionListener() {
                    public void actionPerformed(java.awt.event.ActionEvent evt) {
                        jButtonActionPerformed(evt);
                jPanel1.add(jButton1);
                getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);
                java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
                setBounds((screenSize.width-237)/2, (screenSize.height-191)/2, 237, 191);
            private void jButtonActionPerformed(java.awt.event.ActionEvent evt) {
                setVisible(false);
                dispose();
            private javax.swing.JButton jButton1;
            private javax.swing.JPanel jPanel1;
    }

  • 3D Programming and 7000 Series set top box

    I want to watch ESPN 3D but the screens are split on my Panasonic 3D Plasma screen.  It is part of the Ultimate HD package but I have not been able to see it.  The technicians at Verizon give me a different story each time I talk to them.  One of the techs told me I need a 7000 series box to view 3D content.  Can anyone tell me if this is true or give me suggestions to make this work?  I also wonder if I need to connect the HDMI cable from the set top box directly to the tv via a 1.4 HDMI cable without going through my "non 3D capable" receiver or if a 1.3 HDMI cable will work like it does with my Playstation.  Thanks.
    Kurt

    I had the same problems. This is what you need to do if you haven't tried it yet. EPSN 3D broadcasts in 720P, so you have to go to settings and change your video settings to 720P, my guess is you probably have it set to 1080i. After setting it to 720p, then set your TV 3D setting to top and bottom and it should merge the picture. I would set the setting back to 1080i when you are done with watching the channel, the movies on demand I believe are 1080i and 3D setting side by side. Hope that helps.

  • Displaying JDialog box in front of all windows

    Hi guys,
    I am trying to display a Dialog box with some error message.
    I did it using the following code
    import java.awt.*;
    import javax.swing.*;
    public class JDialog_test {
         public static void main(String args[])
              Frame oframe=new Frame("JDialog Error Message");
              JDialog odialog=new JDialog(oframe,"Praveen",true);
              odialog.setModal(true);
              System.out.println("the modal is set as "+odialog.isModal());
              //odialog.setAlwaysOnTop(true);
              odialog.setVisible(true);
              System.out.println("In displayable is set as "+odialog.isDisplayable());
              odialog.toFront();
    When i run the above code, a dialog box is created successfully.
    But the problem is the dialog box is not displayed in front of all screens.
    Also the dialog box disappears when i open another window.
    Now what i require is???
    ->the dialog box should be displayed on top of all the windows
    ->as long as the dialog box is not closed , i should not be able to access other windows
    Please don put the setModal() method as solution, it isnt working.
    Also i want the solution to be compatible with only java 1.4 compiler.
    Please get back with solutions.

    import java.awt.Dimension;
    import javax.swing.*;
    public class JDialog_test {
         public static void main(String args[])
              JFrame jframe=new JFrame("JFrame");
              jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              jframe.setVisible(true);
              jframe.setSize(new Dimension(200,300));
              JDialog jdialog=new JDialog(jframe,"JDialog",true);
              jdialog.setModal(true);
              jdialog.setSize(new Dimension(100,200));
              jframe.setVisible(true);
              jdialog.setAlwaysOnTop(true); //<-- here's the trick..
              jdialog.setModal(true);
              jdialog.setVisible(true);
              jdialog.toFront();
    }

  • Closing a JDialog box

    Hi,
    I've got a JList inside of a JDialog. When the user selects an item in the JList I would like the JDialog to close automatically instead of requiring the user the manually close the dialog box. Any ideas?
    thanks,
    Roberto Samarone Araujo

    Try something like this:
    JList list = <whatever>;
    JDialog dialog = <whatever?; // may have to be declared final
    // put them together however you want
    list.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            dialog.dispose();
            // do whatever else you want to happen when a selection is made
    });Shaun

  • JDialog box with room to type in a file name or browse files

    Can anyone please tell me how to get a box with the message please choose a file to open, a strip for the user to type a file name into, with a browse button to the right for finding files, and then an ok button underneath.
    Thanks tonnes

    Here's the whole function in its current state:
    public File getOutputFile() throws IOException {
    int result = chooser.showSaveDialog(FileInputFrame.this);
    if(result == JFileChooser.APPROVE_OPTION)
    { String fileName = new String();
    System.out.println(chooser.getSelectedFile());
    fileName = chooser.getSelectedFile().getAbsolutePath();
    System.out.println(fileName);
    File aFile = new File(fileName);
    return aFile;
    else
    return null;
    I'm using JBuilder, so it always says which line the exception is on, and it is always thrown at the first line where chooser.getSelectedFile() is dereferenced, so I'm pretty sure that it is returning null for whatever reason.
    I have the default directory set to "~", so it comes up with a listing of everything in my home directory. Then I just type in a name that does not appear on that list, and poof, exceptions galore.
    OK, here's a really wierd thing. If I use the name of a file that already exists in my home directory but save it in some random subdirectory, there is no problem. But, if I use the name of a file that exists nowhere in that same subdirectory, I get the exception.
    I wonder if it is a system permissions problem, as I do not have admin permissions on this machine, although everything is running out of my home directory, so I should have write permissions. I wonder also if it could be system dependent-- I'm running redhat. I don't have a lot of experience trying to interface with the os/file system, that's why I was so happy to find the JFileChooser class in the first place.
    Thanks for your thoughts on this!

  • JDialog boxes aren't drawing properly

    Hi
    I'm busy designing the front end for my final year project at uni (on Netbeans 5.5, although I doubt the problem is due to that), and I've suddenly started getting some strange problems with dialog boxes (seems to be since updating to Java 1.6 SDK, although this could be a co-incidence. The dialog boxes are displaying, but with holes in them, so you can see right through to the main frame underneath, then moving the dialog box will cause it to disappear completely,. only showing components on it when you go over them with the move, but never the background. I managed to combat most of this but making it run:
    this.update(this.getGraphics());
    every time the dialog box is instantiated and on the component move and shown events. This has solved the problem with holes appearing in the window (even if it does create a rather weird trailing effect), but the title bar and border do not refresh, and both still appear initially with holes, eventually completely disappearing.
    The GUI itself does not do anything weird with the dialog box (well now it does with havign to manually trigger the update), it did use different lookandfeels, but I've commented out that for the moment (to no avail).
    This does seem to be quite a big, but I've not found any help on google for this (ah, the friend of all programmers, surely). I've ran the distribution jar files on multiple computers using multiple version of java (well 1.6 and 1.5), and the problem persists. I've check Netbeans generated code, and I can't fault it. I was just wondering if anyone had any idea of a workaround? Even somehow repainting/updating the title and border as well as the main dialog box, or a cure for the bug? Just so I can get some screenshots.
    Thank you for any assistance you can give me.
    Alex

    Just a quick follow-up in case anyone else runs into this problem (and it may well be a few people do), I had to disable aceleration down to disabling DirectX and Direct3D (so you don't have top disable it full), and seems to suggest that there is a [problem with the way that JAVA works with DirectX (or DirectX works with JAVA I suppose, but as this is a recent problem, I would imagine it may well be JAVA which is at fault IMHO).
    Alex                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How to put minimise, maximize buttons on jDialog box

    I have a dialog box whose default option is close button provided at top, i have to put minimize, maximize(Restore) buttons.

    Use JFrame?

  • How do I get a dialog box to reappear?

    I'm trying to write an application where
    1. There is an opening frame. The user can click a 'start' button which
    opens the first of a series of dialog boxes.
    2 Each of these dialog boxes has a user input field and buttons 'next' 'back' and 'cancel' , to step forward/backward through user input , or to cancel & return to the opening frame.
    3. As each dialog box opens up , the preceeding one should be hid.
    4. If the user clicks 'back' , the current box should close and the
    preceeding one should reopen.
    Straightforward enough and I've got this working at the start of the progam
    for the transition between the opening frame and the first dialog box, by
    doing this:
    in the opening frame...
    //start button..
    this.setVisible(false);
    Dialog001 d001 = new Dialog001(this,"",true);
    d001.setVisible(true);;
    and in the code in the dialog box d001, for the '<< back' button..
    void button1_actionPerformed(ActionEvent e) {
    dispose();
    super.getOwner().setVisible(true);
    *********** so far so good : everything works OK **************
    The problem is when I repeat this in the second dialog box , the
    first dialog box doesn't reappear.
    I have looked in the books and tries various things, but no good
    so far
    How do I get the previous dialog box to reappear?
    Also, how will the 'cancel' button work in the second (and subsequent)
    dialog boxes (instead of the preceeding dialog box reappearing, the
    original opening frame should reappear) ?
    Thanks in advance
    Mike
    [the jdk is 1.2.2 , OS is win98, IDE is jbuilder ver 3]

    How is this: (you can change it from Swing to AWT.)
    setVisible(false);
    int index = 0;     
    Vector v  = new Vector();
    dialog d;
    while (index != -1)
         if (index == v.size())
               v.add(new dialog(this,index));
              d = (dialog)v.get(index);
         else
              d = (dialog)v.get(index);
                  d.setVisible(true);     
         index = d.ret;
         setVisible(true);
    public class dialog extends JDialog
         JButton next = new JButton("next");
         JButton back = new JButton("back");
         JButton canc = new JButton("cancel");
         int     me;
         int     ret;
    public dialog(JFrame f,int i)
         super(f,""+i,true);
         me = i;
         getContentPane().setLayout(new GridLayout(4,0));     
         getContentPane().add(next); 
         getContentPane().add(back);
         getContentPane().add(canc);
         next.addActionListener(new ActionListener()
         {     public void actionPerformed( ActionEvent e )
              {     ret = me+1;      
                   setVisible(false);     
         back.addActionListener(new ActionListener()
         {     public void actionPerformed( ActionEvent e )
              {     ret = me-1;
                   setVisible(false);          
         canc.addActionListener(new ActionListener()
         {     public void actionPerformed( ActionEvent e )
              {     ret = -1;
                   setVisible(false);          
         getContentPane().add(new TextField("abced"));
         setBounds(100,100,100,150);
         setVisible(true);

  • How to invoke OK button in Modal JDialog

    Hi,
    I have two buttons in a Modal JDialog box OK, Save. The functionalities are written in actionPerformed(). But when I click the OK or Save button, the function is not getting invoked.
    JDialog jd = new JDialog();
    jd.setModal(true);
    jd.show;
    Please give me a solution.
    Thanks in Advance....

    Actually, I didn't use Swing for some years now.
    Hava a look at the API doc. Seems like you can pass a Component instead of a String for the message. Maybe you could use a ScrollPane or something like that.
    http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/JOptionPane.html
    What doc says about message arg:
    A descriptive message to be placed in the dialog box. In the most common usage, message is just a String or String constant. However, the type of this parameter is actually Object. Its interpretation depends on its type:
    Object[]
    An array of objects is interpreted as a series of messages (one per object) arranged in a vertical stack. The interpretation is recursive -- each object in the array is interpreted according to its type.
    Component
    The Component is displayed in the dialog.
    Icon
    The Icon is wrapped in a JLabel and displayed in the dialog.
    others
    The object is converted to a String by calling its toString method. The result is wrapped in a JLabel and displayed.

Maybe you are looking for