java创建的界面没有最小化_java 图形界面有些组建不显示,最小化后显示正常

BUTTON和几个JTextField不显示,当鼠标放上去后显示。最小化在重新最大化后显示正常,怎么回事呀,源代码如下:publicclassCustomFrame{privateJFrameframe;publicJTextAreainformati...

BUTTON和几个JTextField不显示,当鼠标放上去后显示。最小化在重新最大化后显示正常,怎么回事呀,源代码如下:

public class CustomFrame {

private JFrame frame;

public JTextArea information;

private JTextArea sendMessage;

private JTextField ip;

private JTextField port;

private JButton attach;

private Custom custom;

private CustomFrame cf=this;

CustomFrame()

{

go();

}

public void go()

{

frame=new JFrame("客户端 ***********杨鹏伟**1937213**计科72");

frame.setBounds(700,200,500,500);

frame.setResizable(false);//不能最大化

frame.setVisible(true);

{

JLabel lb=new JLabel("Port:");

lb.setBounds(230,15,50,25);

frame.getContentPane().add(lb);

}

JScrollPane scrollPane = new JScrollPane();

scrollPane.setBounds(10, 50, 480, 200);

frame.getContentPane().add(scrollPane);

information=new JTextArea();

scrollPane.add(information);

information.setEditable(false);

scrollPane.setViewportView(information);

JScrollPane scrollPane2 = new JScrollPane();

scrollPane2.setBounds(10, 300, 480, 100);

frame.getContentPane().add(scrollPane2);

sendMessage = new JTextArea();

scrollPane2.setViewportView(sendMessage);

ip = new JTextField();

ip.setBounds(70, 15, 150, 25);

ip.setText("127.0.0.1");

frame.getContentPane().add(ip);

port=new JTextField();

port.setBounds(280, 15, 100, 25);

port.setText("9999");

frame.getContentPane().add(port);

attach=new JButton("连接");

attach.setBounds(400,10,80,35);

frame.getContentPane().add(attach);

attach.addActionListener(new ActionListener(){

public void actionPerformed(ActionEvent e) {

String ipValue=ip.getText();

String portValue=port.getText();

if(ipValue==null||ipValue.length()<=0)

JOptionPane.showMessageDialog(frame, "请输入服务器IP地址!");

else if(!ipValue.matches("[0-9.]+"))

JOptionPane.showMessageDialog(frame, "IP地址应为0-9数字和.组成");

else if(portValue==null||portValue.length()<=0)

JOptionPane.showMessageDialog(frame, "请输入端口号");

else if(!portValue.matches("[0-9]+"))

JOptionPane.showMessageDialog(frame, "端口应为0-65535的数字!");

else if(Integer.parseInt(portValue)<0||Integer.parseInt(portValue)>65535)

JOptionPane.showMessageDialog(frame, "端口应为0-65535之间的数值");

else {

ip.setEditable(false);

port.setEditable(false);

custom=new Custom(ipValue,Integer.parseInt(portValue),cf);

custom.start();

attach.setEnabled(true);

}

}

});

JButton send=new JButton("发送");

send.setBounds(400, 400,80, 50);

frame.getContentPane().add(send);

展开

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值