javax.swing.JApplet.getContentPane()方法的使用及代码示例

x33g5p2x  于2022-01-22 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(226)

本文整理了Java中javax.swing.JApplet.getContentPane()方法的一些代码示例,展示了JApplet.getContentPane()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JApplet.getContentPane()方法的具体详情如下:
包路径:javax.swing.JApplet
类名称:JApplet
方法名:getContentPane

JApplet.getContentPane介绍

暂无

代码示例

代码示例来源: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

getContentPane().add(bp);
validate();

代码示例来源:origin: org.opencadc/cadc-app-kit

/**
 * @see ApplicationContainer#getContentPane()
 */
public Container getContentPane()
{
  return applet.getContentPane();
}

代码示例来源: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

import java.security.*;
import javax.swing.*;

public class NativeHelloApplet extends JApplet
{
  public native String displayHelloWorld();
  public native int initPKE (int[] retVal); 

  public NativeHelloApplet() {   
  }

  public void init()
  {
    // privileged code goes here, for example:
    System.loadLibrary("hello");
    getContentPane().add(new JLabel("Test"));
    getContentPane().add(new JLabel(displayHelloWorld()));
  }
}

代码示例来源:origin: stackoverflow.com

import java.awt.BorderLayout;
import javax.swing.JApplet;
public class MyJApplet extends JApplet {
  public void start() {

  }
  public void init() {
    getContentPane().setLayout(new BorderLayout());
    addContent();
  }
  public void addContent() {
    getContentPane().add(new MainGui(this), BorderLayout.CENTER);
  }
  public static void main(String[] args) {
    new MainGui(null);
  }
  private static final long serialVersionUID = 1;
}

代码示例来源:origin: stackoverflow.com

import java.lang.reflect.InvocationTargetException;
import javax.swing.*;

public class MyApplet extends JApplet {
  @Override
  public void init() {
   try {
     SwingUtilities.invokeAndWait(new Runnable() {
      public void run() {
        getContentPane().add(new MyJPanel());             
      }
     });
   } catch (InterruptedException e) {
     e.printStackTrace();
   } catch (InvocationTargetException e) {
     e.printStackTrace();
   }
  }
}

代码示例来源: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/invokeLater() 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

package m2mcom.web;
import m2mcom.entities.AutomatedTelnetClient;
import javax.swing.JApplet;
import javax.swing.SwingUtilities;
import javax.swing.JLabel;

public class Displaytext extends JApplet {
//Called when this applet is loaded into the browser.
public void init() {
  //Execute a job on the event-dispatching thread; creating this applet's GUI.
  try {

        AutomatedTelnetClient telnet = new AutomatedTelnetClient();
        String answer = telnet.request();
        JLabel lbl = new JLabel(answer);
        getContentPane().add(lbl);


  } catch (Exception e) {
    System.err.println("createGUI didn't complete successfully");
  }
}
}

代码示例来源: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/invokeLater() ensures that happens.
    Runnable r = new Runnable() {
      public void run() {
        // the crux of this simple applet
        getContentPane().add( new JLabel("Hello World!") );
      }
    };
    SwingUtilities.invokeLater(r);
  }
}

代码示例来源: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

import java.awt.*;
import javax.swing.*;

public class Applet extends JApplet {

  private JButton button1;
  private JTextField textBox1;

  @Override
  public void init() {
   button1 = new JButton("Calculate");
   textBox1 = new JTextField("number");
   textBox1.setFont(new Font("Courier", Font.PLAIN, 12));
   JPanel myPanel = new JPanel(); // JPanel uses FlowLayout by default
   myPanel.add(new JLabel("Enter a number: "));
   myPanel.add(textBox1);
   myPanel.add(button1);
   myPanel.setBackground(Color.gray);

   getContentPane().add(myPanel, BorderLayout.CENTER);
  }

}

代码示例来源: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

import java.lang.reflect.InvocationTargetException;    
import javax.swing.JApplet;
import javax.swing.SwingUtilities;

public class LifeCycleApplet extends JApplet {
  @Override
  public void init() {
   try {
     SwingUtilities.invokeAndWait(new Runnable() {
      public void run() {
        LifeCycle2 lifeCycle2 = new LifeCycle2();
        getContentPane().add(lifeCycle2.getMainPanel());
      }
     });
   } catch (InvocationTargetException | InterruptedException e) {
     e.printStackTrace();
   }
  }
}

代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

@Override
public void show(View v) {
  this.view = v;
  applet.getContentPane().removeAll();
  applet.getContentPane().add(v.getComponent());
  v.start();
  v.activate();
}

代码示例来源:origin: stackoverflow.com

import javax.swing.JApplet;

public class MyApplet extends JApplet {
  public void init() {
   try {
     javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
      public void run() {
        createGUI();
      }
     });
   } catch (Exception e) {
     System.err.println("createGUI didn't successfully complete");
   }
  }

  private void createGUI() {
   getContentPane().add(new MyPanel());
  }
}

代码示例来源:origin: arhs/sd-dss

/**
 * @param applet
 * @param container
 */
public static void updateDisplay(final JApplet applet, final Container container) {
  if (container != null) {
    final PanelBuilder builder = createBuilder(new String[]{"5dlu", "fill:default:grow", "5dlu"}, new String[]{"5dlu", "fill:default:grow", "5dlu"});
    final CellConstraints cc = new CellConstraints();
    builder.add(container, cc.xy(2, 2));
    final JPanel panel = createPanel(builder);
    panel.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, Color.GRAY));
    applet.getContentPane().removeAll();
    applet.getContentPane().add(panel);
    applet.getContentPane().validate();
    applet.getContentPane().repaint();
  }
}

代码示例来源:origin: stackoverflow.com

import java.awt.*;
import javax.swing.*;

public class Rect20degreeRotate extends JApplet{
public void init() {
 resize(500,500);

  Container DrawArea = getContentPane();
  DrawArea.add(

        new JPanel(){
      public void paintComponent(Graphics g) {
        Graphics2D g2 = (Graphics2D)g;
           int x[]={0,80,80,0};
           int y[]={0,0,50,50};
         g2.translate( 100, 100);
           for (int i=0;i<18;i++){
          g2.rotate(20.0 * Math.PI / 180.0);
          g2.drawPolygon(x,y,4);
           }                         
          }
      }
        );
}

代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

@Override
public void hide(View v) {
  v.deactivate();
  v.stop();
  applet.getContentPane().removeAll();
  this.view = null;
}

代码示例来源:origin: stackoverflow.com

/*
  A trivial applet that tests the StopWatchRunner component.
  The applet just creates and shows a StopWatchRunner.
*/

import java.awt.*;
import javax.swing.*;

public class Test1 extends JApplet {

  public void init() {

   StopWatch watch = new StopWatch();
   watch.setFont( new Font("SansSerif", Font.BOLD, 24) );
   watch.setBackground(Color.white);
   watch.setForeground( new Color(180,0,0) );
   watch.setOpaque(true);
   getContentPane().add(watch, BorderLayout.CENTER);

  }

}

相关文章