الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

كيف أنشأ شاشة MDI على لغة الجافا

مغلق
بدأه MKSoft في 23 مارس 2007 · 2 رد · 539 مشاهدة · في JavaSE
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم ورحمة الله وبركاته ...

أريد أن أعرف كيف أنشأ شاشة MDI , التي يكون هناك Form رئيسي , ومجموعة Forms أخرى بداخله , مثل برنامج MS Word

... في الحقيقة أنا كتبت هذا الكود , لكن لم حدثت مشكلة , حيث أن Form الداخلي لم يظهر العناصر التي يحتويها مثل Buttons ..

الشاشة الرئيسية ..

import javax.swing.*;
import java.awt.event.*;
public class test extends JFrame{
	JDesktopPane theDesktop;
	public test(){
		JMenuBar bar = new JMenuBar(); 
		JMenu addMenu = new JMenu( "Add" ); 
		JMenuItem newFrame = new JMenuItem( "Internal Frame" );
		addMenu.add( newFrame ); 
		bar.add( addMenu );
		setJMenuBar( bar ); 
		theDesktop = new JDesktopPane(); 
		add( theDesktop ); 
		newFrame.addActionListener(
		   new ActionListener() {
			  public void actionPerformed( ActionEvent event ){
				 JInternalFrame frame = new JInternalFrame("Internal Frame", true, true, true, true );
				 tttttttLayout t=new tttttttLayout();
				 frame.add(t);
				 frame.pack(); 
				 theDesktop.add(frame);
				 frame.setVisible(true);
			   } 
		   }  ); }
		public static void main( String args[] ){
		test desktopFrame = new test();
		desktopFrame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
		desktopFrame.setSize( 600, 480 ); 
		desktopFrame.setVisible( true ); 
	} }

الشاشة الداخلية ...

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class ttttttt extends JInternalFrame {
	JButton button_1;
	JButton button_2;
	JButton button_3;
	Label label_1;
	public ttttttt() {
		tttttttLayout customLayout = new tttttttLayout();
		getContentPane().setFont(new Font("Helvetica", Font.PLAIN, 12));
		getContentPane().setLayout(customLayout);
		button_1 = new JButton("button_1");
		getContentPane().add(button_1);
		button_2 = new JButton("button_2");
		getContentPane().add(button_2);
		button_3 = new JButton("button_3");
		getContentPane().add(button_3);
		label_1 = new Label("HELLO");
		getContentPane().add(label_1);
		setSize(getPreferredSize()); }
	public static void main(String args[]) {
		ttttttt window = new ttttttt();
		window.setTitle("ttttttt");
		window.pack();
		window.show();
	}}
class tttttttLayout implements LayoutManager {
	public tttttttLayout() {
	}
	public void addLayoutComponent(String name, Component comp) {
	}
	public void removeLayoutComponent(Component comp) {
   }
	public Dimension preferredLayoutSize(Container parent) {
	   Dimension dim = new Dimension(0, 0);
		Insets insets = parent.getInsets();
		dim.width = 320 + insets.left + insets.right;
		dim.height = 240 + insets.top + insets.bottom;
		return dim; }
	public Dimension minimumLayoutSize(Container parent) {
		Dimension dim = new Dimension(0, 0);
		return dim;}
	public void layoutContainer(Container parent) {
		Insets insets = parent.getInsets();
		Component c;
		c = parent.getComponent(0);
		if (c.isVisible()) {c.setBounds(insets.left+80,insets.top+56,72,24);}
		c = parent.getComponent(1);
		if (c.isVisible()) {c.setBounds(insets.left+80,insets.top+88,72,24);}
		c = parent.getComponent(2);
		if (c.isVisible()) {c.setBounds(insets.left+80,insets.top+120,72,24);}
		c = parent.getComponent(3);
		if (c.isVisible()) {c.setBounds(insets.left+8,insets.top+8,304,32);}}}
#2

اخوي

سو فورم واحد فقط رئيسي

والباقي كلها JPanel وكل jpanel حط فيه المحتويات اللي تبغا وكلها تحت سقف واحد اللي هو الـ JFrame

وهذا اللي تعلمناه ونعرفه

#3

شكرا أخي بارك الله فيك

هذا الموضوع مغلق.

مواضيع مشابهة

عدد الزوار حالياً

المتواجدون خلال آخر دقيقتين · يتحدّث كل ٣٠ ثانية

—الإجمالي—أعضاء مسجّلون—زوار بدون تسجيل

جارٍ التحقق من المتواجدين…