كيف يمكن فتح JFrame Chilld من JFrame Parent بطريقة ShowDialog ؟
سؤال فى الswing
mohamad1088 كتب:كيف يمكن فتح JFrame Chilld من JFrame Parent بطريقة ShowDialog ؟
بطريقه ShowDialog ؟؟؟؟
على حد علمى لا توجد ShowDialog الا فى JFileChooser
هل هذا ما تريده؟
import java.awt.*;
import javax.swing.*;
import javax.swing.border.*;
import java.awt.event.*;
public class MainFrame extends JFrame implements ActionListener
{
public final JFrame frame = this;
public MainFrame()
{
super("Main Frame");
setDefaultCloseOperation(EXIT_ON_CLOSE);
try{ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());}
catch(Exception e){ System.out.println("Unable to load Windows look and feel");}
setPreferredSize(new Dimension(300, 100));
((JPanel) getContentPane()).setBorder(new EmptyBorder(13, 13, 13, 13) );
setLayout(new FlowLayout());
JButton btn = new JButton("Open new window");
btn.setActionCommand("myButton");
btn.addActionListener(this);
add(btn);
pack();
setLocationRelativeTo(null);
setVisible(true);
setResizable(false);
}
public void actionPerformed(ActionEvent e)
{
if(e.getActionCommand().equals("myButton"))
{
new SecondaryFrame();
setEnabled(false);
}
}
private class SecondaryFrame extends JFrame
{
public SecondaryFrame()
{
super("Secondary Frame");
setDefaultCloseOperation(HIDE_ON_CLOSE);
try{ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());}
catch(Exception e){ System.out.println("Unable to load Windows look and feel");}
setSize(new Dimension(300, 100));
((JPanel) getContentPane()).setBorder(new EmptyBorder(13, 13, 13, 13) );
setLayout(new FlowLayout());
setLocationRelativeTo(null);
setVisible(true);
setResizable(false);
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
frame.setEnabled(true);
}
});
}
}
public static void main(String[] args)
{
new MainFrame();
}
}show dialog كنت استعملها فى ال.net لكن فى الjava ابه الحل؟
نغم هذا ما اريده جزاك الله خيرا
mohamad1088 كتب:show dialog كنت استعملها فى ال.net لكن فى الjava ابه الحل؟
اخى الكريم
الدوال والطرق تختلف اسمائها من لغه لاخرى
فان كنت تريد شىء فى لغه لا تعرف ما يقابلها فى اللغه التى درستها
فقط يمكنك شرح كيف تعمل ونحن قوم بادلالك على الطريقه او الداله المناسبه
فلا تجزم اسماء غير موجوده فى اللغه
تم تعديل هذه المشاركة بواسطة Mahmoud Kelany في 4 يوليو 2011 في 20:38
