📄 mainframe.java
字号:
}
fileChooserFrame.setVisible(true);
}
});
}
return jButton;
}
/**
* This method initializes jPanel6
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel6() {
if (jPanel6 == null) {
jLabel1 = new JLabel();
jLabel1.setText("Directory");
jLabel1.setFont(new java.awt.Font("Dialog", java.awt.Font.PLAIN, 12));
jLabel = new JLabel();
jLabel.setText("File");
jLabel.setFont(new java.awt.Font("Dialog", java.awt.Font.PLAIN, 12));
jPanel6 = new JPanel();
jPanel6.add(getJRadioButton(), null);
jPanel6.add(jLabel, null);
jPanel6.add(getJRadioButton1(), null);
jPanel6.add(jLabel1, null);
}
return jPanel6;
}
/**
* This method initializes jRadioButton
*
* @return javax.swing.JRadioButton
*/
private JRadioButton getJRadioButton() {
if (jRadioButton == null) {
jRadioButton = new JRadioButton();
jRadioButton.setSelected(true);
}
return jRadioButton;
}
/**
* This method initializes jRadioButton1
*
* @return javax.swing.JRadioButton
*/
private JRadioButton getJRadioButton1() {
if (jRadioButton1 == null) {
jRadioButton1 = new JRadioButton();
}
return jRadioButton1;
}
/**
* This method initializes jPanel7
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel7() {
if (jPanel7 == null) {
jPanel7 = new JPanel();
jPanel7.setLayout(new BorderLayout());
jPanel7.add(getJComboBox(), java.awt.BorderLayout.CENTER);
}
return jPanel7;
}
/**
* This method initializes jComboBox
*
* @return javax.swing.JComboBox
*/
private JComboBox getJComboBox() {
if (jComboBox == null) {
jComboBox = new JComboBox();
jComboBox.addItem("UNICODE");
jComboBox.setFont(new java.awt.Font("Dialog", java.awt.Font.PLAIN, 12));
Set names = Charset.availableCharsets().keySet();
for(Iterator iter = names.iterator();iter.hasNext();){
jComboBox.addItem((String) iter.next());
}
}
return jComboBox;
}
/**
* This method initializes jPanel8
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel8() {
if (jPanel8 == null) {
jPanel8 = new JPanel();
jPanel8.setLayout(new BorderLayout());
jPanel8.add(getJComboBox1(), java.awt.BorderLayout.CENTER);
jPanel8.setBorder(BorderFactory.createMatteBorder(5,3,3,5,new Color(238,238,238)));
//jPanel8.setPreferredSize(new Dimension())
}
return jPanel8;
}
/**
* This method initializes jComboBox1
*
* @return javax.swing.JComboBox
*/
private JComboBox getJComboBox1() {
if (jComboBox1 == null) {
jComboBox1 = new JComboBox();
jComboBox1.addItem("UNICODE");
//jComboBox1.addItem("unicodebigunmarked");
jComboBox1.setFont(new java.awt.Font("Dialog", java.awt.Font.PLAIN, 12));
Set names = Charset.availableCharsets().keySet();
for(Iterator iter = names.iterator();iter.hasNext();){
jComboBox1.addItem((String )iter.next());
}
}
return jComboBox1;
}
/**
* This method initializes jPanel9
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel9() {
if (jPanel9 == null) {
jLabel2 = new JLabel();
jLabel2.setText(" Source Code ");
jLabel2.setFont(new java.awt.Font("Dialog", java.awt.Font.PLAIN, 12));
jPanel9 = new JPanel();
jPanel9.setLayout(new BorderLayout());
jPanel9.add(jLabel2, java.awt.BorderLayout.WEST);
jPanel9.add(getJPanel7(), java.awt.BorderLayout.CENTER);
jPanel9.setBorder(BorderFactory.createMatteBorder(5,3,3,5,new Color(238,238,238)));
}
return jPanel9;
}
/**
* This method initializes jPanel10
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel10() {
if (jPanel10 == null) {
jLabel3 = new JLabel();
jLabel3.setText(" Convert Code");
jLabel3.setFont(new java.awt.Font("Dialog", java.awt.Font.PLAIN, 12));
jPanel10 = new JPanel();
jPanel10.setLayout(new BorderLayout());
jPanel10.add(jLabel3, java.awt.BorderLayout.WEST);
jPanel10.add(getJPanel8(), java.awt.BorderLayout.CENTER);
}
return jPanel10;
}
/**
* This method initializes jPanel11
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel11() {
if (jPanel11 == null) {
jPanel11 = new JPanel();
jPanel11.setLayout(new BorderLayout());
jPanel11.add(getJButton1(), java.awt.BorderLayout.CENTER);
jPanel11.setBorder(BorderFactory.createMatteBorder(3,5,3,5,new Color(238,238,238)));
}
return jPanel11;
}
/**
* This method initializes jButton1
*
* @return javax.swing.JButton
*/
private JButton getJButton1() {
if (jButton1 == null) {
jButton1 = new JButton();
jButton1.setText("Convert");
jButton1.setFont(new java.awt.Font("Dialog", java.awt.Font.PLAIN, 12));
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
System.out.println("actionPerformed() convert");
File [] files = fileChooserFrame.getSelectFiles();
if(files == null){
jTextArea.setText("Error: No files can be Converted");
}
else{
jTextArea.setText("");
for(int i = 0;i<files.length;i++){
if(files[i].isDirectory()){
File [] sonFiles = files[i].listFiles();
for(int j =0;j<sonFiles.length;j++){
convertFile.convertFile(
jComboBox.getSelectedItem().toString(),
jComboBox1.getSelectedItem().toString(),sonFiles[j]);
}
}
else if(files[i].isFile()){
convertFile.convertFile(jComboBox.getSelectedItem().toString(),
jComboBox1.getSelectedItem().toString(),
files[i]);
}
}
jTextArea.append("---------------------------------------------------------------\n" +
"All Convert Task has been completed !");
//fileChooserFrame.setSelectFilesNull();
}
}
});
}
return jButton1;
}
/**
* This method initializes jPanel12
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel12() {
if (jPanel12 == null) {
jPanel12 = new JPanel();
jPanel12.setPreferredSize(new java.awt.Dimension(10,50));
jPanel12.setBackground(new java.awt.Color(140,166,238));
jPanel12.setLayout(new BorderLayout());
jPanel12.add(getJLabel4(), java.awt.BorderLayout.CENTER);
}
return jPanel12;
}
/**
* This method initializes jLabel4
*
* @return javax.swing.JLabel
*/
private JLabel getJLabel4() {
if (jLabel4 == null) {
jLabel4 = new JLabel();
jLabel4.setFont(new Font("Arial Black", Font.BOLD, 18));
jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel4.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
jLabel4.setText("About CodeConvert");
jLabel4.setForeground(new Color(220, 230, 238));
}
return jLabel4;
}
/**
* This method initializes jScrollPane1
*
* @return javax.swing.JScrollPane
*/
private JScrollPane getJScrollPane1() {
if (jScrollPane1 == null) {
jScrollPane1 = new JScrollPane();
jScrollPane1.setViewportView(getJTextArea1());
}
return jScrollPane1;
}
/**
* This method initializes jTextArea1
*
* @return javax.swing.JTextArea
*/
private JTextArea getJTextArea1() {
if (jTextArea1 == null) {
jTextArea1 = new JTextArea();
jTextArea1.setEditable(false);
File fileReadme = new File("readme.txt");
FileReader fr = null;
BufferedReader br = null;
if(fileReadme.exists()){
String strLine = null ;
try {
fr = new FileReader(fileReadme);
br = new BufferedReader(fr);
do{
strLine = br.readLine();
if(strLine != null ){
jTextArea1.append(strLine + "\n");
}
}while(strLine != null);
} catch (FileNotFoundException e) {
try {
br.close();
fr.close();
} catch (IOException e1) {
// TODO 自动生成 catch 块
e1.printStackTrace();
}
e.printStackTrace();
} catch (IOException e) {
try {
br.close();
fr.close();
} catch (IOException e1) {
// TODO 自动生成 catch 块
e1.printStackTrace();
}
e.printStackTrace();
}
try {
br.close();
fr.close();
} catch (IOException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
}
else{
jTextArea1.setText(fileReadme.getAbsolutePath() +" is not exists!");
}
}
return jTextArea1;
}
} // @jve:decl-index=0:visual-constraint="2,3"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -