当前位置: 首页>>代码示例>>Java>>正文


Java JFrame.getContentPane方法代码示例

本文整理汇总了Java中javax.swing.JFrame.getContentPane方法的典型用法代码示例。如果您正苦于以下问题:Java JFrame.getContentPane方法的具体用法?Java JFrame.getContentPane怎么用?Java JFrame.getContentPane使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JFrame的用法示例。


在下文中一共展示了JFrame.getContentPane方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: saveGameRecord

import javax.swing.JFrame; //导入方法依赖的package包/类
public void saveGameRecord(JFrame frame, String competidores, PvpScore pvpScore) {
    try {
        frame.validate();
        frame.repaint();            
        Container c = frame.getContentPane();
        c.validate();
        c.repaint();
        BufferedImage im = new BufferedImage(c.getWidth(), c.getHeight(), BufferedImage.TYPE_INT_ARGB);
        c.paint(im.getGraphics());
        pvpScore.setGameRecord(im);
    } catch (Exception ex) {
        Logger.getLogger(OthelloTournament.class
                .getName()).log(Level.SEVERE, null, ex);
    }
}
 
开发者ID:data-library,项目名称:jOthelloT,代码行数:16,代码来源:OthelloTournament.java

示例2: testPlot_3

import javax.swing.JFrame; //导入方法依赖的package包/类
public static void testPlot_3() {
	System.out.println("==============================================================================");
	System.out.println("plotting in your own panel , ie embedding the plot");
	System.out.println("==============================================================================");

	// explicitly create a plot
	JFrame frame = new JFrame();
	frame.setSize(new Dimension(600,600)); ///TODO
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	Container pane = frame.getContentPane();
	//JPanel pane = new JPanel();
	Figure fig1 = new Figure(pane);
	
	// simple plot (opens new window or uses existing one)
	double xVals[] = {1.0,2.0,3.0,4.0,5.0};
	double yVals[] = {1.1,2.2,3.3,4.4,5.5};
	fig1.addPlot(xVals,yVals,"curve 1");
	fig1.drawnow();
	frame.setVisible(true);
	fig1.wait(1000);
	
	// elementary layout
	fig1.setXlabel("x-axis","x-unit");
	fig1.setYlabel("y-axis","y-unit");
	fig1.setAxisTitle("My title");
	fig1.drawnow();
	frame.setVisible(true);
	fig1.wait(1000);
	
	// add another curve
	double xVals2[] = {1.0,2.0,3.0,4.0,5.0};
	double yVals2[] = {4.1,4.2,4.3,4.4,4.5};
	fig1.addPlot(xVals2,yVals2,"curve 2");
	fig1.drawnow();
	frame.setVisible(true);
	fig1.wait(3000);
}
 
开发者ID:OpenDA-Association,项目名称:OpenDA,代码行数:38,代码来源:PlotTest.java

示例3: createAndShowGUI

import javax.swing.JFrame; //导入方法依赖的package包/类
/**
 * Create the GUI and show it. For thread safety, this method should be
 * invoked from the event-dispatching thread.
 */
static void createAndShowGUI(JLabel worldLabel, JLabel statusLabel) {
	// Create and set up the window.
	JFrame frame = new JFrame("Blockworld");
	frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

	// add both labels in a vertical layout
	Container content = frame.getContentPane();
	content.setLayout(new BoxLayout(content, BoxLayout.PAGE_AXIS));
	content.add(worldLabel);
	content.add(statusLabel);

	// Display the window.
	frame.pack();
	frame.setVisible(true);

}
 
开发者ID:Ativelox,项目名称:JavaCourse,代码行数:21,代码来源:Main.java

示例4: demoMenu

import javax.swing.JFrame; //导入方法依赖的package包/类
/** Start a menu that allows the user to launch a number of demos for the 
 * JSpikeStack package.  To add a new demo to the menu:
 * 1) Add the appropriate element to the "Demos" enumerator (above);
 * 2) Add the button in demoMenu()
 * 3) Connect the enumerator element to the appropriate function in DemoLauncher through the switch statement.
 */
public static void demoMenu()
{
            
    JFrame frm=new JFrame();
    frm.setTitle("JSpikeStack demos");
    Container pane=frm.getContentPane();
    JButton button;
    
    pane.setLayout(new GridBagLayout());
    
    addDemoButton("Network Generation Demo","Read a network From XML and let it generate",Demos.GENERATE,pane);
    addDemoButton("Learning Demo","Read an AER file, initialize a random net, and run STDP learning",Demos.LEARN,pane);
    addDemoButton("Convolution Demo",  "Here we read data from the Silicon retina.  Two output layers respond to vertically and horizontally oriented features.",Demos.CONV,pane);
    addDemoButton("RC Network",  "Takes retina inputs and fires them to a smoothing network.",Demos.RCNET,pane);
    addDemoButton("Retina",  "In this demo we mimic the behaviour of a variety of types of retinal ganglion cell.",Demos.RETINA,pane);
    
    
    frm.setPreferredSize(new Dimension(500,500));
    frm.pack();
    frm.setVisible(true);
    frm.toFront();
    frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:31,代码来源:JspikeStack.java

示例5: printTexture

import javax.swing.JFrame; //导入方法依赖的package包/类
private static void printTexture() {
    f = new JFrame("Texture Printing Test");
    f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    final TexturePaintPrintingTest gpt = new TexturePaintPrintingTest();
    Container c = f.getContentPane();
    c.add(BorderLayout.CENTER, gpt);

    final JButton print = new JButton("Print");
    print.addActionListener(new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            PrinterJob job = PrinterJob.getPrinterJob();
            job.setPrintable(gpt);
            final boolean doPrint = job.printDialog();
            if (doPrint) {
                try {
                    job.print();
                } catch (PrinterException ex) {
                    throw new RuntimeException(ex);
                }
            }
        }
    });
    c.add(print, BorderLayout.SOUTH);

    f.pack();
    f.setVisible(true);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:29,代码来源:TexturePaintPrintingTest.java

示例6: go

import javax.swing.JFrame; //导入方法依赖的package包/类
private void go() {

        frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Container contentPane = frame.getContentPane();
        ButtonModel model = new DefaultButtonModel();

        JCheckBox check = new JCheckBox("a bit broken");
        check.setModel(model);
        panel = new JPanel(new BorderLayout());
        panel.add(new JTextField("Press Tab (twice?)"), BorderLayout.NORTH);
        panel.add(check);
        contentPane.add(panel);
        frame.setLocationRelativeTo(null);
        frame.pack();
        frame.setVisible(true);
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:DefaultButtonModelCrashTest.java

示例7: testPlot_5

import javax.swing.JFrame; //导入方法依赖的package包/类
public static void testPlot_5() {
	System.out.println("==============================================================================");
	System.out.println("plotting update - adding points");
	System.out.println("==============================================================================");

	// explicitly create a plot
	JFrame frame = new JFrame();
	frame.setSize(new Dimension(600,600)); ///TODO
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	Container pane = frame.getContentPane();
	Figure fig1 = new Figure(pane);
	frame.setVisible(true);
	// simple plot (opens new window or uses existing one)
	double xValsAll[] = {1.0,2.0,3.0,4.0,5.0,6.0,7.0};
	double yValsAll[] = {6.1,5.2,4.3,3.4,3.2,3.1,3.05};
	double xVals[];
	double yVals[];
	for(int i=1;i<=xValsAll.length;i++){
		xVals = new double[i];
		yVals = new double[i];
		for(int j=0;j<i;j++){ //copy relevant part
			xVals[j] = xValsAll[j];
			yVals[j] = yValsAll[j];
		}
		fig1.plot(xVals,yVals,"my curve");
		fig1.setXlabel("x-axis","x-unit");
		fig1.setYlabel("y-axis","y-unit");
		fig1.setAxisTitle("My title");
		fig1.drawnow();
		frame.setVisible(true);
	    //if(i==1){
	    //	frame.setVisible(true);
	    //}
		fig1.wait(1000);
	}
}
 
开发者ID:OpenDA-Association,项目名称:OpenDA,代码行数:37,代码来源:PlotTest.java

示例8: main

import javax.swing.JFrame; //导入方法依赖的package包/类
/**
 * a driver for this demo
 */
public static void main(String[] args) {
    JFrame frame = new JFrame();
    Container content = frame.getContentPane();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    content.add(new TreeLayoutDemo());
    frame.pack();
    frame.setVisible(true);
}
 
开发者ID:dev-cuttlefish,项目名称:cuttlefish,代码行数:13,代码来源:TreeLayoutDemo.java

示例9: JTextFieldDemo1

import javax.swing.JFrame; //导入方法依赖的package包/类
public static void JTextFieldDemo1() {

		jf = new JFrame("TextField����");

		final Container contentPane = jf.getContentPane();
		contentPane.setLayout(new BorderLayout());

		jp = new JPanel();

		jtf1 = new JTextField();
		jtf2 = new JTextField(10);
		jtf3 = new JTextField("ָ���ı�����");
		jtf4 = new JTextField("ָ������+ָ������(ֻ��״̬)", 30);

		jtf3.setEnabled(false); // true���Ա༭
		jtf4.setFont(new Font("����", Font.BOLD | Font.ITALIC, 16)); // ���壬�Ƿ�Ӵ֡�б�壬�ֺ�
		// �����ı���ˮƽ���뷽ʽ
		jtf4.setHorizontalAlignment(SwingConstants.CENTER);

		jp.add(jtf1);
		jp.add(jtf2);
		jp.add(jtf3);
		jp.add(jtf4);

		contentPane.add(jp);

		jf.pack();
		jf.setLocation(400, 200);
		jf.setVisible(true);
		jf.addWindowListener(new WindowAdapter() {
			@Override
			public void windowClosing(WindowEvent e) {
				System.exit(0);
			}
		});
	}
 
开发者ID:zylo117,项目名称:SpotSpotter,代码行数:37,代码来源:TextField.java

示例10: ProgressDialog

import javax.swing.JFrame; //导入方法依赖的package包/类
public ProgressDialog(JFrame parent) {
	
	// init frame
	m_frame = new JFrame(Constants.Name + " - Operation in progress");
	final Container pane = m_frame.getContentPane();
	FlowLayout layout = new FlowLayout();
	layout.setAlignment(FlowLayout.LEFT);
	pane.setLayout(layout);
	
	m_title = new JLabel();
	pane.add(m_title);
	
	// set up the progress bar
	JPanel panel = new JPanel();
	pane.add(panel);
	panel.setLayout(new BorderLayout());
	m_text = GuiTricks.unboldLabel(new JLabel());
	m_progress = new JProgressBar();
	m_text.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0));
	panel.add(m_text, BorderLayout.NORTH);
	panel.add(m_progress, BorderLayout.CENTER);
	panel.setPreferredSize(new Dimension(360, 50));
	
	// show the frame
	pane.doLayout();
	m_frame.setSize(400, 120);
	m_frame.setResizable(false);
	m_frame.setLocationRelativeTo(parent);
	m_frame.setVisible(true);
	m_frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
}
 
开发者ID:cccssw,项目名称:enigma-vk,代码行数:32,代码来源:ProgressDialog.java

示例11: createUI

import javax.swing.JFrame; //导入方法依赖的package包/类
public static void createUI() {
    f = new JFrame("LinearGradient Printing Test");
    f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    final LinearGradientPrintingTest gpt = new LinearGradientPrintingTest();
    Container c = f.getContentPane();
    c.add(BorderLayout.CENTER, gpt);

    final JButton print = new JButton("Print");
    print.addActionListener(new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            PrinterJob job = PrinterJob.getPrinterJob();
            job.setPrintable(gpt);
            final boolean doPrint = job.printDialog();
            if (doPrint) {
                try {
                    job.print();
                } catch (PrinterException ex) {
                    throw new RuntimeException(ex);
                }
            }
        }
    });
    c.add(print, BorderLayout.SOUTH);

    f.pack();
    f.setVisible(true);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:29,代码来源:LinearGradientPrintingTest.java

示例12: createUI

import javax.swing.JFrame; //导入方法依赖的package包/类
public static void createUI() {
    f = new JFrame("RadialGradient Printing Test");
    f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    final RadialGradientPrintingTest gpt = new RadialGradientPrintingTest();
    Container c = f.getContentPane();
    c.add(BorderLayout.CENTER, gpt);

    final JButton print = new JButton("Print");
    print.addActionListener(new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            PrinterJob job = PrinterJob.getPrinterJob();
            job.setPrintable(gpt);
            final boolean doPrint = job.printDialog();
            if (doPrint) {
                try {
                    job.print();
                } catch (PrinterException ex) {
                    throw new RuntimeException(ex);
                }
            }
        }
    });
    c.add(print, BorderLayout.SOUTH);

    f.pack();
    f.setVisible(true);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:29,代码来源:RadialGradientPrintingTest.java

示例13: main

import javax.swing.JFrame; //导入方法依赖的package包/类
/**
 * a driver for this demo
 */
public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Container content = frame.getContentPane();
    content.add(new EdgeLabelDemo());
    frame.pack();
    frame.setVisible(true);
}
 
开发者ID:dev-cuttlefish,项目名称:cuttlefish,代码行数:12,代码来源:EdgeLabelDemo.java

示例14: main

import javax.swing.JFrame; //导入方法依赖的package包/类
/**
* a driver for this demo
*/
  public static void main(String[] args) {
      JFrame frame = new JFrame();
      Container content = frame.getContentPane();
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

      content.add(new VertexImageShaperDemo());
      frame.pack();
      frame.setVisible(true);
  }
 
开发者ID:dev-cuttlefish,项目名称:cuttlefish,代码行数:13,代码来源:VertexImageShaperDemo.java

示例15: createPanel

import javax.swing.JFrame; //导入方法依赖的package包/类
/**
 * Creates an instance of JFrame {@link #panel} and adds the graph view {@link #view} to the {@link #panel}.
 * @author Shashank B S
 */
private void createPanel() {
	JFrame temp = new JFrame();
	temp.setLayout(new BorderLayout());
	panel = temp.getContentPane();
	panel.add(headerBar,BorderLayout.PAGE_START);
	panel.add(view);
	panel.add(settingsBar, BorderLayout.PAGE_END);
}
 
开发者ID:VisuFlow,项目名称:visuflow-plugin,代码行数:13,代码来源:GraphManager.java


注:本文中的javax.swing.JFrame.getContentPane方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。