📄 setconfig.java
字号:
.add(jLabel4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 87, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jTConfigPath, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 286, Short.MAX_VALUE))
.add(org.jdesktop.layout.GroupLayout.LEADING, jPanel1Layout.createSequentialGroup()
.add(jLabel5)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jTMediaPath, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 289, Short.MAX_VALUE)))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jButton2)
.add(jButton3))
.addContainerGap())))
.add(jPanel1Layout.createSequentialGroup()
.add(64, 64, 64)
.add(jButton4)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jButton5)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jBexit)
.addContainerGap(69, Short.MAX_VALUE))
.add(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.add(jLabel6)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jLinfo, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 344, Short.MAX_VALUE)
.addContainerGap())
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel1)
.add(jIPlist, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jTip, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jLabel2))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel3)
.add(jTport, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(jButton1))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel4)
.add(jTConfigPath, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(jButton2))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel5)
.add(jTMediaPath, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jButton3))
.add(19, 19, 19)
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel6)
.add(jLinfo))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jButton4)
.add(jButton5)
.add(jBexit)))
);
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addContainerGap()
.add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addContainerGap()
.add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void jButton4MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton4MouseClicked
//在这个的方写入服务器的配置信息
String ip = jTip.getText();
int port = Integer.parseInt(jTport.getText());
String conPath = jTConfigPath.getText();
String mediaPath =jTMediaPath.getText();
if(ip == null)
{
JOptionPane.showMessageDialog(this,"您的IP地址为空了");
return;
}
if(port == 0)
{
JOptionPane.showMessageDialog(this,"您的端口为空了");
return;
}
if(conPath == null)
{
JOptionPane.showMessageDialog(this,"您的配置文件地址为空了");
return;
}
if(mediaPath == null)
{
JOptionPane.showMessageDialog(this,"您的流媒体文件地址为空了");
return;
}
String msg = "IP:"+ip+"&"+"port:"+port+"&"+"configPath:"+conPath+"&"+"Mediapath:"+mediaPath+"&"+"time:"+((new Date()).toString());
// JOptionPane.showMessageDialog(this,msg);
try
{
File file = new File("config//config.dat");
if(file.exists())
{
file.delete();
file.createNewFile();
FileOutputStream fileOut = new FileOutputStream(file);
fileOut.write(msg.getBytes());
fileOut.close();
JOptionPane.showMessageDialog(this,"配置文件写入成功");
this.dispose();
}else
{
file.createNewFile();
FileOutputStream fileOut = new FileOutputStream(file);
fileOut.write(msg.getBytes());
fileOut.close();
JOptionPane.showMessageDialog(this,"配置文件写入成功");
this.dispose();
}
}
catch(FileNotFoundException e)
{
JOptionPane.showMessageDialog(this,"配置文件写入错误:"+e.toString());
this.dispose();
}
catch(IOException e)
{
JOptionPane.showMessageDialog(this,"配置文件写入错误:"+e.toString());
this.dispose();
}
}//GEN-LAST:event_jButton4MouseClicked
private void jButton5MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton5MouseClicked
//此处是清空填写的内容将从新填写
this.reset();
}//GEN-LAST:event_jButton5MouseClicked
private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton1MouseClicked
//建立一个soket检查是否可以使用
try{
if(jTport.getText() != null){
int intPort = Integer.parseInt(jTport.getText());
DatagramSocket tempSocket = new DatagramSocket(intPort);
if(tempSocket != null&&intPort <=50000)
{
JOptionPane.showMessageDialog(this,"该UDP端口可以使用");
tempSocket =null;
}else
{
tempSocket = null;
}
}else
{
JOptionPane.showMessageDialog(this,"该UDP端口不能使用");
}
}catch(BindException e)
{
JOptionPane.showMessageDialog(this,"这个端口现在正在使用当中");
}catch(SocketException e)
{
JOptionPane.showMessageDialog(this,e.toString());
}
}//GEN-LAST:event_jButton1MouseClicked
private void jButton3MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton3MouseClicked
JFileChooser fileChooser = new JFileChooser(new File("./"));
fileChooser.setSize(100,100);
if(fileChooser.showOpenDialog(this)==JFileChooser.APPROVE_OPTION)
{
jTMediaPath.setText(fileChooser.getCurrentDirectory().toString());
};
}//GEN-LAST:event_jButton3MouseClicked
private void jButton2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton2MouseClicked
JFileChooser fileChooser = new JFileChooser(new File("./"));
fileChooser.setSize(100,100);
if(fileChooser.showOpenDialog(this)==JFileChooser.APPROVE_OPTION)
{
jTConfigPath.setText(fileChooser.getCurrentDirectory().toString());
};
}//GEN-LAST:event_jButton2MouseClicked
private void jBexitMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jBexitMouseClicked
if(JOptionPane.showConfirmDialog(this,"您是否确认退出信息配置,有可能丢失您的信息配置","信息提示",JOptionPane.YES_NO_OPTION)==JOptionPane.OK_OPTION)
{
this.dispose();
};
}//GEN-LAST:event_jBexitMouseClicked
private void jIPlistItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jIPlistItemStateChanged
jTip.setText(evt.getItem().toString());
}//GEN-LAST:event_jIPlistItemStateChanged
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new setConfig().setVisible(true);
}
});
}
// 变量声明 - 不进行修改//GEN-BEGIN:variables
private javax.swing.JButton jBexit;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JButton jButton4;
private javax.swing.JButton jButton5;
private javax.swing.JComboBox jIPlist;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLinfo;
private javax.swing.JPanel jPanel1;
private javax.swing.JTextField jTConfigPath;
private javax.swing.JTextField jTMediaPath;
private javax.swing.JTextField jTip;
private javax.swing.JTextField jTport;
// 变量声明结束//GEN-END:variables
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -