本文整理了Java中java.applet.Applet
类的一些代码示例,展示了Applet
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Applet
类的具体详情如下:
包路径:java.applet.Applet
类名称:Applet
暂无
代码示例来源:origin: runelite/runelite
public ClientPanel(@Nullable Applet client)
{
setSize(Constants.GAME_FIXED_SIZE);
setMinimumSize(Constants.GAME_FIXED_SIZE);
setPreferredSize(Constants.GAME_FIXED_SIZE);
setLayout(new BorderLayout());
setBackground(Color.black);
if (client == null)
{
return;
}
client.setLayout(null);
client.setSize(Constants.GAME_FIXED_SIZE);
client.init();
client.start();
add(client, BorderLayout.CENTER);
// This causes the whole game frame to be redrawn each frame instead
// of only the viewport, so we can hook to MainBufferProvider#draw
// and draw anywhere without it leaving artifacts
if (client instanceof Client)
{
((Client)client).setGameDrawingMode(2);
}
}
}
代码示例来源:origin: redisson/redisson
/**
* Constructs an object importer.
*
* <p>Remote objects are imported from the web server that the given
* applet has been loaded from.
*
* @param applet the applet loaded from the <code>Webserver</code>.
*/
public ObjectImporter(Applet applet) {
URL codebase = applet.getCodeBase();
orgServername = servername = codebase.getHost();
orgPort = port = codebase.getPort();
}
代码示例来源:origin: stackoverflow.com
if (getParameter("show")!=null) {
show = getParameter("show");
add(p);
validate();
panel.setLayout( new BorderLayout(5,5) );
final JLabel output = new JLabel("Select a tree leaf to see the details.");
panel.add(output, BorderLayout.SOUTH);
d = new Dimension(450,d.height);
tableScroll.setPreferredSize(d);
panel.add( tableScroll, BorderLayout.CENTER );
代码示例来源:origin: stackoverflow.com
bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
Graphics g = bi.getGraphics();
g.drawImage(img1, 0, 0, null);
return new Dimension(bi.getWidth(null), bi.getHeight(null));
g2d.setColor(Color.white);
g2d.fillRect(0,0, getWidth(), getHeight());
try {
BufferedImage img1 = ImageIO.read(imageSrc1);
gp.drawImage(image2, 0, 0, null);
start = System.currentTimeMillis();
repaint();
imageSrc1 = new URL(getCodeBase(), imageFileName1);
imageSrc2 = new URL(getCodeBase(), imageFileName2);
} catch (MalformedURLException e) {
add("Center", st);
f.add("Center", sta);
f.pack();
f.setVisible(true);
代码示例来源:origin: stackoverflow.com
import java.applet.*;
import java.net.*;
public class InJava4 extends Applet{
public void init(){
String msg = "Hello from Java (using javascript alert)";
try {
getAppletContext().showDocument
(new URL("javascript:doAlert(\"" + msg +"\")"));
}
catch (MalformedURLException me) { }
}
}
代码示例来源:origin: stackoverflow.com
Graphics g= getGraphics();
this.setLayout(null);
percent.setBounds(10,10,50,30);
this.add(percent);
percent.setVisible(true);
percent.addActionListener(this);
enter.setBounds(65,10,50,30);
enter.addActionListener(this);
this.add(enter);
enter.setBackground(Color.blue);
enter.setVisible(true);
URL url = new URL(getCodeBase(),id);
img = ImageIO.read(url);
} catch (IOException e) {}
g.drawImage(img,10,10,this);
g.setColor(myColor);
g.fillRect(x,y,w,h);
if(entry>=60)
代码示例来源:origin: ThomasFooteDQ/DroidQuest
public SoundClip(String f) {
filename = f;
try {
URL baseURL = new URL("file:" + System.getProperty("user.dir") + "/sounds/");
URL soundURL;
soundURL = new URL(baseURL, filename);
audioClip = Applet.newAudioClip(soundURL);
}
catch (MalformedURLException e) {
System.err.println(e.getMessage());
}
}
}
代码示例来源:origin: stackoverflow.com
URL imageURL = new URL(
"http://pscode.org/media/starzoom-thumb.gif");
Image image = new ImageIcon(imageURL).getImage();
setLayout(new GridLayout(1, 0, 2, 2));
add(new CarAnimationPanel(image));
add(jtfCar1 = new JSpinner(new SpinnerNumberModel(
150, 40, 200, 1)));
g.drawImage(image, x, y, this);
repaint();
JFrame frame = new JFrame("Exercise18_17");
frame.add(applet, BorderLayout.CENTER);
applet.init();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(300, 200);
frame.setLocationRelativeTo(null); // Center the frame
frame.setVisible(true);
代码示例来源:origin: runelite/runelite
URL url = new URL(codebase + initialJar);
Request request = new Request.Builder()
.url(url)
rs.setStub(new RSAppletStub(config));
return rs;
代码示例来源:origin: stackoverflow.com
String string = "http://mainline.brynmawr.edu/Courses/cs110/spring2002/Applets/Smiley/";
URL[] urls = {
new URL(string)
};
URLClassLoader urlcl = new URLClassLoader(urls);
Object o = clss.newInstance();
Applet applet = (Applet)o;
applet.init();
applet.start();
applet.setPreferredSize(new Dimension(200,200));
Component[] components = parent.getComponents();
for (Component c : components) {
System.out.println(c);
代码示例来源:origin: stackoverflow.com
setLayout(null);
okButton = new Button("A button");
nameField = new TextField("A TextField",100);
okButton.setBounds(20,20,100,30);
nameField.setBounds(20,70,100,40);
add(okButton);
add(nameField);
currentApplet.getAppletContext().showDocument(new URL(address));
} catch (Exception ex) {
代码示例来源:origin: stackoverflow.com
import java.applet.*;
import java.awt.Graphics;
import java.net.MalformedURLException;
import java.net.URL;
public class AppletExample extends Applet
{
public void init() {
try {
getAppletContext().showDocument(new URL("http://www.google.com"), "_blank");//This is new tab/
getAppletContext().showDocument(new URL("http://www.google.com"), "_parent");//This is in the parent tab/
}
catch (MalformedURLException ex) {
System.out.println(ex.getMessage());
}
}
public void paint( Graphics g ) {
g.drawString("Go Google", 0,100);
}
}
代码示例来源:origin: stackoverflow.com
getContentPane().add(bp);
validate();
String sampleRate = getParameter("samplerate");
if (sampleRate!=null) {
try {
String fpw = getParameter("fpw");
if (fpw!=null) {
try {
boolean harmonic = (getParameter("addharmonic")!=null);
bp.setAddHarmonic(harmonic);
if ( getParameter("autoloop")!=null ) {
String loopcount = getParameter("loopcount");
if (loopcount!=null) {
try {
e.printStackTrace();
setPreferredSize( new Dimension(300,300) );
options.setLayout(bl);
bPlay.addKeyListener( new KeyAdapter(){
@Override
public void keyPressed(KeyEvent ke) {
代码示例来源:origin: stackoverflow.com
JFrame frame = new JFrame();
frame.setTitle("Grid Panel Example");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JApplet applet = new MyGrid();
applet.init();
frame.getContentPane().add(applet);
frame.pack();
frame.setVisible(true);
getContentPane().add(panel);
setPreferredSize(new Dimension(480, 480));
setBackground(Color.BLACK);
Graphics2D g2D = (Graphics2D)g;
g2D.setColor(Color.lightGray);
g2D.drawLine(0, p, len, p);
g2D.drawLine(p, 0, p, len);
p += c;
ChangeCellsClass ccc = new ChangeCellsClass();
cells = ccc.setCells(cells);
repaint();
代码示例来源:origin: stackoverflow.com
import java.applet.*;
import java.awt.*;
public class FromWhere extends Applet {
public void init() {
Label label = new Label(getCodeBase().toString());
add(label);
}
}
代码示例来源:origin: stackoverflow.com
All.add(scroll);
Container cp = getContentPane();
cp.add(All);
JFrame frame = new JFrame();
frame.getContentPane().removeAll();
frame.setTitle(name);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(applet);
frame.setSize(1200, 500);
applet.init();
applet.start();
frame.setVisible(true);
one.setMaximumSize(new Dimension (150,20));
two.setMaximumSize(new Dimension (150,20));
代码示例来源:origin: stackoverflow.com
applet.setPreferredSize(new Dimension(500, 500));
applet.init();
JFrame mainFrame = new JFrame();
mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
mainFrame.getContentPane().add(applet);
mainFrame.pack();
mainFrame.setVisible(true);
applet.start();
JLabel label = new JLabel("Hello World");
label.setHorizontalAlignment(SwingConstants.CENTER);
add(label);
代码示例来源:origin: stackoverflow.com
public class MyGrid extends JApplet {
public static void main(String[] args) {
JFrame frame = new JFrame();
frame.setTitle("Grid Panel Example");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JApplet applet = new MyGrid();
applet.init();
frame.getContentPane().add(applet);
frame.pack();
frame.setVisible(true);
getContentPane().add(panel);
setPreferredSize(new Dimension(480, 480));
setBackground(Color.BLACK);
代码示例来源:origin: stackoverflow.com
setBackground(Color.white);
setForeground(Color.white);
JFrame f = new JFrame("Line");
f.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
f.getContentPane().add("Center", applet);
applet.init();
f.pack();
f.setSize(new Dimension(300, 300));
f.setVisible(true);
代码示例来源:origin: IanDarwin/javasrc
f = new JFrame("AppletViewer");
f.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
f.setVisible(false);
Container cp = f.getContentPane();
cp.setLayout(new BorderLayout());
cp.add(BorderLayout.SOUTH, aa);
ai.setStub(aa);
cp.add(BorderLayout.CENTER, ai);
Dimension d = ai.getSize();
d.height += aa.getSize().height;
f.setSize(d);
ai.init();
ai.start();
内容来源于网络,如有侵权,请联系作者删除!