Results 1 to 11 of 11
  1. #1
    apprerntice is offline Member
    Join Date
    Jul 2011
    Posts
    6
    Rep Power
    0

    Default A componenet positioning problem

    Q1. Componenets (JRadioButtons) appear out of position when the screen resolution is switched. They either move to far right or go off screen completely. Components should appear in Centre. JPanel Layout Manager is Groupedlayout and is inside a JTabbedPane which itself is within the JDialog.

    Q.2. I have 2 classes (Jframe and JDiolog) when the main app is fired up (Jframe) the JDialog Window will appear. I am after a modal effect, whilst JDialog is active. JFrame should be greyed out and should not be editable until JDialog window is closed. Some tips on how to do this will be appreciated.

    #JDialog Class
    Java Code:
    import java.awt.BorderLayout;  
      
      
      
    public class DataDialog extends JDialog {  
      
        private final JPanel contentPanel = new JPanel();  
      
      
        /** 
         * Launch the application. 
         */  
        public static void main(String[] args) {  
            try {  
                DataDialog dialog = new DataDialog();  
                dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);  
                dialog.setVisible(true);  
            } catch (Exception e) {  
                e.printStackTrace();  
            }  
        }  
      
        /** 
         * Create the dialog. 
         */  
        public DataDialog() {  
            // Get toolkit  
            Toolkit toolkit = Toolkit.getDefaultToolkit();  
      
            // Get size  
            Dimension dimension = toolkit.getScreenSize();  
            int width = dimension.width;  
            int height= dimension.height;  
            setBounds(this.getX()+50,this.getY()+100, width-100, height-150);  
              
            getContentPane().setLayout(new BorderLayout());  
            contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));  
            getContentPane().add(contentPanel, BorderLayout.CENTER);  
              
            //Group all Buttons  
            //Button Group One  
            ButtonGroup buttonGroupOne = new ButtonGroup();  
              
              
              
            //Button Group Two  
            ButtonGroup buttonGroupTwo = new ButtonGroup();  
              
            //Register a Listener for radio buttons  
            RadioListener rListener = new RadioListener();  
            JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);  
              
            GroupLayout gl_contentPanel = new GroupLayout(contentPanel);  
            gl_contentPanel.setHorizontalGroup(  
                gl_contentPanel.createParallelGroup(Alignment.TRAILING)  
                    .addComponent(tabbedPane, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 1100, Short.MAX_VALUE)  
            );  
            gl_contentPanel.setVerticalGroup(  
                gl_contentPanel.createParallelGroup(Alignment.TRAILING)  
                    .addGroup(Alignment.LEADING, gl_contentPanel.createSequentialGroup()  
                        .addComponent(tabbedPane, GroupLayout.PREFERRED_SIZE, 800, GroupLayout.PREFERRED_SIZE)  
                        .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))  
            );  
            {  
                JPanel panel = new JPanel();  
                tabbedPane.addTab("New Tab", null, panel, null);  
                tabbedPane.setEnabledAt(0, true);  
                JRadioButton rdbtnOne = new JRadioButton("Button One");  
                buttonGroupOne.add(rdbtnOne);  
                rdbtnOne.setSelected(true);  
                JRadioButton rdbtnTwo = new JRadioButton("Button Two");  
                buttonGroupOne.add(rdbtnTwo);  
                JRadioButton rdbtnThree = new JRadioButton("Button Three");  
                buttonGroupOne.add(rdbtnThree);  
                JRadioButton rdbtnFour = new JRadioButton("Button Four");  
                buttonGroupOne.add(rdbtnFour);  
                GroupLayout gl_panel = new GroupLayout(panel);  
                gl_panel.setHorizontalGroup(  
                    gl_panel.createParallelGroup(Alignment.LEADING)  
                        .addGroup(gl_panel.createSequentialGroup()  
                            .addGap(377)  
                            .addGroup(gl_panel.createParallelGroup(Alignment.LEADING)  
                                .addComponent(rdbtnOne)  
                                .addComponent(rdbtnTwo)  
                                .addComponent(rdbtnThree)  
                                .addComponent(rdbtnFour))  
                            .addContainerGap(709, Short.MAX_VALUE))  
                );  
                gl_panel.setVerticalGroup(  
                    gl_panel.createParallelGroup(Alignment.LEADING)  
                        .addGroup(gl_panel.createSequentialGroup()  
                            .addGap(43)  
                            .addComponent(rdbtnOne)  
                            .addPreferredGap(ComponentPlacement.UNRELATED)  
                            .addComponent(rdbtnTwo)  
                            .addPreferredGap(ComponentPlacement.RELATED)  
                            .addComponent(rdbtnThree)  
                            .addPreferredGap(ComponentPlacement.UNRELATED)  
                            .addComponent(rdbtnFour)  
                            .addContainerGap(631, Short.MAX_VALUE))  
                );  
                gl_panel.setHonorsVisibility(false);  
                panel.setLayout(gl_panel);  
            }  
            {  
                JPanel panel = new JPanel();  
                tabbedPane.addTab("New tab", null, panel, null);  
            }  
            {  
                JPanel panel = new JPanel();  
                tabbedPane.addTab("New tab", null, panel, null);  
            }  
            contentPanel.setLayout(gl_contentPanel);  
            {  
                JPanel buttonPane = new JPanel();  
                buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));  
                getContentPane().add(buttonPane, BorderLayout.SOUTH);  
                {  
                    JButton okButton = new JButton("OK");  
                    okButton.setActionCommand("OK");  
                    buttonPane.add(okButton);  
                    getRootPane().setDefaultButton(okButton);  
                }  
                {  
                    JButton cancelButton = new JButton("Cancel");  
                    cancelButton.setActionCommand("Cancel");  
                    buttonPane.add(cancelButton);  
                }  
            }  
              
        }  
          
        class RadioListener implements ActionListener{  
            public void actionPerformed(ActionEvent e){  
                System.out.println("Radio Button [" + e.getActionCommand()  
                        + "] was Selected.");  
            }  
        }  
    }  
    
    
    #JFrame Class 
    view plaincopy to clipboardprint?
    import java.awt.Dimension;  
    import java.awt.EventQueue;  
    import java.awt.Frame;  
    import java.awt.Toolkit;  
      
    import javax.swing.JFrame;  
      
      
      
      
    public class CompareUI {  
      
        private JFrame frame;  
      
        /** 
         * Launch the application. 
         */  
        public static void main(String[] args) {  
            EventQueue.invokeLater(new Runnable() {  
                public void run() {  
                    try {  
                        CompareUI window = new CompareUI();                     
                        window.frame.setVisible(true);  
                    } catch (Exception e) {  
                        e.printStackTrace();  
                    }  
                }  
            });  
        }  
      
        /** 
         * Create the application. 
         */  
        public CompareUI() {  
            initialize();  
        }  
      
        /** 
         * Initialize the contents of the frame. 
         */  
        private void initialize() {  
            frame = new JFrame();  
            Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();  
            frame.setBounds(0, 0,screen.width,screen.height - 30);  
            frame.setExtendedState(Frame.MAXIMIZED_BOTH);  
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);  
              
              
        }  
    }
    Last edited by apprerntice; 07-22-2011 at 08:22 PM.

  2. #2
    j2me64's Avatar
    j2me64 is offline Senior Member
    Join Date
    Sep 2009
    Location
    Zurich, Switzerland
    Posts
    962
    Rep Power
    6

    Default

    plase use code-tags next time you post your code. to your Q1: each jtabbedpane can have its own layout. so read this to position your component: Using Layout Managers (The Java™ Tutorials > Creating a GUI With JFC/Swing > Laying Out Components Within a Container)

  3. #3
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,882
    Rep Power
    25

    Default

    Where do you create a DataDialog class instance from the SQLCompareUI class?
    The JDialog constructor has a modal parameter.

  4. #4
    apprerntice is offline Member
    Join Date
    Jul 2011
    Posts
    6
    Rep Power
    0

    Default

    j2me64 - Tried seting a layout manager to the tabbedPane but it throws an error.
    e.g. tabbedPane.setLayout(new FlowLayout());
    Java Code:
    java.lang.ArrayIndexOutOfBoundsException: 0
    	at javax.swing.plaf.basic.BasicTabbedPaneUI.paintTabArea(Unknown Source)
    	at javax.swing.plaf.basic.BasicTabbedPaneUI.paint(Unknown Source)
    	at javax.swing.plaf.ComponentUI.update(Unknown Source)
    	at javax.swing.JComponent.paintComponent(Unknown Source)
    	at javax.swing.JComponent.printComponent(Unknown Source)
    	at javax.swing.JComponent.paint(Unknown Source)
    	at javax.swing.JComponent.print(Unknown Source)
    	at javax.swing.JComponent.paintChildren(Unknown Source)
    	at javax.swing.JComponent.printChildren(Unknown Source)
    	at javax.swing.JComponent.paint(Unknown Source)
    	at javax.swing.JComponent.print(Unknown Source)
    	at javax.swing.JComponent.paintChildren(Unknown Source)
    	at javax.swing.JComponent.printChildren(Unknown Source)
    	at javax.swing.JComponent.paint(Unknown Source)
    	at javax.swing.JComponent.print(Unknown Source)
    	at javax.swing.JComponent.paintChildren(Unknown Source)
    	at javax.swing.JComponent.printChildren(Unknown Source)
    	at javax.swing.JComponent.paint(Unknown Source)
    	at javax.swing.JLayeredPane.paint(Unknown Source)
    	at javax.swing.JComponent.print(Unknown Source)
    	at javax.swing.JComponent.paintChildren(Unknown Source)
    	at javax.swing.JComponent.printChildren(Unknown Source)
    	at javax.swing.JComponent.paint(Unknown Source)
    	at javax.swing.JComponent.print(Unknown Source)
    	at java.awt.GraphicsCallback$PrintCallback.run(Unknown Source)
    	at sun.awt.SunGraphicsCallback.runOneComponent(Unknown Source)
    	at sun.awt.SunGraphicsCallback.runComponents(Unknown Source)
    	at java.awt.Container.print(Unknown Source)
    	at sun.awt.windows.WComponentPeer.print(Unknown Source)
    	at sun.awt.windows.WPanelPeer.print(Unknown Source)
    	at sun.awt.windows.WWindowPeer.print(Unknown Source)
    	at java.awt.GraphicsCallback$PeerPrintCallback.run(Unknown Source)
    	at sun.awt.SunGraphicsCallback.runOneComponent(Unknown Source)
    	at java.awt.Component.printAll(Unknown Source)
    	at org.eclipse.wb.internal.swing.utils.SwingScreenshotMaker.makeShots(SwingScreenshotMaker.java:123)
    	at org.eclipse.wb.internal.swing.model.component.ComponentInfo.refresh_fetch(ComponentInfo.java:154)
    	at org.eclipse.wb.internal.swing.model.component.ComponentInfo.refresh_fetch(ComponentInfo.java:139)
    	at org.eclipse.wb.internal.swing.model.component.ContainerInfo.refresh_fetch(ContainerInfo.java:251)
    	at org.eclipse.wb.core.model.ObjectInfo$5$1.run(ObjectInfo.java:487)
    	at org.eclipse.wb.internal.core.utils.execution.ExecutionUtils.runDesignTime(ExecutionUtils.java:139)
    	at org.eclipse.wb.core.model.ObjectInfo$5.run(ObjectInfo.java:484)
    	at org.eclipse.wb.internal.swing.utils.SwingUtils$2.run(SwingUtils.java:76)
    	at java.awt.event.InvocationEvent.dispatch(Unknown Source)
    	at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    	at java.awt.EventQueue.access$000(Unknown Source)
    	at java.awt.EventQueue$1.run(Unknown Source)
    	at java.awt.EventQueue$1.run(Unknown Source)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
    	at java.awt.EventQueue.dispatchEvent(Unknown Source)
    	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    	at java.awt.EventDispatchThread.run(Unknown Source)
    
    Full context stack trace:
    java.lang.ArrayIndexOutOfBoundsException: 0
    	at javax.swing.plaf.basic.BasicTabbedPaneUI.paintTabArea(Unknown Source)
    	at javax.swing.plaf.basic.BasicTabbedPaneUI.paint(Unknown Source)
    	at javax.swing.plaf.ComponentUI.update(Unknown Source)
    	at javax.swing.JComponent.paintComponent(Unknown Source)
    	at javax.swing.JComponent.printComponent(Unknown Source)
    	at javax.swing.JComponent.paint(Unknown Source)
    	at javax.swing.JComponent.print(Unknown Source)
    	at javax.swing.JComponent.paintChildren(Unknown Source)
    	at javax.swing.JComponent.printChildren(Unknown Source)
    	at javax.swing.JComponent.paint(Unknown Source)
    	at javax.swing.JComponent.print(Unknown Source)
    	at javax.swing.JComponent.paintChildren(Unknown Source)
    	at javax.swing.JComponent.printChildren(Unknown Source)
    	at javax.swing.JComponent.paint(Unknown Source)
    	at javax.swing.JComponent.print(Unknown Source)
    	at javax.swing.JComponent.paintChildren(Unknown Source)
    	at javax.swing.JComponent.printChildren(Unknown Source)
    	at javax.swing.JComponent.paint(Unknown Source)
    	at javax.swing.JLayeredPane.paint(Unknown Source)
    	at javax.swing.JComponent.print(Unknown Source)
    	at javax.swing.JComponent.paintChildren(Unknown Source)
    	at javax.swing.JComponent.printChildren(Unknown Source)
    	at javax.swing.JComponent.paint(Unknown Source)
    	at javax.swing.JComponent.print(Unknown Source)
    	at java.awt.GraphicsCallback$PrintCallback.run(Unknown Source)
    	at sun.awt.SunGraphicsCallback.runOneComponent(Unknown Source)
    	at sun.awt.SunGraphicsCallback.runComponents(Unknown Source)
    	at java.awt.Container.print(Unknown Source)
    	at sun.awt.windows.WComponentPeer.print(Unknown Source)
    	at sun.awt.windows.WPanelPeer.print(Unknown Source)
    	at sun.awt.windows.WWindowPeer.print(Unknown Source)
    	at java.awt.GraphicsCallback$PeerPrintCallback.run(Unknown Source)
    	at sun.awt.SunGraphicsCallback.runOneComponent(Unknown Source)
    	at java.awt.Component.printAll(Unknown Source)
    	at org.eclipse.wb.internal.swing.utils.SwingScreenshotMaker.makeShots(SwingScreenshotMaker.java:123)
    	at org.eclipse.wb.internal.swing.model.component.ComponentInfo.refresh_fetch(ComponentInfo.java:154)
    	at org.eclipse.wb.internal.swing.model.component.ComponentInfo.refresh_fetch(ComponentInfo.java:139)
    	at org.eclipse.wb.internal.swing.model.component.ContainerInfo.refresh_fetch(ContainerInfo.java:251)
    	at org.eclipse.wb.core.model.ObjectInfo$5$1.run(ObjectInfo.java:487)
    	at org.eclipse.wb.internal.core.utils.execution.ExecutionUtils.runDesignTime(ExecutionUtils.java:139)
    	at org.eclipse.wb.core.model.ObjectInfo$5.run(ObjectInfo.java:484)
    	at org.eclipse.wb.internal.swing.utils.SwingUtils$2.run(SwingUtils.java:76)
    	at java.awt.event.InvocationEvent.dispatch(Unknown Source)
    	at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    	at java.awt.EventQueue.access$000(Unknown Source)
    	at java.awt.EventQueue$1.run(Unknown Source)
    	at java.awt.EventQueue$1.run(Unknown Source)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
    	at java.awt.EventQueue.dispatchEvent(Unknown Source)
    	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    	at java.awt.EventDispatchThread.run(Unknown Source)

    Norm - At the moment both class have their own main methods and they run independently of one another.

  5. #5
    apprerntice is offline Member
    Join Date
    Jul 2011
    Posts
    6
    Rep Power
    0

    Default

    j2me64 - Tried seting a layout manager to the tabbedPane but it throws an error.
    e.g. tabbedPane.setLayout(new FlowLayout());
    Java Code:
    java.lang.ArrayIndexOutOfBoundsException: 0
    	at javax.swing.plaf.basic.BasicTabbedPaneUI.paintTabArea(Unknown Source)
    	at javax.swing.plaf.basic.BasicTabbedPaneUI.paint(Unknown Source)
    	at javax.swing.plaf.ComponentUI.update(Unknown Source)
    	at javax.swing.JComponent.paintComponent(Unknown Source)
    	at javax.swing.JComponent.printComponent(Unknown Source)
    	at javax.swing.JComponent.paint(Unknown Source)
    	at javax.swing.JComponent.print(Unknown Source)
    	at javax.swing.JComponent.paintChildren(Unknown Source)
    	at javax.swing.JComponent.printChildren(Unknown Source)
    	at javax.swing.JComponent.paint(Unknown Source)
    	at javax.swing.JComponent.print(Unknown Source)
    	at javax.swing.JComponent.paintChildren(Unknown Source)
    	at javax.swing.JComponent.printChildren(Unknown Source)
    	at javax.swing.JComponent.paint(Unknown Source)
    	at javax.swing.JComponent.print(Unknown Source)
    	at javax.swing.JComponent.paintChildren(Unknown Source)
    	at javax.swing.JComponent.printChildren(Unknown Source)
    	at javax.swing.JComponent.paint(Unknown Source)
    	at javax.swing.JLayeredPane.paint(Unknown Source)
    	at javax.swing.JComponent.print(Unknown Source)
    	at javax.swing.JComponent.paintChildren(Unknown Source)
    	at javax.swing.JComponent.printChildren(Unknown Source)
    	at javax.swing.JComponent.paint(Unknown Source)
    	at javax.swing.JComponent.print(Unknown Source)
    	at java.awt.GraphicsCallback$PrintCallback.run(Unknown Source)
    	at sun.awt.SunGraphicsCallback.runOneComponent(Unknown Source)
    	at sun.awt.SunGraphicsCallback.runComponents(Unknown Source)
    	at java.awt.Container.print(Unknown Source)
    	at sun.awt.windows.WComponentPeer.print(Unknown Source)
    	at sun.awt.windows.WPanelPeer.print(Unknown Source)
    	at sun.awt.windows.WWindowPeer.print(Unknown Source)
    	at java.awt.GraphicsCallback$PeerPrintCallback.run(Unknown Source)
    	at sun.awt.SunGraphicsCallback.runOneComponent(Unknown Source)
    	at java.awt.Component.printAll(Unknown Source)
    	at org.eclipse.wb.internal.swing.utils.SwingScreenshotMaker.makeShots(SwingScreenshotMaker.java:123)
    	at org.eclipse.wb.internal.swing.model.component.ComponentInfo.refresh_fetch(ComponentInfo.java:154)
    	at org.eclipse.wb.internal.swing.model.component.ComponentInfo.refresh_fetch(ComponentInfo.java:139)
    	at org.eclipse.wb.internal.swing.model.component.ContainerInfo.refresh_fetch(ContainerInfo.java:251)
    	at org.eclipse.wb.core.model.ObjectInfo$5$1.run(ObjectInfo.java:487)
    	at org.eclipse.wb.internal.core.utils.execution.ExecutionUtils.runDesignTime(ExecutionUtils.java:139)
    	at org.eclipse.wb.core.model.ObjectInfo$5.run(ObjectInfo.java:484)
    	at org.eclipse.wb.internal.swing.utils.SwingUtils$2.run(SwingUtils.java:76)
    	at java.awt.event.InvocationEvent.dispatch(Unknown Source)
    	at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    	at java.awt.EventQueue.access$000(Unknown Source)
    	at java.awt.EventQueue$1.run(Unknown Source)
    	at java.awt.EventQueue$1.run(Unknown Source)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
    	at java.awt.EventQueue.dispatchEvent(Unknown Source)
    	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    	at java.awt.EventDispatchThread.run(Unknown Source)
    
    Full context stack trace:
    java.lang.ArrayIndexOutOfBoundsException: 0
    	at javax.swing.plaf.basic.BasicTabbedPaneUI.paintTabArea(Unknown Source)
    	at javax.swing.plaf.basic.BasicTabbedPaneUI.paint(Unknown Source)
    	at javax.swing.plaf.ComponentUI.update(Unknown Source)
    	at javax.swing.JComponent.paintComponent(Unknown Source)
    	at javax.swing.JComponent.printComponent(Unknown Source)
    	at javax.swing.JComponent.paint(Unknown Source)
    	at javax.swing.JComponent.print(Unknown Source)
    	at javax.swing.JComponent.paintChildren(Unknown Source)
    	at javax.swing.JComponent.printChildren(Unknown Source)
    	at javax.swing.JComponent.paint(Unknown Source)
    	at javax.swing.JComponent.print(Unknown Source)
    	at javax.swing.JComponent.paintChildren(Unknown Source)
    	at javax.swing.JComponent.printChildren(Unknown Source)
    	at javax.swing.JComponent.paint(Unknown Source)
    	at javax.swing.JComponent.print(Unknown Source)
    	at javax.swing.JComponent.paintChildren(Unknown Source)
    	at javax.swing.JComponent.printChildren(Unknown Source)
    	at javax.swing.JComponent.paint(Unknown Source)
    	at javax.swing.JLayeredPane.paint(Unknown Source)
    	at javax.swing.JComponent.print(Unknown Source)
    	at javax.swing.JComponent.paintChildren(Unknown Source)
    	at javax.swing.JComponent.printChildren(Unknown Source)
    	at javax.swing.JComponent.paint(Unknown Source)
    	at javax.swing.JComponent.print(Unknown Source)
    	at java.awt.GraphicsCallback$PrintCallback.run(Unknown Source)
    	at sun.awt.SunGraphicsCallback.runOneComponent(Unknown Source)
    	at sun.awt.SunGraphicsCallback.runComponents(Unknown Source)
    	at java.awt.Container.print(Unknown Source)
    	at sun.awt.windows.WComponentPeer.print(Unknown Source)
    	at sun.awt.windows.WPanelPeer.print(Unknown Source)
    	at sun.awt.windows.WWindowPeer.print(Unknown Source)
    	at java.awt.GraphicsCallback$PeerPrintCallback.run(Unknown Source)
    	at sun.awt.SunGraphicsCallback.runOneComponent(Unknown Source)
    	at java.awt.Component.printAll(Unknown Source)
    	at org.eclipse.wb.internal.swing.utils.SwingScreenshotMaker.makeShots(SwingScreenshotMaker.java:123)
    	at org.eclipse.wb.internal.swing.model.component.ComponentInfo.refresh_fetch(ComponentInfo.java:154)
    	at org.eclipse.wb.internal.swing.model.component.ComponentInfo.refresh_fetch(ComponentInfo.java:139)
    	at org.eclipse.wb.internal.swing.model.component.ContainerInfo.refresh_fetch(ContainerInfo.java:251)
    	at org.eclipse.wb.core.model.ObjectInfo$5$1.run(ObjectInfo.java:487)
    	at org.eclipse.wb.internal.core.utils.execution.ExecutionUtils.runDesignTime(ExecutionUtils.java:139)
    	at org.eclipse.wb.core.model.ObjectInfo$5.run(ObjectInfo.java:484)
    	at org.eclipse.wb.internal.swing.utils.SwingUtils$2.run(SwingUtils.java:76)
    	at java.awt.event.InvocationEvent.dispatch(Unknown Source)
    	at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    	at java.awt.EventQueue.access$000(Unknown Source)
    	at java.awt.EventQueue$1.run(Unknown Source)
    	at java.awt.EventQueue$1.run(Unknown Source)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
    	at java.awt.EventQueue.dispatchEvent(Unknown Source)
    	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    	at java.awt.EventDispatchThread.run(Unknown Source)

    Norm - At the moment both class have their own main methods and they run independently of one another.

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,882
    Rep Power
    25

    Default

    I have 2 classes (Jframe and JDiolog) when the main app is fired up (Jframe) the JDialog Window will appear. I am after a modal effect, whilst JDialog is active. JFrame should be greyed out and should not be editable until JDialog window is closed
    both class have their own main methods and they run independently of one another
    Could you explain your question 2?

    If they are two separate programs running independently, do you want the one program to tell the other one what to do?

  7. #7
    apprerntice is offline Member
    Join Date
    Jul 2011
    Posts
    6
    Rep Power
    0

    Default

    No, its a single program, perhaps having 2 class is a bit too much?. I want a JDialog inside a JFrame. If JDialog is active the JFrame will be inactive until JDialog is closed.

  8. #8
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,882
    Rep Power
    25

    Default

    If JDialog is active the JFrame will be inactive until JDialog is closed.
    That sounds like the JDialog should be created as modal. See the JDialog class's API doc.
    But your class extending JFrame doesn't call/create the JDialog class.
    If it did, it could pass the modal parameter to the JDialog class's constructor.

  9. #9
    apprerntice is offline Member
    Join Date
    Jul 2011
    Posts
    6
    Rep Power
    0

    Default

    I decided to delete the JDialog Class and put it all in the same class. Problem now is when application starts JDialog is not visible only the JFrame.

    I imagine when the buttons are reinserted into the JDialog the positioning problem (Q.1) will reappear so any tips on that will be appreciated.

    Thanks

    Java Code:
    import java.awt.Dimension;
    import java.awt.EventQueue;
    import java.awt.Frame;
    import java.awt.Toolkit;
    
    import javax.swing.JFrame;
    import javax.swing.JDialog;
    import java.awt.BorderLayout;
    import java.awt.Dialog.ModalityType;
    import java.awt.Color;
    
    
    
    
    public class CompareUI {
    
    	private JFrame frame;
    
    	/**
    	 * Launch the application.
    	 */
    	public static void main(String[] args) {
    		EventQueue.invokeLater(new Runnable() {
    			public void run() {
    				try {
    					CompareUI window = new CompareUI();					
    					window.frame.setVisible(true);
    				} catch (Exception e) {
    					e.printStackTrace();
    				}
    			}
    		});
    	}
    
    	/**
    	 * Create the application.
    	 */
    	public CompareUI() {
    		initialize();
    	}
    
    	/**
    	 * Initialize the contents of the frame.
    	 */
    	private void initialize() {
    		frame = new JFrame();
    		Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    		frame.setBounds(0, 0,screen.width,screen.height - 30);
    		frame.setExtendedState(Frame.MAXIMIZED_BOTH);
    		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    		
    		JDialog dialog = new JDialog();
    		dialog.setBackground(Color.GRAY);
    		dialog.setResizable(false);
    		dialog.setModal(true);
    		dialog.setModalityType(ModalityType.APPLICATION_MODAL);
    		frame.getContentPane().add(dialog, BorderLayout.CENTER);
    		
    		
    	}
    }
    Last edited by apprerntice; 07-22-2011 at 08:23 PM.

  10. #10
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,882
    Rep Power
    25

    Default

    Java Code:
    frame.getContentPane().add(dialog, BorderLayout.CENTER);
    Why are you adding the JDialog to the JFrame?
    JDialog extends from Window.
    You need to read the Java Tutorial on how to build Dialogs.
    In the API doc for JDialog there is a link to the Tutorial site: How to Make Dialogs.

    In post #1 you did this to show the dialog:
    Java Code:
                DataDialog dialog = new DataDialog();  
                dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);  
                dialog.setVisible(true);

  11. #11
    apprerntice is offline Member
    Join Date
    Jul 2011
    Posts
    6
    Rep Power
    0

    Default

    Thank You for the help
    Last edited by apprerntice; 07-22-2011 at 08:56 PM.

Similar Threads

  1. problem positioning a JPanel in a JScrollPane
    By gib65 in forum AWT / Swing
    Replies: 5
    Last Post: 09-06-2013, 09:27 AM
  2. Vertical box and positioning
    By aborgeld in forum New To Java
    Replies: 9
    Last Post: 04-01-2011, 08:33 PM
  3. Positioning using setBounds
    By thayalan in forum AWT / Swing
    Replies: 4
    Last Post: 04-28-2009, 02:59 AM
  4. I obviously don't understand positioning panels
    By javatard in forum New To Java
    Replies: 2
    Last Post: 12-10-2008, 08:48 AM
  5. panel positioning
    By shwein in forum New To Java
    Replies: 4
    Last Post: 09-09-2008, 06:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •