Swing之使得JFrame窗口最大化不可用方法

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/jintianhen1/article/details/11794199

这两个都是坑人的,用了效果反而不好。

1  

this.setResizable(false);


2 去掉窗口修饰

                  this.setUndecorated(true); // 去掉窗口的装饰 [本句起了作用]

 this.getRootPane().setWindowDecorationStyle(JRootPane.NONE);【这句感觉没用】


展开阅读全文

vc++ 窗口最大化方法

11-07

vc++ 窗口最大化方法rnrn一般的做法是在 C**App::InitInstance()中,修改成这样:rnrn//...rnm_pMainWnd->ShowWindow(SW_SHOWMAXIMIZED);rnm_pMainWnd->UpdateWindow();rn//...rnrn或者,还在 CMainFrame::PreCreateWindow(CREATESTRUCT& cs)中,添加:rnrn//...rncs.style |= WS_MAXIMIZE;rn//...rnrnrn这种做法能产生窗口最大化,但效果是显示的时候窗口从普通大小"闪"到最大化。还有的做法,是先将窗口隐藏,然后再最大化。那么怎样使窗口正常一开始出现就最大化?看看下面的流程,从 C**App::InitInstance()中的ProcessShellCommand(...)开始:rnrn//...rn//ProcessShellCommand中第一次显示了窗口rnif (!ProcessShellCommand(cmdInfo))rn return FALSE;rnm_pMainWnd->ShowWindow(SW_SHOWMAXIMIZED);rnm_pMainWnd->UpdateWindow();rn//...rnrnrnrn->CWinApp::ProcessShellCommand rn->AfxGetApp()->OnCmdMsg(ID_FILE_NEW, 0, NULL, NULL) rn//如果你自己处理了ID_FILE_NEW要调用CWinApp::OnFileNew()rn->CWinApp::OnFileNew()rn->CDocManager::OnFileNew() rn->CSingleDocTemplate::OpenDocumentFile //当前文档模板初始化rn->CSingleDocTemplate::CreateNewDocument //创建文档rn//加载资源并创建主窗口(顺便创建视图),但没显示rn->CSingleDocTemplate::CreateNewFrame rn->CFrameWnd::InitialUpdateFramernrn//...rnint nCmdShow = -1; // defaultrnCWinApp* pApp = AfxGetApp();rnif (pApp != NULL && pApp->m_pMainWnd == this)rnrn nCmdShow = pApp->m_nCmdShow; // use the parameter from WinMainrn pApp->m_nCmdShow = -1; // set to default after first timernrnActivateFrame(nCmdShow); //在这里第一次显示窗口rn//...rnrn->CFrameWnd::ActivateFrame(int nCmdShow)rn// nCmdShow is the normal show mode this frame should be inrnrn// translate default nCmdShow (-1)rnif (nCmdShow == -1)rnrn if (!IsWindowVisible())rn nCmdShow = SW_SHOWNORMAL;rn else if (IsIconic())rn nCmdShow = SW_RESTORE;rnrnrn// bring to top before showingrnBringToTop(nCmdShow);rnrnif (nCmdShow != -1)rnrn // show the window as specifiedrn ShowWindow(nCmdShow); //第一次显示窗口rnrn // and finally, bring to top after showingrn BringToTop(nCmdShow);rnrnrn->***rnrn从上面可以看出,CWinApp::ProcessShellCommand函数创建了窗口并显示,这是窗口第一次显示,先于:rnm_pMainWnd->ShowWindow(SW_SHOWMAXIMIZED);rnm_pMainWnd->UpdateWindow();rnrnrn怎么解决问题? 让窗口第一次显示就最大化?rnrnCCommandLineInfo cmdInfo;rnParseCommandLine(cmdInfo);rnrn// Dispatch commands specified on the command linern//在ParseCommandLine之后,ProcessShellCommand之前,添加这句!!!rnm_nCmdShow = SW_SHOWMAXIMIZED; rnif (!ProcessShellCommand(cmdInfo))rn return FALSE;rnrn// The one and only window has been initialized, so show and update it.rnm_pMainWnd->ShowWindow(SW_SHOWMAXIMIZED);rnm_pMainWnd->UpdateWindow();rn rn 论坛

JFrame窗口

09-21

package calculator;rnimport javax.swing.*; rnimport java.awt.*; rnpublic class NumberKey extends JPanel rnrn rn JButton zero = new JButton("0"); //数字键0 rn JButton one = new JButton("1"); //数字键1 rn JButton two = new JButton("2"); //数字键2 rn JButton three = new JButton("3"); //数字键3 rn JButton four = new JButton("4"); //数字键4 rn JButton five = new JButton("5"); //数字键5 rn JButton six = new JButton("6"); //数字键6 rn JButton seven = new JButton("7"); //数字键7 rn JButton eight = new JButton("8"); //数字键8 rn JButton nine = new JButton("9"); //数字键9 rnrn JButton plus = new JButton("+"); rn JButton sub = new JButton("-"); rn JButton mul = new JButton("*"); rn JButton div = new JButton("/"); rn JButton equal = new JButton("="); rn JButton ce = new JButton("清零"); //置零键 rn JButton point = new JButton(".");rn rn rn NumberKey() rn rn JFrame f=new JFrame("calculator");rn f.add(this);rn setLayout(new GridLayout(4, 4, 1, 1)); //定义布局管理器为网格布局 rnrn setBackground(Color.blue); //设置背景颜色 rn// 添加按钮 rn add(one); rn add(two); rn add(three); rn add(four); rn add(five); rn add(six); rn add(seven); rn add(eight); rn add(nine); rn add(zero); rn add(plus); rn add(sub); rn add(mul); rn add(div); rn add(point); rn add(equal); rn add(ce); rn rn rn public static void main(String args[])rn rn new NumberKey();rn rnrnrnserializable 类 NumberKey 未声明类型为 long 的静态终态 serialVersionUID 字段 one/calculator NumberKey.java 第 4 行 1222008818734 35rn这个错误是什么意思啊??rn 论坛

没有更多推荐了,返回首页