本文整理汇总了Java中javax.swing.JApplet类的典型用法代码示例。如果您正苦于以下问题:Java JApplet类的具体用法?Java JApplet怎么用?Java JApplet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JApplet类属于javax.swing包,在下文中一共展示了JApplet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getLayeredPane
import javax.swing.JApplet; //导入依赖的package包/类
private Component getLayeredPane() {
Container parent = null;
if (this.owner != null) {
parent = this.owner instanceof Container ? (Container) this.owner : this.owner.getParent();
}
for (Container p = parent; p != null; p = p.getParent()) {
if (p instanceof JRootPane) {
if (p.getParent() instanceof JInternalFrame) {
continue;
}
parent = ((JRootPane) p).getLayeredPane();
} else if (p instanceof Window) {
if (parent == null) {
parent = p;
}
break;
} else if (p instanceof JApplet) {
break;
}
}
return parent;
}
示例2: NonOpaqueJAppletFrame
import javax.swing.JApplet; //导入依赖的package包/类
NonOpaqueJAppletFrame() {
super("NonOpaque Swing JAppletFrame");
JApplet ja = new JApplet() {
public void paint(Graphics g) {
super.paint(g);
System.err.println("JAppletFrame paint called");
}
};
p = new JPanel() {
public void paintComponent(Graphics g) {
super.paintComponent(g);
render(g, getWidth(), getHeight(), true);
g.setColor(Color.red);
g.drawString("Non-Opaque Swing JFrame", 10, 15);
}
};
p.setDoubleBuffered(false);
p.setOpaque(false);
ja.add(p);
add(ja);
setUndecorated(true);
}
示例3: getPopup
import javax.swing.JApplet; //导入依赖的package包/类
@Override
public Popup getPopup(Component owner, Component contents, int x, int y)
throws IllegalArgumentException {
Component[] hierarchy = getHierarchy(owner);
for(int a = hierarchy.length-1; a>=0; a--) {
if(hierarchy[a] instanceof JApplet &&
contents instanceof JComponent) {
return new AppletPopup( (JApplet)hierarchy[a], owner, (JComponent)contents, x, y);
/* Unfortunately we can't simply check against a java.awt.Frame,
* because applets can be embedded in a
* sun.plugin2.main.client.PluginEmbeddedFrame.
*/
//} else if(hierarchy[a] instanceof Frame) {
} else if(hierarchy[a] instanceof JFrame) {
return oldFactory.getPopup(owner, contents, x, y);
}
}
return oldFactory.getPopup(owner, contents, x, y);
}
示例4: run
import javax.swing.JApplet; //导入依赖的package包/类
public void run() {
try {
Class cls = Class.forName(loadAppletName);
JApplet app = (JApplet)cls.newInstance();
app.setStub((AppletStub)this);
app.init();
getContentPane().add("Center", app);
loadApplet = app;
validate();
if(isStarted) {
loadApplet.start();
}
validate();
} catch (Throwable e) {
loadApplet = null;
AppletLogger.showError("Exception:", e);
e.printStackTrace();
validate();
}
System.out.println("Thread end");
}
示例5: run
import javax.swing.JApplet; //导入依赖的package包/类
public void run() {
try {
Class cls = Class.forName(loadAppletName);
JApplet app = (JApplet)cls.newInstance();
app.setStub((AppletStub)this);
app.init();
getContentPane().add("Center", app);
loadApplet = app;
validate();
if(isStarted) {
loadApplet.start();
}
validate();
} catch (Throwable e) {
loadApplet = null;
AppletLogger.showError("Exception:", e);
e.printStackTrace();
validate();
}
}
示例6: main
import javax.swing.JApplet; //导入依赖的package包/类
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
JFrame f = new JFrame("Line");
f.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
JApplet applet = new Gynfont();
f.getContentPane().add("Center", applet);
applet.init();
f.pack();
f.setSize(new Dimension(800, 100));
f.setVisible(true);
}
示例7: showMensagem
import javax.swing.JApplet; //导入依赖的package包/类
/**
*
* Exibe uma caixa de dialogo com uma mensagem.
*
* @param applet
* @param mensagem -> String com a mensagem a ser exibida
* @param tipo -> Tipo da mensagem, sendo: 0 = Informacao, 1 = Alerta e 2 = Erro
*/
public static void showMensagem(JApplet applet, String mensagem, int tipo) {
String[] botao = new String[]{""};
botao[0]= "Fechar";
String Titulo;
int tipoMsg;
switch (tipo) {
case 0: Titulo= "Informa��o do Sistema."; tipoMsg=JOptionPane.INFORMATION_MESSAGE; break;
case 1: Titulo= "Alerta do Sistema!"; tipoMsg=JOptionPane.WARNING_MESSAGE; break;
case 2: Titulo= "Erro na Execu��o!"; tipoMsg=JOptionPane.ERROR_MESSAGE; break;
default: Titulo= "Informa��o do Sistema!"; tipoMsg=JOptionPane.INFORMATION_MESSAGE; break;
}
JOptionPane.showOptionDialog(applet,
mensagem,
Titulo,
JOptionPane.YES_OPTION,
tipoMsg,
null,
botao,
botao[0]);
//JOptionPane.showMessageDialog(applet, message, "Mensagem do Sistema",JOptionPane.NO_OPTION);
}
示例8: Menu
import javax.swing.JApplet; //导入依赖的package包/类
public Menu(int w, int h, JApplet aplet)
{
try
{
bgImage = ImageIO.read(this.getClass().getClassLoader().getResource("resources/chessg.jpg"));
bgImage = bgImage.getScaledInstance(w, h, 1);
startButton = ImageIO.read(this.getClass().getClassLoader().getResource("resources/startgame.png"));
exitButton =ImageIO.read(this.getClass().getClassLoader().getResource("resources/exitgame.png"));
playGame= new Rectangle(100,100,100,50);
exit = new Rectangle(100,200,90,50);
frame=aplet;
}
catch (IOException ex)
{
System.err.println(ex.toString());
}
}
示例9: loadImage
import javax.swing.JApplet; //导入依赖的package包/类
/**
* Loads an image from the application server from which a JApplet originates. Stores
* the the image in the image mapping with the parameter name as the key.
*
* @param applet The JApplet
* @param parameter Name of the parameter which specifies the relative path of the image
*/
protected void loadImage(JApplet applet, String parameter)
{
String codeBase = applet.getCodeBase().toString();
String path = applet.getParameter(parameter);
if (path != null)
{
try
{
URL url = new URL(codeBase + path);
BufferedImage image = ImageIO.read(url);
images.put(parameter, image);
}
catch (Exception e)
{
//Unable to load image do nothing
}
}
}
示例10: init
import javax.swing.JApplet; //导入依赖的package包/类
public void init(JApplet a) {
applet = a;
size = applet.getSize();
canvas = new Canvas();
canvas.setSize(applet.getSize());
applet.add(canvas);
canvas.createBufferStrategy(2);
canvas.addKeyListener(this);
canvas.addMouseListener(this);
canvas.addMouseMotionListener(this);
canvas.addMouseWheelListener(this);
canvas.setBackground(Color.black);
canvas.setForeground(Color.white);
frames = 0;
start = 0;
layers = new CopyOnWriteArrayList<>();
initGame();
}
示例11: main
import javax.swing.JApplet; //导入依赖的package包/类
public static void main(String[] args) {
SwingUtilities.invokeLater(() -> {
JFrame frame = new JFrame("Swing FX Keyboard");
frame.setResizable(false);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JApplet applet = new SwingDemo();
applet.init();
frame.setContentPane(applet.getContentPane());
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
applet.start();
});
}
示例12: createMenus
import javax.swing.JApplet; //导入依赖的package包/类
private void createMenus() {
menuBar = new JMenuBar();
createFileMenu();
createDisplayMenu();
createAnimationMenu();
if (container instanceof JFrame) {
((JFrame) container).setJMenuBar(menuBar);
} else if (container instanceof JApplet) {
((JApplet) container).setJMenuBar(menuBar);
}
}
示例13: ActivityMonitorTest
import javax.swing.JApplet; //导入依赖的package包/类
/** Creates new form ActivityMonitorTest */
public ActivityMonitorTest(JApplet applet) {
initComponents();
this.applet = applet;
setSize(800,300);
getContentPane().setLayout(new BorderLayout());
getContentPane().add(applet,BorderLayout.CENTER);
}
示例14: main
import javax.swing.JApplet; //导入依赖的package包/类
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
JApplet applet = new DVSActApplet();
JFrame frame = new ActivityMonitorTest(applet);
applet.init();
applet.start();
frame.setVisible(true);
}
示例15: main
import javax.swing.JApplet; //导入依赖的package包/类
/**
* For testing in JFrame
* @param args the command line arguments
*/
public static void main(String args[]) {
JApplet applet = new ClockApplet();
JFrame frame = new ActivityMonitorTest(applet);
applet.init();
applet.start();
frame.setVisible(true);
}