当前位置: 技术问答>java相关
其他工具都可以通过的程序在JB里总是报错,为什么?
来源: 互联网 发布时间:2015-11-04
本文导语: 程序如下: package myie; 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 java.awt.event.*; import java.awt.*; public class MyIe ...
程序如下:
package myie;
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 java.awt.event.*;
import java.awt.*;
public class MyIe extends JFrame {
JDesktopPane desktop;
static int i = 3;
public MyIe() {
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);
//Quit this app when the big window closes.
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
//Set up the GUI.
desktop = new JDesktopPane(); //a specialized layered pane
//createFrame(); //Create first window
setContentPane(desktop);
setJMenuBar(createMenuBar());
//Make dragging faster:
desktop.putClientProperty("JDesktopPane.dragMode", "outline");
}
protected JMenuBar createMenuBar() {
JMenuBar menuBar = new JMenuBar();
JMenu menu = new JMenu("Document");
menu.setMnemonic(KeyEvent.VK_D);
JMenuItem menuItem = new JMenuItem("New");
menuItem.setMnemonic(KeyEvent.VK_N);
menuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
createFrame();
}
});
menu.add(menuItem);
menuBar.add(menu);
return menuBar;
}
protected void createFrame() {
EditorPaneFrame frame=new EditorPaneFrame(i++);
frame.setVisible(true); //necessary as of kestrel
}
/* public static void main(String[] args) {
MyIe frame = new MyIe();
frame.setVisible(true);
}*/
}
package myie;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
public class EditorPaneFrame extends JFrame
{
//static int openFrameCount = 0;
static final int xOffset = 30, yOffset = 30;
public EditorPaneFrame(int i)
{ setTitle("EditorPaneTest");
setSize(600, 400);
setLocation(xOffset*i, yOffset*i);
// set up text field and load button for typing in URL
url = new JTextField(30);
url.addActionListener(new ActionListener()
{ public void actionPerformed(ActionEvent event)
{ try
{ // remember URL for back button
urlStack.push(url.getText());
editorPane.setPage(url.getText());
}
catch(IOException e)
{ editorPane.setText("Error: " + e);
}
}
});
loadButton = new JButton("Flush");
loadButton.addActionListener(new ActionListener()
{ public void actionPerformed(ActionEvent event)
{ try
{
editorPane.setPage(url.getText());
}
catch(IOException e)
{ editorPane.setText("Error: " + e);
}
}
});
// set up back button and button action
backButton = new JButton("Back");
backButton.addActionListener(new ActionListener()
{ public void actionPerformed(ActionEvent event)
{ if (urlStack.size()
package myie;
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 java.awt.event.*;
import java.awt.*;
public class MyIe extends JFrame {
JDesktopPane desktop;
static int i = 3;
public MyIe() {
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);
//Quit this app when the big window closes.
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
//Set up the GUI.
desktop = new JDesktopPane(); //a specialized layered pane
//createFrame(); //Create first window
setContentPane(desktop);
setJMenuBar(createMenuBar());
//Make dragging faster:
desktop.putClientProperty("JDesktopPane.dragMode", "outline");
}
protected JMenuBar createMenuBar() {
JMenuBar menuBar = new JMenuBar();
JMenu menu = new JMenu("Document");
menu.setMnemonic(KeyEvent.VK_D);
JMenuItem menuItem = new JMenuItem("New");
menuItem.setMnemonic(KeyEvent.VK_N);
menuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
createFrame();
}
});
menu.add(menuItem);
menuBar.add(menu);
return menuBar;
}
protected void createFrame() {
EditorPaneFrame frame=new EditorPaneFrame(i++);
frame.setVisible(true); //necessary as of kestrel
}
/* public static void main(String[] args) {
MyIe frame = new MyIe();
frame.setVisible(true);
}*/
}
package myie;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
public class EditorPaneFrame extends JFrame
{
//static int openFrameCount = 0;
static final int xOffset = 30, yOffset = 30;
public EditorPaneFrame(int i)
{ setTitle("EditorPaneTest");
setSize(600, 400);
setLocation(xOffset*i, yOffset*i);
// set up text field and load button for typing in URL
url = new JTextField(30);
url.addActionListener(new ActionListener()
{ public void actionPerformed(ActionEvent event)
{ try
{ // remember URL for back button
urlStack.push(url.getText());
editorPane.setPage(url.getText());
}
catch(IOException e)
{ editorPane.setText("Error: " + e);
}
}
});
loadButton = new JButton("Flush");
loadButton.addActionListener(new ActionListener()
{ public void actionPerformed(ActionEvent event)
{ try
{
editorPane.setPage(url.getText());
}
catch(IOException e)
{ editorPane.setText("Error: " + e);
}
}
});
// set up back button and button action
backButton = new JButton("Back");
backButton.addActionListener(new ActionListener()
{ public void actionPerformed(ActionEvent event)
{ if (urlStack.size()