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

x33g5p2x  于2022-01-21 转载在 其他  
字(8.0k)|赞(0)|评价(0)|浏览(342)

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

JFrame.getContentPane介绍

暂无

代码示例

代码示例来源:origin: libgdx/libgdx

public void run () {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frame.setSize(480, 320);
    frame.setLocationRelativeTo(null);
    JPanel panel = new JPanel();
    frame.getContentPane().add(panel);
    panel.add(new Slider(200, 100, 500, 0.1f, 150, 300));
    frame.setVisible(true);
  }
});

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

private void makeGUI()
{
  final JFrame f = new JFrame();
  f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  f.getContentPane().setLayout(new FlowLayout());

  // include: "class AnswerWorker" code here.
  // include: "JButton" b code here.

  f.getContentPane().add(b);
  f.getContentPane().add(new JButton("Nothing"));
  f.pack();
  f.setVisible(true);
}

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

JFrame f = new JFrame();
f.getContentPane().add(sp);

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

public void show(){
  frame = new JFrame("HDR View");
  label = new JLabel(new ImageIcon(image));
  frame.getContentPane().add(label);
  frame.setLayout(new FlowLayout());
  frame.pack();
  frame.setVisible(true);
}

代码示例来源:origin: stanfordnlp/CoreNLP

private void buildExtractButton() {
 if (extractButton == null) {
  JPanel buttonPanel = new JPanel();
  extractButton = new JButton("Run NER");
  buttonPanel.add(extractButton);
  frame.getContentPane().add(buttonPanel, BorderLayout.SOUTH);
  extractButton.addActionListener(actor);
 }
}

代码示例来源:origin: pmd/pmd

frame.getContentPane().add(containerSplitPane);
frame.setDefaultCloseOperation(exitOnClose ? JFrame.EXIT_ON_CLOSE : WindowConstants.DISPOSE_ON_CLOSE);

代码示例来源:origin: libgdx/libgdx

public void run () {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frame.setSize(480, 320);
    frame.setLocationRelativeTo(null);
    JPanel panel = new JPanel();
    frame.getContentPane().add(panel);
    panel.add(new NewSlider(200, 100, 500, 0.1f, 150, 300));
    frame.setVisible(true);
  }
});

代码示例来源:origin: apache/shiro

methodPanel.add(secureMethod3Button);
frame = new JFrame("Apache Shiro Sample Application");
frame.setSize(500, 200);
Container panel = frame.getContentPane();
panel.setLayout(new BorderLayout());
panel.add(logo, BorderLayout.NORTH);
panel.add(valuePanel, BorderLayout.CENTER);
panel.add(methodPanel, BorderLayout.SOUTH);

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

JFrame frame = new JFrame("FooRendererTest");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(mainPanel); // or whatever...
frame.pack();
frame.setLocationRelativeTo(null);  // *** this will center your app ***
frame.setVisible(true);

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

private static void createTabs(){
  tabbedPane = new JTabbedPane();
  canvasPanel1 = new JPanel();
  canvasPanel1.setLayout(new BorderLayout());
  tabbedPane.addTab("jME3 Canvas 1", canvasPanel1);
  canvasPanel2 = new JPanel();
  canvasPanel2.setLayout(new BorderLayout());
  tabbedPane.addTab("jME3 Canvas 2", canvasPanel2);
  frame.getContentPane().add(tabbedPane);
  currentPanel = canvasPanel1;
}

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

JFrame frame = new JFrame();
frame.getContentPane().setLayout(new FlowLayout());
frame.getContentPane().add(new JLabel(new ImageIcon(img)));
frame.getContentPane().add(new JLabel(new ImageIcon(img2)));
frame.getContentPane().add(new JLabel(new ImageIcon(img3)));
frame.pack();
frame.setVisible(true);
//frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // if you want the X button to close the app

代码示例来源:origin: libgdx/libgdx

public void run () {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frame.setSize(480, 320);
    frame.setLocationRelativeTo(null);
    JPanel panel = new JPanel();
    frame.getContentPane().add(panel);
    panel.add(new NewSlider(200, 100, 500, 0.1f, 150, 300));
    frame.setVisible(true);
  }
});

代码示例来源:origin: stanfordnlp/CoreNLP

public static void main(String[] args) throws IOException {
 TreeJPanel tjp = new TreeJPanel();
 // String ptbTreeString1 = "(ROOT (S (NP (DT This)) (VP (VBZ is) (NP (DT a) (NN test))) (. .)))";
 String ptbTreeString = "(ROOT (S (NP (NNP Interactive_Tregex)) (VP (VBZ works)) (PP (IN for) (PRP me)) (. !))))";
 if (args.length > 0) {
  ptbTreeString = args[0];
 }
 Tree tree = (new PennTreeReader(new StringReader(ptbTreeString), new LabeledScoredTreeFactory(new StringLabelFactory()))).readTree();
 tjp.setTree(tree);
 tjp.setBackground(Color.white);
 JFrame frame = new JFrame();
 frame.getContentPane().add(tjp, BorderLayout.CENTER);
 frame.addWindowListener(new WindowAdapter() {
  @Override
  public void windowClosing(WindowEvent e) {
   System.exit(0);
  }
 });
 frame.pack();
 frame.setVisible(true);
 frame.setVisible(true);
}

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

public static void main(String[] args) throws MalformedURLException {
   URL url = new URL("<URL to your Animated GIF>");
   Icon icon = new ImageIcon(url);
   JLabel label = new JLabel(icon);
   JFrame f = new JFrame("Animation");
   f.getContentPane().add(label);
   f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   f.pack();
   f.setLocationRelativeTo(null);
   f.setVisible(true);
 }

代码示例来源:origin: stanfordnlp/CoreNLP

private void buildContentPanel() {
 editorPane = new JEditorPane ();
 editorPane.setContentType("text/rtf");
 editorPane.addKeyListener(new InputListener());
 //    defaultAttrSet = ((StyledEditorKit)editorPane.getEditorKit()).getInputAttributes();
 StyleConstants.setFontFamily(defaultAttrSet, "Lucinda Sans");
 Document doc = new DefaultStyledDocument();
 editorPane.setDocument(doc);
 try {
  doc.insertString(0, initText, defaultAttrSet);
 } catch (Exception ex) {
  throw new RuntimeException(ex);
 }
 JScrollPane scrollPane = new JScrollPane(editorPane);
 frame.getContentPane().add(scrollPane, BorderLayout.CENTER);
 editorPane.setEditable(true);
}

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

JFrame frame=new JFrame();
frame.getContentPane().add(new JPanel());

代码示例来源:origin: libgdx/libgdx

public void run () {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frame.setSize(480, 320);
    frame.setLocationRelativeTo(null);
    JPanel panel = new JPanel();
    frame.getContentPane().add(panel);
    panel.add(new Slider(200, 100, 500, 0.1f, 150, 300));
    frame.setVisible(true);
  }
});

代码示例来源:origin: marytts/marytts

public JFrame showInJFrame(String title, int width, int height, boolean allowZoom, boolean showControls, boolean exitOnClose) {
  final JFrame main = new JFrame(title);
  int mainWidth = width;
  JScrollPane scroll = new JScrollPane(this);
  main.getContentPane().add(scroll, BorderLayout.CENTER);
  final CursorDisplayer glass = new CursorDisplayer();
  main.setGlassPane(glass);
    JPanel zoomPanel = new JPanel();
    zoomPanel.setLayout(new BoxLayout(zoomPanel, BoxLayout.Y_AXIS));
    main.getContentPane().add(zoomPanel, BorderLayout.WEST);
    zoomPanel.add(Box.createVerticalGlue());
    JButton zoomIn = new JButton("Zoom In");

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

public static void main(String[] args) {
  Rectangle box = new Rectangle(5, 10, 20, 30);

  // New stuff - Create a program window and set it up.
  JFrame window = new JFrame();

  // Tell Swing to exit the program when the program window is closed.
  window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

  // Set the window boundaries to be 300x300 on the screen, and position it 30 pixels from the top and left edges of the monitor.
  window.setBounds(30, 30, 300, 300);

  // Get the content pane of the window, and give it our own custom component.
  window.getContentPane().add(new JComponent() {  // Not a typo - this is some advanced magic called an "anonymous class".
    Rectangle myBox = box;    // Give the component a reference to our box object.
    public void paint(Graphics g) {
      g.drawRect(myBox.x, myBox.y, myBox.width, myBox.height);
    }
  });

  // Make our window appear.
  window.setVisible(true);
}

代码示例来源:origin: stanfordnlp/CoreNLP

private void buildContentPanel() {
 editorPane = new JEditorPane ();
 editorPane.setContentType("text/rtf");
 editorPane.addKeyListener(new InputListener());
 //    defaultAttrSet = ((StyledEditorKit)editorPane.getEditorKit()).getInputAttributes();
 StyleConstants.setFontFamily(defaultAttrSet, "Lucida Sans");
 Document doc = new DefaultStyledDocument();
 editorPane.setDocument(doc);
 try {
  doc.insertString(0, initText, defaultAttrSet);
 } catch (Exception ex) {
  throw new RuntimeException(ex);
 }
 JScrollPane scrollPane = new JScrollPane(editorPane);
 frame.getContentPane().add(scrollPane, BorderLayout.CENTER);
 editorPane.setEditable(true);
}

相关文章

JFrame类方法