本文整理了Java中javax.swing.JApplet
类的一些代码示例,展示了JApplet
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JApplet
类的具体详情如下:
包路径:javax.swing.JApplet
类名称:JApplet
暂无
代码示例来源:origin: org.swinglabs.swingx/swingx-core
/**
* {@inheritDoc}
*/
@Override
public JXRootPane getRootPane() {
return (JXRootPane) super.getRootPane();
}
代码示例来源:origin: stackoverflow.com
getContentPane().add(bp);
validate();
SwingUtilities.invokeLater(new Runnable() {
public void run() {
JFrame f = new JFrame("Beeper");
setPreferredSize( new Dimension(300,300) );
options.setLayout(bl);
harmonic.addActionListener( new ActionListener(){
public void actionPerformed(ActionEvent ae) {
setUpSound();
frequency = new JLabel();
JButton bPlay = new JButton("Code Key");
bPlay.addKeyListener( new KeyAdapter(){
@Override
public void keyPressed(KeyEvent ke) {
bPlay.addMouseListener( new MouseAdapter() {
@Override
public void mousePressed(MouseEvent me) {
harmonic.setSelected(addHarmonic);
代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw
/**
* Same as <code>Applet.getParameter()</code> but doesn't throw a
* NullPointerException when used without an Applet context.
*/
@Override
public String getParameter(String name) {
try {
return super.getParameter(name);
} catch (NullPointerException e) {
return null;
}
}
代码示例来源:origin: stackoverflow.com
Container PW = getContentPane();
JLabel password = new JLabel("Enter Password(and click OK):");
JLabel message = new JLabel();
Font font1 = new Font("Times New Roman", Font.BOLD, 18);
JTextField input = new JTextField(7);
JButton enter = new JButton("OK");
PW.add(password);
password.setFont(font1);
PW.add(input);
PW.add(enter);
PW.add(message);
PW.setLayout(new FlowLayout());
enter.addActionListener(this);
for(int i=0;i<passwords.length;i++) {
if (pass1.equalsIgnoreCase(passwords[i])) {
message.setText("Access Granted");
return;
代码示例来源:origin: stackoverflow.com
private JButton button = new JButton();
JLabel greeting = new JLabel("Welcome to Alien Hunt Game!");
JLabel gameOverMessage = new JLabel(" ");
JPanel displayPanel = new JPanel(new GridLayout(2, 4));
private int[] alienArray = new int[8];
private ImageIcon image = new ImageIcon("earth.jpg");
private int width, height;
Container con = getContentPane();
Font aFont = new Font("Gigi", Font.BOLD, 20);
height = image.getIconHeight();
greeting.setFont(aFont);
greeting.setHorizontalAlignment(SwingConstants.CENTER);
con.setLayout(new BorderLayout());
con.add(greeting, BorderLayout.NORTH);
con.add(displayPanel, BorderLayout.CENTER);
displayPanel.add(button);
button.setText("!");
button.addActionListener(this);
button.setEnabled(false);
con.remove(greeting);
displayPanel.remove(button);
代码示例来源:origin: stackoverflow.com
JLabel Dep1=new JLabel("Department 1");
JTextField atext1=new JTextField(5);
JLabel Dep2=new JLabel("Department 2");
JTextField atext2=new JTextField(5);
JLabel Dep3=new JLabel("Department 3");
JTextField atext3=new JTextField(5);
JLabel Dep4=new JLabel("Department 4");
JLabel Dep5=new JLabel("Department 5");
JTextField atext5=new JTextField(5);
JButton but1=new JButton("Average"); //button 1
JButton but2=new JButton("Clear Fields"); //button 2
Frame c1 = (Frame)this.getParent().getParent();
c1.setTitle("Hello World");
c=getContentPane();
c.setLayout(flow);
c.setBackground(Color.white);
c.add(average);
but1.addActionListener(this);
but2.addActionListener(this);
代码示例来源:origin: stackoverflow.com
package com.evanmallory;
import java.awt.*;
import javax.swing.*;
public class TellTime extends JApplet {
private JLabel mMessage;
public TellTime() {
SwingUtilities.invokeLater( new Runnable() {
public void run() {
mMessage = new JLabel("Set the clock to the given time.",
SwingConstants.CENTER);
mMessage.setFont(new Font("Serif", Font.PLAIN, 36));
getContentPane().add(mMessage);
}
});
}
}
代码示例来源:origin: stackoverflow.com
panelChoice.setBackground(Color.white);
panelChoice.addItem("FlowLayout"); // Add in the names of the cards.
panelChoice.addItem("FlowLayout with Big Hgap");
panelChoice.addItemListener(this);
cardPanel.setBackground(Color.white);
cards = new CardLayout();
cardPanel.setLayout(cards);
setBackground(Color.blue);
getContentPane().setBackground(Color.blue);
getContentPane().setLayout(new BorderLayout(3,3));
getContentPane().add("Center",cardPanel);
getContentPane().add("North",panelChoice);
getContentPane().add("South",message);
JButton b = new JButton(name);
p.add(b);
b.addActionListener(this);
JButton b = new JButton(name);
p.add(b, option);
b.addActionListener(this);
message.setText("Button \"" + buttonName + "\" was pressed.");
message.setText("Panel \"" + panelName + "\" was selected.");
代码示例来源:origin: net.java.dev.jets3t/jets3t
@Override
public void init() {
Container content = getContentPane();
content.setLayout(new BorderLayout());
grid.add(portLabel);
grid.validate();
content.add(grid, BorderLayout.CENTER);
JButton button = new JButton("Detect Proxy");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
SwingUtilities.invokeLater(new Runnable() {
content.add(buttonPanel, BorderLayout.SOUTH);
validate();
super.setSize(400,100);
代码示例来源:origin: stackoverflow.com
SwingUtilities.invokeLater(new Runnable()
JLabel noNodeLabel = new JLabel("Enter the No. of Nodes :", JLabel.LEFT);
noNodeField = new JTextField(5);
JLabel timeSimLabel = new JLabel("Enter time of Simulation :", JLabel.LEFT);
timeSimField = new JTextField(5);
JLabel iniEngLabel = new JLabel("Initial Energy Of Each Sensor Node :", JLabel.LEFT);
iniEngField = new JTextField("10^-4 Joules");
distPattCombo = new JComboBox(selectionModelString);
runSimButton = new JButton("Run Simulation");
logButton = new JButton("View Log");
detailNodeButton = new JButton("Details of Node");
JComponent contentPane = (JComponent) getContentPane();
topPanel.add(distPattCombo);
JPanel buttonPanel = new JPanel();
buttonPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
buttonPanel.setLayout(new GridLayout(0, 1, 5, 5));
contentPane.add(mainPanel, BorderLayout.PAGE_START);
setSize(1000, 600);
代码示例来源:origin: stackoverflow.com
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
TestClass test = new TestClass();
JPanel contentPane = (JPanel) getContentPane();
contentPane.add(test);
contentPane.addAncestorListener(new RequestFocusListener());
public void ancestorAdded(AncestorEvent aEvt) {
Component comp = (Component) aEvt.getSource();
comp.requestFocusInWindow();
class TestClass extends JPanel {
public TestClass() {
setLayout(new BorderLayout());
add(new JLabel("TestClass", SwingUtilities.CENTER));
InputMap inputMap = getInputMap(condition);
ActionMap actionMap = getActionMap();
代码示例来源:origin: stackoverflow.com
SwingUtilities.invokeLater(new Runnable(){public void run() {
label = new JLabel("inited.");
getContentPane().setLayout(new FlowLayout());
getContentPane().add(label);
}});
public void start() {
System.out.println("start()");
label.setText("started.");
public void stop() {
System.out.println("stop()");
label.setText("stopped.");
代码示例来源:origin: stackoverflow.com
private JButton b = new JButton("Ok");
list = new JList(defaultListModel);
final JLabel label = new JLabel(image);
down.setBorder(BorderFactory.createEmptyBorder(100, 100, 100, 100));
down.add(label);
panel.add(c);
panel.add(b);
Container cp = getContentPane();
cp.add(list, BorderLayout.CENTER);
cp.add(down, BorderLayout.PAGE_END);
this.setVisible(true);
b.addActionListener(
label.setIcon(infoIcon);
label.setIcon(null);
代码示例来源:origin: stackoverflow.com
label = new JLabel();
label.setHorizontalAlignment(SwingConstants.CENTER );
label.setOpaque(true); // So label draws the background color
if (font != null) label.setFont(Font.decode(font));
if (foreground != null) label.setForeground(Color.decode(foreground));
if (background != null) label.setBackground(Color.decode(background));
if (imageURL != null) {
label.setIcon(new ImageIcon(image));
getContentPane().add(label, BorderLayout.CENTER);
addMouseListener(this);
代码示例来源:origin: stackoverflow.com
/* <!-- Defines the applet element used by the appletviewer. -->
<applet code='HelloWorld' width='200' height='100'></applet> */
import javax.swing.*;
/** An 'Hello World' Swing based applet.
To compile and launch:
prompt> javac HelloWorld.java
prompt> appletviewer HelloWorld.java */
public class HelloWorld extends JApplet {
public void init() {
// Swing operations need to be performed on the EDT.
// The Runnable/invokeAndWait(..) ensures that happens.
Runnable r = new Runnable() {
public void run() {
// the crux of this simple applet
getContentPane().add( new JLabel("Hello World!") );
}
};
SwingUtilities.invokeAndWait(r);
}
}
代码示例来源:origin: stackoverflow.com
JPanel cp=new JPanel();
Container cont = getContentPane();
cont.setLayout(new GridBagLayout());
add(cp);
pb.setStringPainted(true);
JLabel l=new JLabel("Name of product");
JButton b=new JButton("Send a message");
b.setEnabled(true);
cp.add(c);
cp.add(pb);
cp.add(l);
代码示例来源:origin: stackoverflow.com
import java.awt.*;
import javax.swing.*;
public class DemoJTextFieldWithLimit extends JApplet{
JTextField textfield1;
JLabel label1;
public void init() {
getContentPane().setLayout(new FlowLayout());
//
label1 = new JLabel("max 10 chars");
textfield1 = new JTextField(15);
getContentPane().add(label1);
getContentPane().add(textfield1);
textfield1.setDocument
(new JTextFieldLimit(10));
}
}
代码示例来源:origin: stackoverflow.com
// AnimationApplet.java
// The classic animation applet rewritten to use an animated GIF.
//
import javax.swing.*;
public class AnimationApplet extends JApplet {
public void init() {
ImageIcon icon = new ImageIcon("images/rolling.gif"); // animated gif
getContentPane().add(new JLabel(icon));
}
}
代码示例来源:origin: stackoverflow.com
JLabel st1 = new JLabel("Enter a string: ");
JTextField str1 = new JTextField(8);
JLabel st2 = new JLabel("Enter a string: ");
JTextField str2 = new JTextField(8);
JLabel equals = new JLabel(" ");
JLabel compare = new JLabel(" ");
JLabel results = new JLabel(" ");
Container c = getContentPane();
c.setLayout(flow);
c.setBackground(Color.lightGray);
st1.setForeground(Color.blue);
c.add(st1);
str1.setForeground(Color.blue);
c.add(str1);
st2.setForeground(Color.blue);
c.add(st2);
str2.setForeground(Color.blue);
代码示例来源:origin: stackoverflow.com
@Override
public void init() {
getContentPane().add(new SimpleAppletMainPanel());
private static final Stroke CIRCLE_STROKE = new BasicStroke((float)CIRCLE_STROKE_WIDTH);
private JTextField textField = new JTextField(5);
private JButton myButton = new JButton("Submit");
private int count = 0;
try {
count = Integer.parseInt(textField.getText());
repaint();
} catch (NumberFormatException e) {
e.printStackTrace();
myButton.addActionListener(actionListener);
textField.addActionListener(actionListener);
add(new JLabel("Enter a number, 1-10:"));
add(textField);
add(myButton);
int centerX = getWidth() / 2;
int centerY = getHeight() / 2;
int radius = layer * (CIRCLE_STROKE_WIDTH + GAP) + GAP;
int x = centerX - radius ;
内容来源于网络,如有侵权,请联系作者删除!