import java.awt.Color;
import java.awt.EventQueue;
import java.awt.Font;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.filechooser.FileNameExtensionFilter;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComponent;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
import java.net.URI;
import java.util.regex.Pattern;
import javax.swing.JTextField;
import javax.swing.JRadioButton;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import javax.swing.JComboBox;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import java.awt.event.HierarchyListener;
import java.awt.event.HierarchyEvent;
import org.eclipse.wb.swing.FocusTraversalOnArray;
import java.awt.Component;
import java.awt.Desktop;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
public class Trim {
private JFrame GenEclatNGSQTrim;
public JPanel panel_1,panel_2,panel;
public File[] file1,finder;
private JLabel label;
private JLabel lblInputFile,thumb;
private static final String basePath = "D:\\Company Data\\3. Our Works\\My work\\Pipeline Development\\Tools\\Trimmomatic-0.35";
public File file,inputfile,file2;
public int phreads=33;
public boolean clicked,dclicked,sel3=false,sel1=false,sel=false,sel2=false, filseselection=false;
public int threads=4;
private JLabel label_1;
private JButton button;
private JLabel label_2;
private JLabel label_3;
private JButton button_1;
private JLabel label_4;
private JLabel lblPairedEnd;
public JLabel lblWelcomeToNgsqtrim;
public JButton btnNewButton_2;
private JTextField textField_2;
private JTextField textField_3;
private JTextField textField_5;
private JTextField textField_7;
private JTextField textField_8;
private JTextField textField_10;
private JTextField textField_11;
private JPanel panel_3;
private JLabel label_16;
private JTextField textField;
private JLabel label_17;
private JTextField textField_1;
private JLabel label_18;
private JTextField textField_4;
private JLabel label_19;
private JTextField textField_6;
private JLabel label_20;
private JTextField textField_9;
private JLabel label_21;
private JTextField textField_12;
private JLabel label_22;
private JLabel label_23;
private JLabel label_24;
private JComboBox<Object> comboBox;
private JLabel label_25;
private JTextField textField_13;
private JRadioButton radioButton_1;
private JLabel label_26;
public String filepath,s1,s2,s,sa,sefile,seout,pefile2;
public File[] files;
public JComboBox<Object> comboBox_1;
public JRadioButton radioButton;
public int lip=0;
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
//File f = new File("images/good.jpg");
//window.GenEclatNGSQTrim.setVisible(true);
Trim frame = new Trim();
frame.GenEclatNGSQTrim.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public Trim() {
initialize();
}
private void initialize() {
GenEclatNGSQTrim = new JFrame();
GenEclatNGSQTrim.setBackground(Color.WHITE);
GenEclatNGSQTrim.setTitle("NGSQTrim");
//GenEclatNGSQTrim.setBounds(400, 200, 585, 380);
GenEclatNGSQTrim.setBounds(15, 410, 1000, 1000);
//GenEclatNGSQTrim.setExtendedState(JFrame.MAXIMIZED_BOTH);
//GenEclatNGSQTrim.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
GenEclatNGSQTrim.getContentPane().setLayout(null);
//GenEclatNGSQTrim.getRootPane().setWindowDecorationStyle(JRootPane.NONE);
//GenEclatNGSQTrim.setState(Frame.ICONIFIED);
GenEclatNGSQTrim.setResizable(false);
//GenEclatNGSQTrim.setVisible(JFrame.);
panel_1 = new JPanel();
panel_1.setBounds(10, 292, 560, 222);
GenEclatNGSQTrim.getContentPane().add(panel_1);
panel_1.setLayout(null);
panel_1.setAlignmentX(JComponent.CENTER_ALIGNMENT);
label = new JLabel("Single End");
label.setBounds(239, 0, 111, 20);
panel_1.add(label);
Font font1 = new Font(null,Font.BOLD, 16);
label.setFont(font1);
//Image
//Image image=GenerateImage.toImage(true); //this generates an image file
/*ImageIcon icon = new ImageIcon("images/good.jpg");
//thumb = new JLabel();
thumb.setIcon(icon);
thumb.setBounds(40, -65, 500, 500);
thumb.setHorizontalAlignment(SwingConstants.CENTER);
//GenEclatNGSQTrim.setBounds(15, 410, 585, 380);
GenEclatNGSQTrim.getContentPane().add(thumb);*/
//Tab sequence
//panel_1.setFocusTraversalPolicy(new FocusTraversalOnArray(new Component[]{btnNewButton_2, textField_9, textField_6, textField, textField_1, textField_4, textField_15, textField_20, comboBox, rdbtnTophread, btnExecute}));
//0-12 Single End
//0. Browse
btnNewButton_2 = new JButton("Browse");
btnNewButton_2.setBounds(122, 40, 89, 23);
panel_1.add(btnNewButton_2);
//textField_20.setEnabled(false);
//9. comboBox
String[] seselcet = { "TruSeq2-SE", "TruSeq3-SE"};
//Pared end panel
panel_2 = new JPanel();
panel_2.setBounds(10, 30, 560, 234);
//panel_2.setBounds(341, 40, 560, 320);
//panel_2.setBounds(10, 30, 575, 315);
GenEclatNGSQTrim.getContentPane().add(panel_2);
panel_2.setLayout(null);
panel_2.setVisible(false);
//00. Browse
button_1 = new JButton("Browse");
//button_1.setEnabled(false);
button_1.setBounds(122, 27, 89, 23);
panel_2.add(button_1);
//09. comboBox_1
String[] peselect = { "TruSeq2-PE", "TruSeq3-PE", "TruSeq3-PE-2"};
//Paired end panel labels L1-L15
//L1
lblPairedEnd = new JLabel("Paired End");
lblPairedEnd.setBounds(239, 0, 111, 20);
//label.setBounds(239, 0, 111, 20);
panel_2.add(lblPairedEnd);
Font font2 = new Font(null,Font.BOLD, 16);
lblPairedEnd.setFont(font2);
//L2
label_3 = new JLabel("Select Input file");
label_3.setBounds(10, 30, 130, 14);
panel_2.add(label_3);
//L3
label_4 = new JLabel("Input File");
label_4.setBounds(10, 57, 295, 14);
panel_2.add(label_4);
label_4.setVisible(false);
JLabel lblSelectInputFile = new JLabel("Select Input file");
lblSelectInputFile.setBounds(10, 43, 130, 14);
panel_1.add(lblSelectInputFile);
JMenuBar menuBar = new JMenuBar();
menuBar.setBounds(0, 0, 1370, 21);
GenEclatNGSQTrim.getContentPane().add(menuBar);
menuBar.setMaximumSize(null);
lblInputFile = new JLabel("Input File");
lblInputFile.setBounds(10, 68, 295, 14);
panel_1.add(lblInputFile);
lblInputFile.setVisible(false);
panel_3 = new JPanel();
panel_3.setBounds(10, 83, 540, 129);
panel_1.add(panel_3);
panel_3.setVisible(false);
panel_3.setLayout(null);
label_16 = new JLabel("Number of Threads");
label_16.setBounds(0, 6, 111, 14);
panel_3.add(label_16);
textField = new JTextField();
textField.addKeyListener(new KeyAdapter() {
@Override
public void keyTyped(KeyEvent e) {
char c=e.getKeyChar();
if(!(Character.isDigit(c) || (c ==KeyEvent.VK_BACK_SPACE) ||c==KeyEvent.VK_DELETE)){
e.consume();
}
}
});
textField.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
threads= Integer.parseInt(textField.getText());
}
});
textField.setColumns(10);
textField.setBounds(112, 3, 86, 20);
panel_3.add(textField);
label_17 = new JLabel("Trailing");
label_17.setBounds(234, 6, 77, 14);
panel_3.add(label_17);
textField_1 = new JTextField();
textField_1.addKeyListener(new KeyAdapter() {
@Override
public void keyTyped(KeyEvent e) {
char c=e.getKeyChar();
if(!(Character.isDigit(c) || (c ==KeyEvent.VK_BACK_SPACE) ||c==KeyEvent.VK_DELETE)){
e.consume();
}
}
});
textField_1.setColumns(10);
textField_1.setBounds(290, 3, 86, 20);
panel_3.add(textField_1);
label_18 = new JLabel("Miss match allowed");
label_18.setBounds(417, 0, 123, 14);
panel_3.add(label_18);
textField_4 = new JTextField();
textField_4.addKeyListener(new KeyAdapter() {
@Override
public void keyTyped(KeyEvent e) {
char c=e.getKeyChar();
if(!(Character.isDigit(c) || (c ==KeyEvent.VK_BACK_SPACE) ||c==KeyEvent.VK_DELETE)){
e.consume();
}
}
});
textField_4.setColumns(10);
textField_4.setBounds(504, 25, 32, 20);
panel_3.add(textField_4);
label_19 = new JLabel("Max");
label_19.setBounds(474, 28, 24, 14);
panel_3.add(label_19);
textField_6 = new JTextField();
textField_6.addKeyListener(new KeyAdapter() {
@Override
public void keyTyped(KeyEvent e) {
char c=e.getKeyChar();
if(!(Character.isDigit(c) || (c ==KeyEvent.VK_BACK_SPACE) ||c==KeyEvent.VK_DELETE)){
e.consume();
}
}
});
textField_6.setColumns(10);
textField_6.setBounds(442, 25, 24, 20);
panel_3.add(textField_6);
label_20 = new JLabel("Min");
label_20.setBounds(417, 28, 24, 14);
panel_3.add(label_20);
textField_9 = new JTextField();
textField_9.addKeyListener(new KeyAdapter() {
@Override
public void keyTyped(KeyEvent e) {
char c=e.getKeyChar();
if(!(Character.isDigit(c) || (c ==KeyEvent.VK_BACK_SPACE) ||c==KeyEvent.VK_DELETE)){
e.consume();
}
}
});
textField_9.setColumns(10);
textField_9.setBounds(290, 34, 86, 20);
panel_3.add(textField_9);
label_21 = new JLabel("Leading");
label_21.setBounds(234, 37, 46, 14);
panel_3.add(label_21);
textField_12 = new JTextField();
textField_12.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
try
{
if (!(Pattern.matches("^[0-9]:[0-9]+$", textField_12.getText())) ){
JOptionPane.showMessageDialog(null, "Please enter ratio correctly", "Sliding window", JOptionPane.ERROR_MESSAGE);
textField_12.setText("");
textField_12.grabFocus();
}
}
catch (Exception e1) {
e1.printStackTrace();
}}
});
textField_12.addKeyListener(new KeyAdapter() {
@Override
public void keyTyped(KeyEvent e) {
char c=e.getKeyChar();
if(!(Character.isDigit(c) || (c ==':') || (c ==KeyEvent.VK_BACK_SPACE) ||c==KeyEvent.VK_DELETE)){
e.consume();
}
}
});
textField_12.setColumns(10);
textField_12.setBounds(112, 34, 86, 20);
panel_3.add(textField_12);
label_22 = new JLabel("Sliding Window");
label_22.setBounds(0, 37, 89, 14);
panel_3.add(label_22);
label_23 = new JLabel("(Eg: 4:5)");
label_23.setBounds(0, 51, 46, 14);
panel_3.add(label_23);
label_24 = new JLabel("Select Adapters");
label_24.setBounds(0, 68, 95, 14);
panel_3.add(label_24);
String[] seselcet1 = { "TruSeq2-SE", "TruSeq3-SE"};
comboBox = new JComboBox<Object>(seselcet1);
//comboBox.setEnabled(false);
comboBox.setBounds(109, 65, 105, 20);
panel_3.add(comboBox);
label_25 = new JLabel("MinLen");
label_25.setBounds(234, 65, 46, 14);
panel_3.add(label_25);
textField_13 = new JTextField();
textField_13.addKeyListener(new KeyAdapter() {
@Override
public void keyTyped(KeyEvent e) {
char c=e.getKeyChar();
if(!(Character.isDigit(c) || (c ==KeyEvent.VK_BACK_SPACE) ||c==KeyEvent.VK_DELETE)){
e.consume();
}
}
});
textField_13.setColumns(10);
textField_13.setBounds(290, 62, 86, 20);
panel_3.add(textField_13);
radioButton_1 = new JRadioButton("TOPHREAD64");
radioButton_1.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
try
{
sel3=radioButton_1.isSelected();
if (sel3==true)
{
phreads=64;
JOptionPane.showMessageDialog(null, "P Value "+phreads);
}
else if (sel3==false)
{
phreads=33;
JOptionPane.showMessageDialog(null, "P Value "+phreads);
}
}catch (Exception e5){
e5.printStackTrace();}
}
});
//radioButton_1.setEnabled(false);
radioButton_1.setBounds(417, 52, 109, 20);
panel_3.add(radioButton_1);
label_26 = new JLabel("(Default 33)");
label_26.setBounds(440, 75, 89, 19);
panel_3.add(label_26);
lblWelcomeToNgsqtrim = new JLabel("Welcome to NGSQTrim");
lblWelcomeToNgsqtrim.setBounds(103, 32, 381, 37);
GenEclatNGSQTrim.getContentPane().add(lblWelcomeToNgsqtrim);
Font font = new Font("Verdana", Font.BOLD, 22);
lblWelcomeToNgsqtrim.setFont(font);
lblWelcomeToNgsqtrim.setForeground(Color.BLUE);
lblWelcomeToNgsqtrim.setHorizontalAlignment(SwingConstants.CENTER);
panel = new JPanel();
panel.setBounds(10, 61, 540, 149);
panel_2.add(panel);
panel.setVisible(false);
panel.setLayout(null);
JLabel label_5 = new JLabel("Number of Threads");
label_5.setBounds(0, 17, 111, 14);
panel.add(label_5);
label_5.setToolTipText("this is a msg");
textField_2 = new JTextField();
textField_2.addKeyListener(new KeyAdapter() {
});
textField_2.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
threads= Integer.parseInt(textField_2.getText());
}
});
//textField_2.setEnabled(false);
textField_2.setColumns(10);
textField_2.setBounds(112, 14, 86, 20);
panel.add(textField_2);
JLabel label_6 = new JLabel("Trailing");
label_6.setBounds(234, 17, 77, 14);
panel.add(label_6);
textField_3 = new JTextField();
textField_3.addKeyListener(new KeyAdapter() {
});
textField_3.setColumns(10);
textField_3.setBounds(290, 14, 86, 20);
panel.add(textField_3);
JLabel label_7 = new JLabel("Miss match allowed");
label_7.setBounds(417, 11, 138, 14);
panel.add(label_7);
JLabel label_8 = new JLabel("Min");
label_8.setBounds(417, 32, 23, 14);
panel.add(label_8);
textField_5 = new JTextField();
textField_5.addKeyListener(new KeyAdapter() {
});
//textField_5.setEnabled(false);
textField_5.setColumns(10);
textField_5.setBounds(443, 29, 23, 20);
panel.add(textField_5);
JLabel label_9 = new JLabel("Max");
label_9.setBounds(476, 32, 30, 14);
panel.add(label_9);
textField_7 = new JTextField();
textField_7.addKeyListener(new KeyAdapter() {
});
//textField_7.setEnabled(false);
textField_7.setColumns(10);
textField_7.setBounds(509, 29, 30, 20);
panel.add(textField_7);
JLabel label_10 = new JLabel("Sliding Window");
label_10.setBounds(0, 48, 89, 14);
panel.add(label_10);
JLabel label_11 = new JLabel("(Eg: 4:5)");
label_11.setBounds(0, 60, 46, 14);
panel.add(label_11);
textField_8 = new JTextField();
//textField_8.setEnabled(false);
textField_8.setColumns(10);
textField_8.setBounds(112, 45, 86, 20);
panel.add(textField_8);
JLabel label_12 = new JLabel("Select Adapters");
label_12.setBounds(0, 79, 95, 14);
panel.add(label_12);
String[] peselect1 = { "TruSeq2-PE", "TruSeq3-PE", "TruSeq3-PE-2"};
comboBox_1 = new JComboBox<Object>(peselect);
//comboBox_1.setEnabled(false);
comboBox_1.setBounds(109, 76, 105, 20);
panel.add(comboBox_1);
JLabel label_13 = new JLabel("Leading");
label_13.setBounds(234, 48, 46, 14);
panel.add(label_13);
textField_10 = new JTextField();
textField_10.addKeyListener(new KeyAdapter() {
});
textField_10.setColumns(10);
textField_10.setBounds(290, 45, 86, 20);
panel.add(textField_10);
textField_11 = new JTextField();
textField_11.addKeyListener(new KeyAdapter() {
});
//textField_11.setEnabled(false);
textField_11.setColumns(10);
textField_11.setBounds(290, 73, 86, 20);
panel.add(textField_11);
JLabel label_14 = new JLabel("MinLen");
label_14.setBounds(234, 76, 46, 14);
panel.add(label_14);
radioButton = new JRadioButton("TOPHREAD64");
radioButton.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
try
{
sel3=radioButton.isSelected();
if (sel3==true)
{
phreads=64;
JOptionPane.showMessageDialog(null, "P Value "+phreads);
}
else if (sel3==false)
{
phreads=33;
JOptionPane.showMessageDialog(null, "P Value "+phreads);
}
}catch (Exception e5){
e5.printStackTrace();}}
});
radioButton.setBounds(417, 57, 109, 20);
panel.add(radioButton);
JLabel label_15 = new JLabel("(Default 33)");
label_15.setBounds(440, 74, 86, 19);
panel.add(label_15);
panel_2.setFocusTraversalPolicy(new FocusTraversalOnArray(new Component[]{button_1}));
}
}
我尝试过使用工具提示,但是这有效吗? 我已附上完整的代码,请查看所有标签上的文字鼠标是否需要它也不适用于单个标签。