requestFocus我也试了,也不行。 我在一个desktoppane里测试了一下,似乎只有setVisible有效。比如
.
.
.
JInternalFrame if1,if2;
.
.
if1.setVisible(true);
if2.setVisible(true);-------------这里谁放后面,谁就能在前面显示
.....但我的JInternalFrame是通过鼠标事件触发的啊,该怎么办啊?
.
.
.
JInternalFrame if1,if2;
.
.
if1.setVisible(true);
if2.setVisible(true);-------------这里谁放后面,谁就能在前面显示
.....但我的JInternalFrame是通过鼠标事件触发的啊,该怎么办啊?
解决方案 »
- 请高手帮我看看我写的jtable怎么实现分页
- java中为什么我的scanner不能用?
- 安装Tomcat5.0.30问题,解决问题给50,进来的都有分
- 用JTextArea 如何实现剪切,复制,拷贝功能??????
- 一个能把对象直接输出到网页上的工具包
- 请教!现在还有人用RMI吗?
- 做一个java的客户端,向服务器端发“GET”请求,如何做到?
- java的String类用法
- 是不是只能在applet方法里的paint()里画图呀?
- 一个小问题,怎么在java中运行另一个应用程序?收到答案立即结贴
- 求 HttpURLConnection 使用说明
- 一个问题:如何将int转换为String类型?需要用在setText上。
那个什么 Plan来做容器是可以的
{
setSelected(true);
}
catch..
import javax.swing.*;
import java.awt.*;/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2004</p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
*/public class maxWin extends JFrame {
JButton jButton1 = new JButton();
public maxWin() throws HeadlessException {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace(); }
}
public static void main(String[] args) throws HeadlessException {
maxWin maxWin1 = new maxWin();
}
private void jbInit() throws Exception {
jButton1.setText("jButton1");
// this.preferredSize(new Dimension(1024,768));
//this.setSize ( new Dimension(1024,768));
//this.setSize(new Dimension(1024,768));
//this.setBounds(0,0,1024,768);
this.setState(Frame.MAXIMIZED_BOTH);
// this.getContentPane().add(jButton1, BorderLayout.CENTER);
this.pack();
this.show(); }}
import javax.swing.JInternalFrame;
import javax.swing.JDesktopPane;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JMenuBar;
import javax.swing.JFrame;
import javax.swing.KeyStroke;import java.awt.event.*;
import java.awt.*;/*
* InternalFrameDemo.java is a 1.4 application that requires:
* MyInternalFrame.java
*/
public class InternalFrameDemo extends JFrame
implements ActionListener {
JDesktopPane desktop; public InternalFrameDemo() {
super("InternalFrameDemo"); //Make the big window be indented 50 pixels from each edge
//of the screen.
int inset = 50;
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
setBounds(inset, inset,
screenSize.width - inset*2,
screenSize.height - inset*2); //Set up the GUI.
desktop = new JDesktopPane(); //a specialized layered pane
createFrame(); //create first "window"
setContentPane(desktop);
setJMenuBar(createMenuBar()); //Make dragging a little faster but perhaps uglier.
desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
} protected JMenuBar createMenuBar() {
JMenuBar menuBar = new JMenuBar(); //Set up the lone menu.
JMenu menu = new JMenu("Document");
menu.setMnemonic(KeyEvent.VK_D);
menuBar.add(menu); //Set up the first menu item.
JMenuItem menuItem = new JMenuItem("New");
menuItem.setMnemonic(KeyEvent.VK_N);
menuItem.setAccelerator(KeyStroke.getKeyStroke(
KeyEvent.VK_N, ActionEvent.ALT_MASK));
menuItem.setActionCommand("new");
menuItem.addActionListener(this);
menu.add(menuItem); //Set up the second menu item.
menuItem = new JMenuItem("Quit");
menuItem.setMnemonic(KeyEvent.VK_Q);
menuItem.setAccelerator(KeyStroke.getKeyStroke(
KeyEvent.VK_Q, ActionEvent.ALT_MASK));
menuItem.setActionCommand("quit");
menuItem.addActionListener(this);
menu.add(menuItem); return menuBar;
} //React to menu selections.
public void actionPerformed(ActionEvent e) {
if ("new".equals(e.getActionCommand())) { //new
createFrame();
} else { //quit
quit();
}
} //Create a new internal frame.
protected void createFrame() {
MyInternalFrame frame = new MyInternalFrame();
frame.setVisible(true); //necessary as of 1.3
desktop.add(frame);
try {
frame.setSelected(true);
} catch (java.beans.PropertyVetoException e) {}
} //Quit the application.
protected void quit() {
System.exit(0);
} /**
* Create the GUI and show it. For thread safety,
* this method should be invoked from the
* event-dispatching thread.
*/
private static void createAndShowGUI() {
//Make sure we have nice window decorations.
JFrame.setDefaultLookAndFeelDecorated(true); //Create and set up the window.
InternalFrameDemo frame = new InternalFrameDemo();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //Display the window.
frame.setVisible(true);
} public static void main(String[] args) {
//Schedule a job for the event-dispatching thread:
//creating and showing this application's GUI.
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
}
}
import java.awt.*;
import com.borland.jbcl.layout.*;
import javax.swing.*;
import java.beans.*;/* Used by InternalFrameDemo.java. */
public class MyInternalFrame
extends JInternalFrame {
static int openFrameCount = 0;
static final int xOffset = 30, yOffset = 30; public MyInternalFrame() {
super("Document #" + (++openFrameCount),
true, //resizable
true, //closable
true, //maximizable
true); //iconifiable //...Create the GUI and put it in the window... //...Then set the window size or call pack...
setSize(300, 300); //Set the window's location.
setLocation(xOffset * openFrameCount, yOffset * openFrameCount);
try {
jbInit();
}
catch (Exception e) {
e.printStackTrace();
}
} private void jbInit() throws Exception {
jButton1.setText("单击此处新增子窗口");
jButton1.addActionListener(new MyInternalFrame_jButton1_actionAdapter(this));
this.getContentPane().setLayout(xYLayout1);
this.getContentPane().add(jButton1, new XYConstraints(107, 96, -1, -1));
} XYLayout xYLayout1 = new XYLayout();
JButton jButton1 = new JButton(); void jButton1_actionPerformed(ActionEvent e) {
System.out.println("adfas");
MyInternalFrame a = new MyInternalFrame();
this.getParent().add(a);
a.setVisible(true);
try {
a.setSelected(true);
}
catch (PropertyVetoException ex) {
}
// JOptionPane.showMessageDialog(null,"dfd"); }
}class MyInternalFrame_jButton1_actionAdapter
implements java.awt.event.ActionListener {
MyInternalFrame adaptee; MyInternalFrame_jButton1_actionAdapter(MyInternalFrame adaptee) {
this.adaptee = adaptee;
} public void actionPerformed(ActionEvent e) {
adaptee.jButton1_actionPerformed(e);
}
}