当前位置: 技术问答>java相关
谁能贴个JBuilder 或者 JAVA写的 MDI的例子?多谢~
来源: 互联网 发布时间:2015-10-22
本文导语: 谁能贴个JBuilder 或者 JAVA写的 MDI的例子?相关链接也可以~ | 呵呵,这段代码,我用过三次 import java.awt.*; import java.awt.event.*; import javax.swing.*; class QQQ extends JFrame { JDesktopPane desk = new...
谁能贴个JBuilder 或者 JAVA写的 MDI的例子?相关链接也可以~
|
呵呵,这段代码,我用过三次
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class QQQ extends JFrame
{
JDesktopPane desk = new JDesktopPane();
JInternalFrame if1 = new JInternalFrame();
JInternalFrame if2 = new JInternalFrame();
JButton bt1 = new JButton("Switch 1");
JButton bt2 = new JButton("Switch 2");
JButton btOpen = new JButton("Open");
JTextField txt = new JTextField("I got focus!");
QQQ()
{
JPanel temp = new JPanel();
temp.add(bt1);
temp.add(bt2);
temp.add(btOpen);
getContentPane().add(temp, BorderLayout.NORTH);
getContentPane().add(desk, BorderLayout.CENTER);
desk.add(if1);
desk.add(if2);
if1.getContentPane().add(txt, BorderLayout.NORTH);
if1.reshape(10,10,100,100);
if2.reshape(30,30,100,100);
bt1.addActionListener(new MyListener());
bt2.addActionListener(new MyListener());
btOpen.addActionListener(new MyListener());
setBounds(100,100,400,400);
show();
}
public static void main(String[] args)
{
QQQ q = new QQQ();
}
class MyListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
try
{
if(e.getSource()==bt1)
if1.setSelected(true);
else if(e.getSource()==bt2)
if2.setSelected(true);
else{
if1.setVisible(true);
if2.setVisible(true);
if1.setSelected(true);
txt.requestFocus();
}
}
catch (Exception ex)
{
}
}
};
}
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class QQQ extends JFrame
{
JDesktopPane desk = new JDesktopPane();
JInternalFrame if1 = new JInternalFrame();
JInternalFrame if2 = new JInternalFrame();
JButton bt1 = new JButton("Switch 1");
JButton bt2 = new JButton("Switch 2");
JButton btOpen = new JButton("Open");
JTextField txt = new JTextField("I got focus!");
QQQ()
{
JPanel temp = new JPanel();
temp.add(bt1);
temp.add(bt2);
temp.add(btOpen);
getContentPane().add(temp, BorderLayout.NORTH);
getContentPane().add(desk, BorderLayout.CENTER);
desk.add(if1);
desk.add(if2);
if1.getContentPane().add(txt, BorderLayout.NORTH);
if1.reshape(10,10,100,100);
if2.reshape(30,30,100,100);
bt1.addActionListener(new MyListener());
bt2.addActionListener(new MyListener());
btOpen.addActionListener(new MyListener());
setBounds(100,100,400,400);
show();
}
public static void main(String[] args)
{
QQQ q = new QQQ();
}
class MyListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
try
{
if(e.getSource()==bt1)
if1.setSelected(true);
else if(e.getSource()==bt2)
if2.setSelected(true);
else{
if1.setVisible(true);
if2.setVisible(true);
if1.setSelected(true);
txt.requestFocus();
}
}
catch (Exception ex)
{
}
}
};
}
|
是要播放声音文件吗?