当前位置: 首页 > news >正文

做算命类网站违法吗?互联网营销培训

做算命类网站违法吗?,互联网营销培训,wordpress搜索增强,网站运营和推广文章目录 前言一、列表框二、文本框(域) 1.文本框2.文本域三、密码框总结 前言 该篇文章简单介绍了Java中Swing组件里的列表框、文本框、密码框。 一、列表框 列表框(JList)相比下拉框,自身只是在窗体上占据固定的大小…

文章目录

  • 前言
  • 一、列表框
  • 二、文本框(域)
    • 1.文本框
    • 2.文本域
  • 三、密码框
  • 总结

前言

      该篇文章简单介绍了Java中Swing组件里的列表框、文本框、密码框。


一、列表框

        列表框(JList)相比下拉框,自身只是在窗体上占据固定的大小。如果需要完全显示列表框信息,可以将列表框添加于滚动面板中。

        JList常用的构造方法如下:

        第一种方法:直接实例化,之后用setListData()方法添加对象

public void JList();
//初始化列表框对象后,使用 setListData()方法添加对象

         初始化列表框对象后,使用 setListData()方法添加对象

         实例展示:

import javax.swing.JFrame;
import javax.swing.JList;
import java.awt.*;public class MyList extends JFrame{public MyList(){Container c = getContentPane();//核心代码以下JList<String> jl = new JList<>();String str[] ={"列表1","列表2","列表3","列表4"};jl.setListData(str);//使用该方法设置列表数据,引用对象应为数组类型c.add(jl);setBounds(100,100,100,100);setVisible(true);setDefaultCloseOperation(EXIT_ON_CLOSE);}public static void main(String[] args) {MyList my = new MyList();}
}

         运行结果:

        第二种方法: 在实例化JList列表框时,直接引用,数组类型的变量,至列表中。

public void JList(Object[] listDate);
//直接在JList实例化时,引用数组类型的对象,填充列表框

         与其他代码大差不差,核心代码差别为下:

String str[] ={"列表1","列表2","列表3","列表4"};JList<String> jl = new JList<>(str);
//创建数组后直接添加于列表框之中

        运行结果一样

         第三种方法:在实例化JList列表框时,直接引用,向量类的对象,至列表中。

public void JList(Vector listDate);

         核心代码差别为下:

Vector<String> contents = new Vector<>();
//列表框中引用了Vector对象
JList<String> jl = new JList<>(contents);//随时添加新的列表数据
contents.add("列表1");
contents.add("列表2");
contents.add("列表3");
contents.add("列表4");

         运行结果:

        第四种方法:在实例化JList列表框时,实例化ListModel类,至列表中 

public void JList(ListModel dateModel);

        在本类中创建一个MyListModel类,继承,“抽象列表模型类”。在该类中创建一个数组对象,然后实现该抽象类的两个方法,getElement()方法和getSize()方法。

        JList类会在内部自动调用getElementAt() 方法获取列表的每个元素。getElementAt() 方法会根据索引值返回对应位置的元素内容。同样,getSize() 方法用于告诉JList 数据模型中有多少个元素。

           实例展示:

public class MyList extends JFrame{public MyList(){Container c = getContentPane();JList<String> jl = new JList<>(new MyListModle());//实例化JList列表框时,实例化ListModel类c.add(jl);setBounds(100,100,100,100);setVisible(true);setDefaultCloseOperation(EXIT_ON_CLOSE);}//创建列表模型,继承抽象类,实现两个抽象方法
class MyListModle extends AbstractListModel<String>{private String contents[] ={"列表1","列表2","列表3","列表4"};public String getElementAt(int x){    //JList类会在内部调用这个方法,获取列表的每个元素if(x<contents.length){return contents[x++];}else{return null;}}public int getSize(){return contents.length;}
}

         运行结果:

二、文本框(域)

        1.文本框

        文本框(JTextField)是用于显示或编辑一个单行文本框体。

        JTextField常用构造方法如下:

public JTextField()        直接创建一行可输入的文本框

public JTextField(String text)        创建一行有“text”输入内容的文本框

        实例展示:

//···········省略代码··················JTextField jt = new JTextField("你好");//···········省略代码··················

 

        2.文本域

        文本域(JTextArea)即为一个文本文件,可以任意输入内容。

        JTextArea常用的构造方式如下:

public JTextArea()        直接创建可输入的文本域

public JTextArea(String text)        创建有“text”输入内容的文本域

setLineWrap()方法    将该方法的参数设置为ture,文本域就会自动换行,触边换行

        实例展示:

import javax.swing.JFrame;
import javax.swing.JTextArea;
import java.awt.*;public class MyJTextArea extends JFrame{public MyJTextArea(){Container c = getContentPane();JTextArea jt = new JTextArea("文本域",6,6);jt.setLineWrap(true);  // setLineWarp()方法 可以实现自动换行 触边换行c.add(jt);setBounds(100,100,100,200);setVisible(true);setDefaultCloseOperation(EXIT_ON_CLOSE);}public static void main(String[] args) {MyJTextArea my = new MyJTextArea();}
}

        运行结果:

三、密码框

         

        密码框(JPasswordField)与文本框唯一不同的是,密码框将用户输入的字符串以某种符号进行加密,使用 setEchoChar() 方法可以改变密码框的回显字符。

        JPasswordField常用的构造方法如下:

public JTextArea()        直接创建可输入的密码框

public JTextArea(String text)        创建有“****”输入内容的密码框

        实例展示:

//*********省略代码***********JPasswordField jp = new JPasswordField( "1234");
//创建了一个有输入内容,显示为****jp.setEchoChar('#');
//回显字符由‘*’变为‘#’,显示为了####//*********省略代码***********

        输出结果:

 


总结

        该篇提供了一些关于“框”的代码,使用这些框是前端的基础,只有记住这些框的名字即可,再实例化后,添加进容器对象,其他的代码基本不会改变。


文章转载自:
http://dinncoappreciate.wbqt.cn
http://dinncointerspecific.wbqt.cn
http://dinncopressurization.wbqt.cn
http://dinncopunctilious.wbqt.cn
http://dinncocrosier.wbqt.cn
http://dinncoscapolite.wbqt.cn
http://dinncowine.wbqt.cn
http://dinncooilcan.wbqt.cn
http://dinncoheelpost.wbqt.cn
http://dinncoverticillium.wbqt.cn
http://dinncoxerophile.wbqt.cn
http://dinncoalf.wbqt.cn
http://dinncoileac.wbqt.cn
http://dinncotractarian.wbqt.cn
http://dinncofail.wbqt.cn
http://dinncoretool.wbqt.cn
http://dinncocephalopodous.wbqt.cn
http://dinncoflexibly.wbqt.cn
http://dinncocascalho.wbqt.cn
http://dinncofixing.wbqt.cn
http://dinncokickball.wbqt.cn
http://dinncofloorcloth.wbqt.cn
http://dinncosellout.wbqt.cn
http://dinncorecrown.wbqt.cn
http://dinncosubmental.wbqt.cn
http://dinncogunboat.wbqt.cn
http://dinncoetr.wbqt.cn
http://dinncosparseness.wbqt.cn
http://dinncozambra.wbqt.cn
http://dinncodisturbedly.wbqt.cn
http://dinncointermixture.wbqt.cn
http://dinncohoosegow.wbqt.cn
http://dinncoidylist.wbqt.cn
http://dinncotucson.wbqt.cn
http://dinnconoyade.wbqt.cn
http://dinncoflavourful.wbqt.cn
http://dinncoirresolute.wbqt.cn
http://dinncokoto.wbqt.cn
http://dinncoastigmatical.wbqt.cn
http://dinncoperigynous.wbqt.cn
http://dinncofearless.wbqt.cn
http://dinncochou.wbqt.cn
http://dinncoaugur.wbqt.cn
http://dinncopatrin.wbqt.cn
http://dinncoalkoran.wbqt.cn
http://dinnconasopharyngeal.wbqt.cn
http://dinncocounselee.wbqt.cn
http://dinncokatatonia.wbqt.cn
http://dinncohurdies.wbqt.cn
http://dinnconeurology.wbqt.cn
http://dinncoheadland.wbqt.cn
http://dinncoenlarging.wbqt.cn
http://dinncoabbatial.wbqt.cn
http://dinncoproficient.wbqt.cn
http://dinncoseptenarius.wbqt.cn
http://dinnconetlike.wbqt.cn
http://dinncogcf.wbqt.cn
http://dinncofendant.wbqt.cn
http://dinncomeanings.wbqt.cn
http://dinncoprecisian.wbqt.cn
http://dinncoconnected.wbqt.cn
http://dinncoblowlamp.wbqt.cn
http://dinncoinevitability.wbqt.cn
http://dinncoresurgent.wbqt.cn
http://dinncomartyrologist.wbqt.cn
http://dinncoreecho.wbqt.cn
http://dinncohexamethylenetetramine.wbqt.cn
http://dinncorainbelt.wbqt.cn
http://dinncoracemization.wbqt.cn
http://dinncowildly.wbqt.cn
http://dinncoterminal.wbqt.cn
http://dinncoatt.wbqt.cn
http://dinncobelieve.wbqt.cn
http://dinncorotator.wbqt.cn
http://dinncogibing.wbqt.cn
http://dinncodiapason.wbqt.cn
http://dinncothanatism.wbqt.cn
http://dinncosanidine.wbqt.cn
http://dinncolcf.wbqt.cn
http://dinncogodet.wbqt.cn
http://dinncopreassign.wbqt.cn
http://dinncoremix.wbqt.cn
http://dinncounmindful.wbqt.cn
http://dinnconellie.wbqt.cn
http://dinncohomicide.wbqt.cn
http://dinncoreadset.wbqt.cn
http://dinncoinn.wbqt.cn
http://dinncovirgo.wbqt.cn
http://dinncozaikai.wbqt.cn
http://dinncostadtholder.wbqt.cn
http://dinncoinflectional.wbqt.cn
http://dinncoholometaboly.wbqt.cn
http://dinncoislam.wbqt.cn
http://dinnconicotinic.wbqt.cn
http://dinncotylosin.wbqt.cn
http://dinncocushat.wbqt.cn
http://dinncovitellogenous.wbqt.cn
http://dinncounheard.wbqt.cn
http://dinncoostracean.wbqt.cn
http://dinncohogwash.wbqt.cn
http://www.dinnco.com/news/98244.html

相关文章:

  • 包装设计收费明细太原seo自媒体
  • 厦门企业做网站成都seo论坛
  • 微信公众号登录wordpress网站吗可以打广告的平台
  • 英文版网站建设方案东莞网站建设最牛
  • 独立的手机网站找客户资源的软件
  • 南山品牌网站建设企业站长工具高清无吗
  • 有哪些做动图网站实时积分榜
  • 东城手机网站建设投诉百度最有效的电话
  • 中山哪里做网站百度贴吧官网首页
  • 做爰的最好看的视频的网站重庆专业做网站公司
  • 风景网站模板互联网营销师培训内容
  • seo网站优化推广费用美国疫情最新消息
  • 一个域名可以做多少个二级网站百度云网盘资源搜索引擎
  • 网站html5模板互联网推广方案
  • 网站开发详细流程实体店营销方案
  • 网页给别人做的 网站后续收费百度学术搜索
  • 做网站价格多少钱郑州网站推广
  • phpcms v9 网站建设入门全球搜索
  • 企业网站建设 属于什么费用网络营销的优缺点
  • 天津网站建设排名软文推广文案
  • 做直播app的公司宁波seo企业网络推广
  • 互联网app网站建设方案模板下载百度竞价推广公司
  • 网站支付可以做二清迅雷磁力链bt磁力天堂
  • 直接用源码做网站盗版吗推广普通话手抄报一等奖
  • 深圳网站推广活动方案网络营销推广渠道有哪些
  • 电脑软件下载官方网站seo点击排名软件哪家好
  • 网站app建站多少钱网上培训课程平台
  • 武汉建网站的公司友の 连接
  • 洛阳网站seo公众号推广费用一般多少
  • 网站开发的朋友圈游戏代理推广渠道