e826. 获得和设置JSplitPane分开的位置

Thelocationofadividerismeasuredinpixelsfromeithertheleftedge(inthecaseofahorizontalsplitpane)orthetopedge(inthecaseofaverticalsplitpane).Therearetwowaystosetthelocationofthedivider.Thefirstistospecifyanabsolutelocationbasedonthedistanceinpixelsfromtheleftortopedge.Thesecondistospecifyaproportionallocationbasedonthedistancefromtheleftortopedge.Forexample,aproportionallocationof0setsthedividerattheleftortopedge.Aproportionallocationof1setsthedividerattherightorbottomedge.Aproportionallocationof.5s...

e788. 取消JSpinner的键盘编辑能力

//CreateanummberspinnerJSpinnerspinner=newJSpinner();//DisablekeyboardeditsinthespinnerJFormattedTextFieldtf=((JSpinner.DefaultEditor)spinner.getEditor()).getTextField();tf.setEditable(false);//Thepreviouscallsetsthebackgroundtoadisabled//color(usuallygray).Tochangethisdisabledcolor,//resetthebackgroundcolor.tf.setBackground(Color.white);//Thevalueofthespinnercanstillbeprogrammaticallychangedspinner.setValue(newInteger(100)); RelatedExamples...

e790. 设置JSpinner的边框

//CreateanumberspinnerJSpinnerspinner=newJSpinner();//GetthetextfieldJFormattedTextFieldtf=((JSpinner.DefaultEditor)spinner.getEditor()).getTextField();//Setthemargin(addtwospacestotheleftandrightsideofthevalue)inttop=0;intleft=2;intbottom=0;intright=2;Insetsinsets=newInsets(top,left,bottom,right);tf.setMargin(insets); RelatedExamples...
代码星球 代码星球·2021-02-12

e789. 限制用JSpinner实现数字选择的值

//Createanumberspinnerthatonlyhandlesvaluesintherange[0,100]intmin=0;intmax=100;intstep=5;intinitValue=50;SpinnerModelmodel=newSpinnerNumberModel(initValue,min,max,step);JSpinnerspinner=newJSpinner(model); RelatedExamples...

e787. 用JSpinner实现小时选择

//CreateacalendarobjectandinitializetoaparticularhourifdesiredCalendarcalendar=newGregorianCalendar();calendar.set(Calendar.HOUR_OF_DAY,13);//1pm//CreateadatespinnerthatcontrolsthehoursSpinnerDateModeldateModel=newSpinnerDateModel(calendar.getTime(),null,null,Calendar.HOUR_OF_DAY);JSpinnerspinner=newJSpinner(dateModel);//GetthedateformatterJFormattedTextFieldtf=((JSpinner.DefaultEditor)spinner.getEditor()).getTextField();DefaultFormatterFactoryfactory=(DefaultFormatterFactory)tf.getFormatterFact...

e793. 监听JSpinner数据变化

//CreateanummberspinnerJSpinnerspinner=newJSpinner();//Addthelistenerspinner.addChangeListener(newSpinnerListener());//Changingthevalueprogrammaticallyalsofiresaneventspinner.setValue(newInteger(100));publicclassSpinnerListenerimplementsChangeListener{publicvoidstateChanged(ChangeEventevt){JSpinnerspinner=(JSpinner)evt.getSource();//GetthenewvalueObjectvalue=spinner.getValue();}} RelatedExamples...

e791. 为JSpinner定制编辑器

Thisexamplereplacesthedefaulteditor(aJFormattedTextField)inaspinnercomponentwithacustomeditor.Thecustomeditorissimplyapanelthatdisplaysacolor.ThenameofthecolortodisplayisstoredinaSpinnerListModel.//CreateacolorspinnerColorSpinnerspinner=newColorSpinner(newString[]{"red","green","blue"});//Changetheselectedcolorspinner.setValue("blue");publicclassColorSpinnerextendsJSpinner{publicColorSpinner(String[]colorNames){super();setModel(newSpinnerListModel(colorNames));setEditor(newEditor(this));}publicc...

e786. 创建JSpinner组件

Thisexampledemonstrateshowtobuildthreekindsofspinners.Anumberspinner://CreateanumberspinnerJSpinnerspinner=newJSpinner();//Setitsvaluespinner.setValue(newInteger(100));Alistspinner://CreatealistspinnerSpinnerListModellistModel=newSpinnerListModel(newString[]{"red","green","blue"});spinner=newJSpinner(listModel);//Setitsvaluespinner.setValue("blue");Adatespinner://CreateadatespinnerSpinnerDateModeldateModel=newSpinnerDateModel();spinner=newJSpinner(dateModel);//Setitsvaluetojan12000Calendarcalend...
代码星球 代码星球·2021-02-12

在jsp中,page指令的()属性用来引入需要的包或类。

在jsp中,page指令的()属性用来引入需要的包或类。 A、extends B、import C、language D、contentType 解答:B...

有关JSP隐式对象,以下( )描述正确。

  A.隐式对象是WEB容器加载的一组类的实例,可以直接在JSP页面使用 B.不能通过config对象获取ServletContext对象 C.response对象通过sendRedirect方法实现重定向 D.只有在出错处理页面才有exception对象 解答:ACD...

考虑下面两个JSP文件代码片断: test1.jsp:

<HTML> <BODY> <%pageContext.setAttribute(”ten”,newInteger(10));%> //1 </BODY> </HTML> test2.jsp: 数字为:<%=pageContext.getAttribute(”ten”)%> 以下()放置在test1.jsp中的//1处,当请求test1.jsp时正确输出test2.jsp中的内容。 A.<jsp:includepage=”test2.jsp”/> B.<jsp:forwordpage=”test2.jsp”/> C.<%@includefile=”test2.jsp”%> D.由于pageContext对象的scope属性为page,所以test2.jsp不能访问test1.jsp定义的属性 解答:C pageContextsetAttrib...

下列JSP代码:

下列JSP代码: <html> <body> <% for(inti=0;i<10;i++){ //1 } %> </body> </html> 以下()可放置在//1处,不会发生编译错误。 A<%=i%> B<b>i</b> C%><%=i%><% D不写任何内容 解答:CD...
代码星球 代码星球·2021-02-11

假设A.jsp内设定一个<jsp:useBean>元素:

假设A.jsp内设定一个<jsp:useBean>元素: <jsp:useBeanid=”bean1”class=”myBean”/> 下列哪一个为真?(选择1项) A.bean1的存取范围(scope)默认为application B.在HTTP会话内可以存取bean1 C.只有在A.jsp内可以存取bean1 D.在A.jsp所属的Web应用程序内均可存取bean1 解答:C...

察看下列JSP内容

察看下列JSP内容 <html><body> <%for(inti=0;i<3;i++){%> out.print(i*2); <%}%> </body></html> 当这个JSP被运行时,其结果是什么?(选择1项) A.此JSP因为语法错误,无法运行 B.显示出0,2,4 C.显示出0,2,4,6 D.显示出out.print(i*2)out.print(i*2)out.print(i*2) 解答:D...
代码星球 代码星球·2021-02-11

下列哪个为JSP的小脚本的标签?(选择1项)

下列哪个为JSP的小脚本的标签?(选择1项) A.<%%> B.<@%> C.<%!%> D.<%–%> 解答:A...
首页上一页...34567...下一页尾页