A frame is a component container that displays its contents in a top-level window with a title bar and buttons to resize, iconify, maximize, and close the frame.

Unlike most Swing containers, adding a component to a frame is not done with the JFrame.add() method. This is because the frame holds several panes and it is necessary to specify a particular pane to which to add the component. The pane that holds child components is called the content pane. This example adds a text area to the content pane of a frame.

See also e559 创建窗口.

    // Create the frame
String title = "Frame Title";
JFrame frame = new JFrame(title); // Create a component to add to the frame
JComponent comp = new JTextArea(); // Add the component to the frame's content pane;
// by default, the content pane has a border layout
frame.getContentPane().add(comp, BorderLayout.CENTER); // Show the frame
int width = 300;
int height = 300;
frame.setSize(width, height);
frame.setVisible(true);
Related Examples

e559. 创建窗口的更多相关文章

  1. Duilib创建窗口双击标题栏禁止窗口最大化

    使用Duilib创建窗口并禁止窗口最大化 第一步: XXXFrame.Create(NULL, _T("XXXFrame"), UI_WNDSTYLE_EX_FRAME, WS_E ...

  2. QT源码解析(一) QT创建窗口程序、消息循环和WinMain函数

    QT源码解析(一) QT创建窗口程序.消息循环和WinMain函数 分类: QT2009-10-28 13:33 17695人阅读 评论(13) 收藏 举报 qtapplicationwindowse ...

  3. MFC程序的启动过程——先全局对象theApp(第一入口),后WinMain(真正入口),会引爆pApp->InitInstance从而创建窗口(程序员入口)

    原文出自:http://blog.csdn.net/yuvmen/article/details/5877271 了解MFC程序的启动过程,对于初学者来讲,了学习MFC很有帮助:对于不常用VC的人来说 ...

  4. MFC应用程序创建窗口的过程 good

    MFC应用程序中处理消息的顺序 1.AfxWndProc()      该函数负责接收消息,找到消息所属的CWnd对象,然后调用AfxCallWndProc 2.AfxCallWndProc()  该 ...

  5. windows程序设计读书笔记1——创建窗口

    第一个win32程序,简单的创建窗口: #include <windows.h> LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ...

  6. 【C语言探索之旅】 第三部分第二课:SDL开发游戏之创建窗口和画布

    内容简介 1.第三部分第二课: SDL开发游戏之创建窗口和画布 2.第三部分第三课预告: SDL开发游戏之显示图像 第三部分第二课:SDL开发游戏之创建窗口和画布 在上一课中,我们对SDL这个开源库做 ...

  7. Example003通过按钮创建窗口

    <!--实例003通过按钮创建窗口--> <head> <meta charset="UTF-8"> </head> <for ...

  8. Win32 SDK 编程开始, 创建窗口, 消息的处理, 消息循环

    Windows SDK 编程的一般步骤为: 1. 注册窗口类, 使用到的结构 WNDCLASSEX, 函数 RegisterClassEx. 2. 创建窗口, 函数 CreateWindowEx. 3 ...

  9. emwin之在中断服务程序中创建窗口的结果

    @2019-04-28 [小记] 使用emwin设计器生成的程序,将该窗口创建放在中断服务程序中出现奇怪现象,非死机但功能间歇性异常,将创建窗口程序放于普通程序中则工作正常

随机推荐

  1. Function.apply()在提升程序性能方面的技巧

    我们先从Math.max()函数说起,Math.max后面可以接任意个参数,最后返回所有参数中的最大值. 比如 alert(Math.max(5,8))   //8alert(Math.max(5,7 ...

  2. matlab: Attempt to execute SCRIPT *** as a function 错误

    编写matlab程序时,出现了“Attempt to execute SCRIPT mean as a function”,其实这是“Attempt to execute SCRIPT *** as ...

  3. javascript基础拾遗(十)

    1.支持ES6标准的浏览器 IE10+ Chrome Safari Firefox 移动端浏览器统一都支持 需要注意的是,不同浏览器对各个特性的支持也不一样 2.window对象 当前浏览器窗口对象 ...

  4. Tips for Navigating Large Game Code Bases

    http://solid-angle.blogspot.com/2015/08/tips-for-navigating-large-game-code.html

  5. android开发图片分辨率

    一直受到android开发图片分辨率问题困扰.drawable-(xdpi,hdpi,mdpi,ldpi,nodpi)这几个文件夹到底怎么放图片呢? dpi是什么呢? dpi是“dot per inc ...

  6. [DIOCP3-IocpTask说明书]基于IOCP引擎的多线程任务的投递和回调处理单元

    [说明] IocpTask是基于Iocp引擎的多线程任务投递和处理单元,可以方便的把任务进行投递到IOCP线程进行统一调度和处理,是模仿QDAC-QWorker的处理方式,支持D7以上的版本. [使用 ...

  7. 第二章 使用接口(Using Interfaces)-书籍翻译

    PDF预览 下载地址 http://files.cnblogs.com/DKSoft/CodingInDelphi.pdf 1.1. 解耦(Decoupling) All through this b ...

  8. webpack打包调试react并使用babel编译jsx配置方法

    http://lxj8749.iteye.com/blog/2287074 ********************************************** 安装webpack npm i ...

  9. mysql 通过echo的方式写入数据库 中文乱码解决方案

    echo "set names utf8;insert into xxx (path, sn, time, flag) values ('$wav', '$sn', '$secs', 'op ...

  10. win7 LR11.0 启动controller报:Failed to create Online:无效指针

    win7 LR11.0 启动controller报:Failed to create Online:无效指针 运行lr setup.exe 进行修复后问题解决 修复完成后,覆盖lr安装目录“bin”文 ...