Guest_imported
New member
- Jan 1, 1970
- 0
Hi All,
I do have class, which is given below; Presently the size of the dialog box is hard coded(setSize(734, 600));
Could anyone let me know how I get the size dynamic(1/4 of the entire frame).
=============================================
import java.awt.Container;
import java.awt.event.*;
import javax.swing.*;
import java.awt.*;
public class FinalValidationDialog extends JDialog
{
private JTextArea myText = new JTextArea();
private JScrollPane myScrollPane;
private Container myParentContainer;
public FinalValidationDialog( Container aParent, String aText )
{
super( (JFrame) null, true );
myText.setText( aText );
myText.setEditable( false );
myText.setLineWrap( true );
myText.setWrapStyleWord( true );
init();
this.setLocationRelativeTo( aParent );
}
private void init()
{
// determine the size of the dialog
Window win = SwingUtilities.windowForComponent(myParentContainer);
System.out.println("SwingUtilities.windowForComponent returned "+
win.getClass().getName());
myScrollPane = new JScrollPane(myText);
this.setTitle("Final Validation"
this.getContentPane().add(myScrollPane, "North"
JPanel p = new JPanel();
JButton ok = new JButton("Ok"
p.add(ok);
getContentPane().add(p, "South"
ok.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent evt)
{
setVisible(false);
}
});
setSize(734, 600);
}
}
I do have class, which is given below; Presently the size of the dialog box is hard coded(setSize(734, 600));
Could anyone let me know how I get the size dynamic(1/4 of the entire frame).
=============================================
import java.awt.Container;
import java.awt.event.*;
import javax.swing.*;
import java.awt.*;
public class FinalValidationDialog extends JDialog
{
private JTextArea myText = new JTextArea();
private JScrollPane myScrollPane;
private Container myParentContainer;
public FinalValidationDialog( Container aParent, String aText )
{
super( (JFrame) null, true );
myText.setText( aText );
myText.setEditable( false );
myText.setLineWrap( true );
myText.setWrapStyleWord( true );
init();
this.setLocationRelativeTo( aParent );
}
private void init()
{
// determine the size of the dialog
Window win = SwingUtilities.windowForComponent(myParentContainer);
System.out.println("SwingUtilities.windowForComponent returned "+
win.getClass().getName());
myScrollPane = new JScrollPane(myText);
this.setTitle("Final Validation"
this.getContentPane().add(myScrollPane, "North"
JPanel p = new JPanel();
JButton ok = new JButton("Ok"
p.add(ok);
getContentPane().add(p, "South"
ok.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent evt)
{
setVisible(false);
}
});
setSize(734, 600);
}
}