📄 programclient.java
字号:
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.event.*;
import java.net.*;
public class programClient extends JFrame implements ActionListener
{
JButton ok;
JTextField tf;
static String strRequest="";
Container cp;
public programClient()
{
super("Draw graphs") ;
cp=getContentPane();
cp.setLayout(null);
cp.setBackground(new Color(141,165,181));
ok=new JButton("Ok");
ok.setMnemonic('O');
ok.setBounds(120,130,100,20);
ok.setForeground(new Color(141,0,131));
ok.setBackground(new Color(0,209,255));
ok.addActionListener(this);
cp.add(ok);
JLabel lblServerName=new JLabel("Enter Address Server:");
lblServerName.setBounds(10,50,150,20);
lblServerName.setForeground(new Color(0,120,0));
cp.add(lblServerName);
tf=new JTextField();
tf.setForeground(Color.blue);
tf.setSelectedTextColor(Color.green);
tf.setSelectionColor(Color.darkGray);
tf.setBounds(100,80,150,20);
cp.add(tf);
JLabel lblTitle=new JLabel("Welcome to draw graphs programming");
lblTitle.setFont(new Font("TimesNewRoman",Font.BOLD,18));
lblTitle.setBounds(0,10,340,20);
lblTitle.setForeground(new Color(225,54,197));
cp.add(lblTitle);
this.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent evt)
{System.exit(0);}
});
this.setResizable(false) ;
}
public void actionPerformed(ActionEvent evt)
{
if(evt.getSource()==ok)
{
if(tf.getText().trim().equals("")){}
else
{
try
{
InetAddress inet=InetAddress.getByName(tf.getText());
graph g=new graph(inet.getHostAddress());
g.setSize(800,570);
g.setVisible(true);
this.setVisible(false);
}
catch(Exception e) {System.out.println(e);}
}
}
}
public static void main(String arg[])
{
programClient rc=new programClient();
rc.setSize(350,210);
rc.setVisible(true);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -