List of usage examples for javax.swing JTabbedPane JTabbedPane
public JTabbedPane()
TabbedPane
with a default tab placement of JTabbedPane.TOP
. From source file:instance.gui.InstanceGUI.java
private void createTabs() { tabbedPane = new JTabbedPane(); createStatisticsTab();//from www. java 2s .c om createInfoTab(); createSnapshotTab(); createLogPanel(); setLayout(new GridLayout(1, 1)); tabbedPane.setSelectedComponent(logPanel); add(tabbedPane); }
From source file:be.fedict.eid.tsl.tool.TslInternalFrame.java
private void initUI() { JTabbedPane tabbedPane = new JTabbedPane(); Container contentPane = this.getContentPane(); contentPane.add(tabbedPane);//from www . j av a2 s .c o m addGenericTab(tabbedPane); addServiceProviderTab(tabbedPane); addSignatureTab(tabbedPane); }
From source file:fr.pasteque.pos.sales.restaurant.JTicketsBagRestaurantMap.java
/** Creates new form JTicketsBagRestaurant */ public JTicketsBagRestaurantMap(AppView app, TicketsEditor panelticket) { super(app, panelticket); dlReceipts = new DataLogicReceipts(); dlSales = new DataLogicSales(); m_restaurantmap = new JTicketsBagRestaurant(app, this); m_PlaceCurrent = null;//from w w w .j a v a 2 s .co m m_PlaceClipboard = null; customer = null; this.floors = new ArrayList<Floor>(); this.places = new HashMap<String, List<Place>>(); try { ServerLoader loader = new ServerLoader(); ServerLoader.Response r = loader.read("PlacesAPI", "getAll"); if (r.getStatus().equals(ServerLoader.Response.STATUS_OK)) { JSONArray a = r.getArrayContent(); for (int i = 0; i < a.length(); i++) { JSONObject oFloor = a.getJSONObject(i); Floor f = new Floor(oFloor); this.floors.add(f); this.places.put(f.getID(), new ArrayList<Place>()); JSONArray aPlaces = oFloor.getJSONArray("places"); for (int j = 0; j < aPlaces.length(); j++) { Place p = new Place(aPlaces.getJSONObject(j)); this.places.get(f.getID()).add(p); } } } } catch (Exception e) { e.printStackTrace(); } initComponents(); // add the Floors containers if (this.floors.size() > 1) { // A tab container for 2 or more floors JTabbedPane jTabFloors = new JTabbedPane(); jTabFloors.applyComponentOrientation(getComponentOrientation()); jTabFloors.setBorder(new javax.swing.border.EmptyBorder(new Insets(5, 5, 5, 5))); jTabFloors.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); jTabFloors.setFocusable(false); jTabFloors.setRequestFocusEnabled(false); m_jPanelMap.add(jTabFloors, BorderLayout.CENTER); for (Floor f : this.floors) { f.getContainer().applyComponentOrientation(getComponentOrientation()); JScrollPane jScrCont = new JScrollPane(); jScrCont.applyComponentOrientation(getComponentOrientation()); JPanel jPanCont = new JPanel(); jPanCont.applyComponentOrientation(getComponentOrientation()); jTabFloors.addTab(f.getName(), f.getIcon(), jScrCont); jScrCont.setViewportView(jPanCont); jPanCont.add(f.getContainer()); } } else if (this.floors.size() == 1) { // Just a frame for 1 floor Floor f = this.floors.get(0); f.getContainer().applyComponentOrientation(getComponentOrientation()); JPanel jPlaces = new JPanel(); jPlaces.applyComponentOrientation(getComponentOrientation()); jPlaces.setLayout(new BorderLayout()); jPlaces.setBorder(new javax.swing.border.CompoundBorder( new javax.swing.border.EmptyBorder(new Insets(5, 5, 5, 5)), new javax.swing.border.TitledBorder(f.getName()))); JScrollPane jScrCont = new JScrollPane(); jScrCont.applyComponentOrientation(getComponentOrientation()); JPanel jPanCont = new JPanel(); jPanCont.applyComponentOrientation(getComponentOrientation()); // jPlaces.setLayout(new FlowLayout()); m_jPanelMap.add(jPlaces, BorderLayout.CENTER); jPlaces.add(jScrCont, BorderLayout.CENTER); jScrCont.setViewportView(jPanCont); jPanCont.add(f.getContainer()); } // Add all the Table buttons. for (Floor f : this.floors) { List<Place> places = this.places.get(f.getID()); for (Place pl : places) { f.getContainer().add(pl.getButton()); pl.setButtonBounds(); pl.getButton().addActionListener(new MyActionListener(pl)); } } // Add the reservations panel m_jreservations = new JTicketsBagRestaurantRes(app, this); add(m_jreservations, "res"); }
From source file:gtu._work.ui.RegexReplacer.java
private void initGUI() { try {// w ww .ja v a2 s. co m BorderLayout thisLayout = new BorderLayout(); getContentPane().setLayout(thisLayout); this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); { jTabbedPane1 = new JTabbedPane(); jTabbedPane1.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { try { if (configHandler != null && jTabbedPane1.getSelectedIndex() == TabIndex.TEMPLATE.ordinal()) { System.out.println("-------ChangeEvent[" + jTabbedPane1.getSelectedIndex() + "]"); configHandler.reloadTemplateList(); } } catch (Exception ex) { JCommonUtil.handleException(ex); } } }); getContentPane().add(jTabbedPane1, BorderLayout.CENTER); { jPanel1 = new JPanel(); BorderLayout jPanel1Layout = new BorderLayout(); jPanel1.setLayout(jPanel1Layout); jTabbedPane1.addTab("source", null, jPanel1, null); { jScrollPane1 = new JScrollPane(); jPanel1.add(jScrollPane1, BorderLayout.CENTER); { replaceArea = new JTextArea(); jScrollPane1.setViewportView(replaceArea); } } } { jPanel2 = new JPanel(); BorderLayout jPanel2Layout = new BorderLayout(); jPanel2.setLayout(jPanel2Layout); jTabbedPane1.addTab("param", null, jPanel2, null); { exeucte = new JButton(); jPanel2.add(exeucte, BorderLayout.SOUTH); exeucte.setText("exeucte"); exeucte.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { exeucteActionPerformed(evt); } }); } { jPanel3 = new JPanel(); jPanel2.add(JCommonUtil.createScrollComponent(jPanel3), BorderLayout.CENTER); jPanel3.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), }, new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, RowSpec.decode("default:grow"), })); { lblNewLabel = new JLabel("key"); jPanel3.add(lblNewLabel, "2, 2, right, default"); } { configKeyText = new JTextField(); jPanel3.add(configKeyText, "4, 2, fill, default"); configKeyText.setColumns(10); } { lblNewLabel_1 = new JLabel("from"); jPanel3.add(lblNewLabel_1, "2, 4, right, default"); } { repFromText = new JTextArea(); repFromText.setRows(3); jPanel3.add(JCommonUtil.createScrollComponent(repFromText), "4, 4, fill, default"); repFromText.setColumns(10); } { lblNewLabel_2 = new JLabel("to"); jPanel3.add(lblNewLabel_2, "2, 6, right, default"); } { repToText = new JTextArea(); repToText.setRows(3); // repToText.setPreferredSize(new Dimension(0, 50)); jPanel3.add(JCommonUtil.createScrollComponent(repToText), "4, 6, fill, default"); } } { addToTemplate = new JButton(); jPanel2.add(addToTemplate, BorderLayout.NORTH); addToTemplate.setText("add to template"); addToTemplate.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { configHandler.put(configKeyText.getText(), repFromText.getText(), repToText.getText(), tradeOffArea.getText()); configHandler.reloadTemplateList(); } }); } } { jPanel5 = new JPanel(); BorderLayout jPanel5Layout = new BorderLayout(); jPanel5.setLayout(jPanel5Layout); jTabbedPane1.addTab("template", null, jPanel5, null); { jScrollPane3 = new JScrollPane(); jPanel5.add(jScrollPane3, BorderLayout.CENTER); { templateList = new JList(); jScrollPane3.setViewportView(templateList); } templateList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { if (templateList.getLeadSelectionIndex() == -1) { return; } PropConfigHandler.Config config = (PropConfigHandler.Config) JListUtil .getLeadSelectionObject(templateList); configKeyText.setText(config.configKeyText); repFromText.setText(config.fromVal); repToText.setText(config.toVal); tradeOffArea.setText(config.tradeOff); templateList.setToolTipText(config.fromVal + " <----> " + config.toVal); if (JMouseEventUtil.buttonLeftClick(2, evt)) { String replaceText = StringUtils.defaultString(replaceArea.getText()); replaceText = replacer(config.fromVal, config.toVal, replaceText); resultArea.setText(replaceText); jTabbedPane1.setSelectedIndex(TabIndex.RESULT.ordinal()); // pasteTextToClipboard(); } } }); templateList.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent evt) { JListUtil.newInstance(templateList).defaultJListKeyPressed(evt); } }); // ? JListUtil.newInstance(templateList).setItemColorTextProcess(new ItemColorTextHandler() { public Pair<String, Color> setColorAndText(Object value) { PropConfigHandler.Config config = (PropConfigHandler.Config) value; if (config.tradeOffScore != 0) { return Pair.of(null, Color.GREEN); } return null; } }); // ? } { scheduleExecute = new JButton(); jPanel5.add(scheduleExecute, BorderLayout.SOUTH); scheduleExecute.setText("schedule execute"); scheduleExecute.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { scheduleExecuteActionPerformed(evt); } }); } } { jPanel4 = new JPanel(); BorderLayout jPanel4Layout = new BorderLayout(); jPanel4.setLayout(jPanel4Layout); jTabbedPane1.addTab("result", null, jPanel4, null); { jScrollPane2 = new JScrollPane(); jPanel4.add(jScrollPane2, BorderLayout.CENTER); { resultArea = new JTextArea(); jScrollPane2.setViewportView(resultArea); } } } } { configHandler = new PropConfigHandler(prop, propFile, templateList, replaceArea); JCommonUtil.setFont(repToText, repFromText, replaceArea, templateList); { tradeOffArea = new JTextArea(); tradeOffArea.setRows(3); // tradeOffArea.setPreferredSize(new Dimension(0, 50)); tradeOffArea.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { try { if (JMouseEventUtil.buttonLeftClick(2, e)) { String tradeOff = StringUtils.trimToEmpty(tradeOffArea.getText()); JSONObject json = null; if (StringUtils.isBlank(tradeOff)) { json = new JSONObject(); json.put(CONTAIN_ARRY_KEY, new JSONArray()); json.put(NOT_CONTAIN_ARRY_KEY, new JSONArray()); tradeOff = json.toString(); } else { json = JSONObject.fromObject(tradeOff); } // String selectItem = (String) JCommonUtil._JOptionPane_showInputDialog( "?!", "?", new Object[] { "NA", "equal", "not_equal", "ftl" }, "NA"); if ("NA".equals(selectItem)) { return; } String string = StringUtils.trimToEmpty( JCommonUtil._jOptionPane_showInputDialog(":")); string = StringUtils.trimToEmpty(string); if (StringUtils.isBlank(string)) { tradeOffArea.setText(json.toString()); return; } String arryKey = ""; String boolKey = ""; String strKey = ""; String intKey = ""; if (selectItem.equals("equal")) { arryKey = CONTAIN_ARRY_KEY; } else if (selectItem.equals("not_equal")) { arryKey = NOT_CONTAIN_ARRY_KEY; } else if (selectItem.equals("ftl")) { strKey = FREEMARKER_KEY; } else { throw new RuntimeException(" : " + selectItem); } if (StringUtils.isNotBlank(arryKey)) { if (!json.containsKey(arryKey)) { json.put(arryKey, new JSONArray()); } JSONArray arry = (JSONArray) json.get(arryKey); boolean findOk = false; for (int ii = 0; ii < arry.size(); ii++) { if (StringUtils.equalsIgnoreCase(arry.getString(ii), string)) { findOk = true; break; } } if (!findOk) { arry.add(string); } } else if (StringUtils.isNotBlank(strKey)) { json.put(strKey, string); } else if (StringUtils.isNotBlank(intKey)) { json.put(intKey, Integer.parseInt(string)); } else if (StringUtils.isNotBlank(boolKey)) { json.put(boolKey, Boolean.valueOf(string)); } tradeOffArea.setText(json.toString()); JCommonUtil._jOptionPane_showMessageDialog_info("?!"); } } catch (Exception ex) { JCommonUtil.handleException(ex); } } }); { panel = new JPanel(); jPanel3.add(panel, "4, 8, fill, fill"); { multiLineCheckBox = new JCheckBox(""); panel.add(multiLineCheckBox); } { autoPasteToClipboardCheckbox = new JCheckBox(""); panel.add(autoPasteToClipboardCheckbox); } } { lblNewLabel_3 = new JLabel("? "); jPanel3.add(lblNewLabel_3, "2, 10"); } jPanel3.add(JCommonUtil.createScrollComponent(tradeOffArea), "4, 10, fill, fill"); } configHandler.reloadTemplateList(); } this.setSize(512, 350); JCommonUtil.setJFrameCenter(this); JCommonUtil.defaultToolTipDelay(); JCommonUtil.frameCloseDo(this, new WindowAdapter() { public void windowClosing(WindowEvent paramWindowEvent) { try { prop.store(new FileOutputStream(propFile), "regexText"); } catch (Exception e) { JCommonUtil.handleException("properties store error!", e); } setVisible(false); dispose(); } }); } catch (Exception e) { e.printStackTrace(); } }
From source file:DragFileDemo.java
public DragFileDemo() { super(new BorderLayout()); fc = new JFileChooser(); ;//from w ww .j av a 2 s .c o m fc.setMultiSelectionEnabled(true); fc.setDragEnabled(true); fc.setControlButtonsAreShown(false); JPanel fcPanel = new JPanel(new BorderLayout()); fcPanel.add(fc, BorderLayout.CENTER); clear = new JButton("Clear All"); clear.addActionListener(this); JPanel buttonPanel = new JPanel(new BorderLayout()); buttonPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); buttonPanel.add(clear, BorderLayout.LINE_END); JPanel upperPanel = new JPanel(new BorderLayout()); upperPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); upperPanel.add(fcPanel, BorderLayout.CENTER); upperPanel.add(buttonPanel, BorderLayout.PAGE_END); //The TabbedPaneController manages the panel that //contains the tabbed pane. When there are no files //the panel contains a plain text area. Then, as //files are dropped onto the area, the tabbed panel //replaces the file area. JTabbedPane tabbedPane = new JTabbedPane(); JPanel tabPanel = new JPanel(new BorderLayout()); tabPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); tpc = new TabbedPaneController(tabbedPane, tabPanel); JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, upperPanel, tabPanel); splitPane.setDividerLocation(400); splitPane.setPreferredSize(new Dimension(530, 650)); add(splitPane, BorderLayout.CENTER); }
From source file:org.jfree.chart.demo.Main_window.java
Main_window() { this.setBackground(new Color(47, 79, 79)); errors.setBounds(500, 700, 50, 50);//from w w w .j av a 2 s. c om errors.setVisible(true); // errors.setFont(new Font(arg0, arg1, arg2)); leftpanel.setBackground(new Color(47, 79, 79)); panel = new JPanel(new BorderLayout()); Grafs = new ArrayList<>(); tabs = new JTabbedPane(); leftpanel.setBounds(0, 0, 700, height); leftpanel.setBackground(Color.blue); for (int i = 0; i < 10; i++) { series.add(new XYSeries("Graph " + i)); } arrays_init(); jframe_init(); jpanel_int(); init_graphics(10); lp = new LeftPanel(graphics, Grafs, Charts, series); panel.add(rightpanel); panel.add(lp); panel.repaint(); timer.start(); System.out.println("Socket!!"); socket.start(); }
From source file:com.joey.software.MoorFLSI.RepeatImageTextReader.java
public void createJPanel() { setLayout(new BorderLayout()); add(currentValue, BorderLayout.NORTH); add(image, BorderLayout.CENTER); currentValue.addChangeListener(new ChangeListener() { @Override//from ww w . j a v a2 s.com public void stateChanged(ChangeEvent e) { setCurrentImage((Integer) currentValue.getValue()); } }); // Create the text output panel JPanel outputPanel = new JPanel(new BorderLayout()); JScrollPane scrollPane = new JScrollPane(dataField); outputPanel.add(scrollPane, BorderLayout.CENTER); JTabbedPane tabPanel = new JTabbedPane(); tabPanel.addTab("Graph", chartPanel); tabPanel.addTab("Data", outputPanel); staticsHolderFrame.getContentPane().setLayout(new BorderLayout()); staticsHolderFrame.getContentPane().removeAll(); staticsHolderFrame.getContentPane().add(tabPanel, BorderLayout.CENTER); staticsHolderFrame.getContentPane().add(outputImages, BorderLayout.SOUTH); // Add region panel to image image.getImage().setControler(ROIPanel.TYPE_RECTANGLE); image.getImage().setAllowMultipleROI(false); image.getImage().addROIPanelListner(new ROIPanelListner() { @Override public void regionAdded(Shape region) { updateData(); } @Override public void regionChanged() { // TODO Auto-generated method stub } @Override public void regionRemoved(Shape region) { // TODO Auto-generated method stub } }); outputImages.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { saveImages(); } }); }
From source file:eu.apenet.dpt.standalone.gui.eag2012.Eag2012Frame.java
public void buildPanel(Eag eag, boolean isNew) { mainTabbedPane = new JTabbedPane(); mainTabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); mainTabbedPane.putClientProperty("jgoodies.noContentBorder", Boolean.TRUE); mainTabbedPane.add(labels.getString("eag2012.yourinstitution.institution"), new EagNewRepositoryPanel(eag, null, mainTabbedPane, this, model, labels, 0) .buildInstitutionTabbedPane(isNew, countrycode, mainagencycode)); for (int i = 1; i < eag.getArchguide().getDesc().getRepositories().getRepository().size(); i++) { if (eag.getArchguide().getDesc().getRepositories().getRepository().get(i).getRepositoryName().size() > 0 && StringUtils.isNotEmpty(eag.getArchguide().getDesc().getRepositories().getRepository().get(i) .getRepositoryName().get(0).getContent())) { String name = eag.getArchguide().getDesc().getRepositories().getRepository().get(i) .getRepositoryName().get(0).getContent(); mainTabbedPane.add(name,//w w w . j a v a2 s . c om new EagNewRepositoryPanel(eag, null, mainTabbedPane, this, model, labels, i) .buildInstitutionTabbedPane(isNew, countrycode, mainagencycode)); } else { mainTabbedPane.add(labels.getString("eag2012.tab.extraRepository") + " " + i, new EagNewRepositoryPanel(eag, null, mainTabbedPane, this, model, labels, i) .buildInstitutionTabbedPane(isNew, countrycode, mainagencycode)); } mainTabbedPane.setEnabledAt(i, false); } }
From source file:gtu._work.etc._3DSMovieRenamer.java
private void initGUI() { try {/*from w w w . jav a 2 s. c om*/ final SwingActionUtil swingUtil = (SwingActionUtil) SwingActionUtil.newInstance(this); BorderLayout thisLayout = new BorderLayout(); getContentPane().setLayout(thisLayout); this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); this.setTitle("3DS Rename"); { jTabbedPane1 = new JTabbedPane(); getContentPane().add(jTabbedPane1, BorderLayout.CENTER); { jPanel1 = new JPanel(); BorderLayout jPanel1Layout = new BorderLayout(); jPanel1.setLayout(jPanel1Layout); jTabbedPane1.addTab("vid list", null, jPanel1, null); { openDir = new JButton(); jPanel1.add(openDir, BorderLayout.NORTH); openDir.setText("open dir"); openDir.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { swingUtil.invokeAction("openDir.actionPerformed", evt); } }); } { ListModel vidListModel = new DefaultListModel(); vidList = new JList(); jPanel1.add(vidList, BorderLayout.CENTER); vidList.setModel(vidListModel); vidList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { swingUtil.invokeAction("vidList.mouseClicked", evt); } }); vidList.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent evt) { swingUtil.invokeAction("vidList.keyPressed", evt); } }); } { jPanel3 = new JPanel(); jPanel1.add(jPanel3, BorderLayout.SOUTH); jPanel3.setPreferredSize(new java.awt.Dimension(445, 34)); { renameText = new JTextField(); jPanel3.add(renameText); renameText.setPreferredSize(new java.awt.Dimension(187, 24)); } { renameBtn = new JButton(); jPanel3.add(renameBtn); renameBtn.setText("rename"); renameBtn.setPreferredSize(new java.awt.Dimension(106, 24)); renameBtn.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { swingUtil.invokeAction("renameBtn.mouseClicked", evt); } }); } { forceChange = new JCheckBox(); jPanel3.add(forceChange); forceChange.setText("force"); forceChange.setPreferredSize(new java.awt.Dimension(64, 21)); } } } { jPanel2 = new JPanel(); BorderLayout jPanel2Layout = new BorderLayout(); jPanel2.setLayout(jPanel2Layout); jTabbedPane1.addTab("copy", null, jPanel2, null); { jScrollPane1 = new JScrollPane(); jPanel2.add(jScrollPane1, BorderLayout.CENTER); { ListModel copyToListModel = new DefaultListModel(); copyToList = new JList(); jScrollPane1.setViewportView(copyToList); copyToList.setModel(copyToListModel); copyToList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { swingUtil.invokeAction("copyToList.mouseClicked", evt); } }); } } } { jPanel4 = new JPanel(); BorderLayout jPanel4Layout = new BorderLayout(); jPanel4.setLayout(jPanel4Layout); jTabbedPane1.addTab("BT Movie", null, jPanel4, null); { jScrollPane2 = new JScrollPane(); jPanel4.add(jScrollPane2, BorderLayout.WEST); jScrollPane2.setPreferredSize(new java.awt.Dimension(254, 355)); { btDirTree = new JTree(); jScrollPane2.setViewportView(btDirTree); btDirTree.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { swingUtil.invokeAction(evt); } }); btDirTree.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { swingUtil.invokeAction(evt); } }); JTreeUtil.newInstance(btDirTree).fileSystem(DEFAULT_BT_DIR); } } { jPanel5 = new JPanel(); BorderLayout jPanel5Layout = new BorderLayout(); jPanel5.setLayout(jPanel5Layout); jPanel4.add(jPanel5, BorderLayout.CENTER); { jScrollPane3 = new JScrollPane(); jPanel5.add(jScrollPane3, BorderLayout.CENTER); jScrollPane3.setPreferredSize(new java.awt.Dimension(427, 355)); { DefaultListModel btMovListModel = new DefaultListModel(); btMovList = new JList(); jScrollPane3.setViewportView(btMovList); btMovList.setModel(btMovListModel); btMovList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { swingUtil.invokeAction(evt); } }); btMovList.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent evt) { JListUtil.newInstance(btMovList).defaultJListKeyPressed(evt); } }); } } } } { jPanel6 = new JPanel(); FlowLayout jPanel6Layout = new FlowLayout(); jTabbedPane1.addTab("common", null, jPanel6, null); jPanel6.setLayout(jPanel6Layout); { execute3dsVidTransfer = new JButton(); jPanel6.add(execute3dsVidTransfer); execute3dsVidTransfer.setText("execute 3ds video transfer"); execute3dsVidTransfer.setPreferredSize(new java.awt.Dimension(207, 42)); execute3dsVidTransfer.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String bat = "C:/apps/_movie/3DSVideov1.00/3DS Video.exe"; try { Runtime.getRuntime().exec(String.format("cmd /c call \"%s\"", bat)); } catch (IOException e) { JCommonUtil.handleException(e); } } }); } { openMovieAppDir = new JButton(); jPanel6.add(openMovieAppDir); openMovieAppDir.setText("open movie app dir"); openMovieAppDir.setPreferredSize(new java.awt.Dimension(207, 42)); openMovieAppDir.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { try { Desktop.getDesktop().open(new File("C:/apps/_movie")); } catch (IOException e) { JCommonUtil.handleException(e); } } }); } } { jPanel7 = new JPanel(); BorderLayout jPanel7Layout = new BorderLayout(); jTabbedPane1.addTab("fake rename", null, jPanel7, null); jPanel7.setLayout(jPanel7Layout); { openFakeRenameDir = new JButton(); jPanel7.add(openFakeRenameDir, BorderLayout.NORTH); openFakeRenameDir.setText("open dir"); openFakeRenameDir.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { File file = JCommonUtil._jFileChooser_selectDirectoryOnly(); if (file != null) { DefaultListModel model = new DefaultListModel(); for (File f : file.listFiles()) { model.addElement(f); } openFakeRenameDirList.setModel(model); } } }); } { DefaultListModel openFakeRenameDirListModel = new DefaultListModel(); openFakeRenameDirList = new JList(); jPanel7.add(openFakeRenameDirList, BorderLayout.CENTER); openFakeRenameDirList.setModel(openFakeRenameDirListModel); openFakeRenameDirList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { File file = (File) JListUtil.getLeadSelectionObject(openFakeRenameDirList); try { Process process = Runtime.getRuntime() .exec(String.format("cmd /c call \"%s\"", file)); InputStream ins = process.getInputStream(); while (ins.read() != -1) { //TODO } ins.close(); System.out.println("done..."); } catch (IOException e) { e.printStackTrace(); } } }); openFakeRenameDirList.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent evt) { JListUtil.newInstance(openFakeRenameDirList).defaultJListKeyPressed(evt); } }); } { jPanel8 = new JPanel(); jPanel7.add(jPanel8, BorderLayout.SOUTH); jPanel8.setPreferredSize(new java.awt.Dimension(681, 43)); { openFakeRenameDir_newName = new JTextField(); jPanel8.add(openFakeRenameDir_newName); openFakeRenameDir_newName.setPreferredSize(new java.awt.Dimension(287, 27)); } { fakeRenameExecute = new JButton(); jPanel8.add(fakeRenameExecute); fakeRenameExecute.setText("execute"); fakeRenameExecute.setPreferredSize(new java.awt.Dimension(95, 27)); fakeRenameExecute.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { DefaultListModel model = (DefaultListModel) openFakeRenameDirList.getModel(); //TODO } }); } } } swingUtil.addAction("copyToList.mouseClicked", new Action() { public void action(EventObject evt) throws Exception { try { if (((MouseEvent) evt).getButton() == 3) { JMenuItem reloadMenu = new JMenuItem(); reloadMenu.setText("reload SD card directory"); reloadMenu.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { DefaultListModel copyToListModel = new DefaultListModel(); for (final File f : load3DSDir.listFiles(new FilenameFilter() { public boolean accept(File paramFile, String paramString) { if (paramFile.isDirectory() && paramString.matches(CUSTOM_3DS_DIR_PATTERN)) { return true; } return false; } })) { copyToListModel.addElement(f); } copyToList.setModel(copyToListModel); } }); JMenuItem copyAllToMenu = new JMenuItem(); { copyAllToMenu.setText( String.format("move %d vids to...", vidList.getModel().getSize())); final File toDir = (File) JListUtil.getLeadSelectionObject(copyToList); if (toDir == null || !toDir.exists() || !toDir.isDirectory()) { copyAllToMenu.setEnabled(false); } if (vidList.getModel().getSize() == 0) { copyAllToMenu.setText("copy no file..."); copyAllToMenu.setEnabled(false); } copyAllToMenu.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { DefaultListModel model = JListUtil.newInstance(vidList).getModel(); if (JOptionPaneUtil.ComfirmDialogResult.YES_OK_OPTION != JOptionPaneUtil .newInstance().iconWaringMessage().confirmButtonYesNo() .showConfirmDialog("are you sure copy files : " + model.getSize() + "\n to dir : " + toDir, "COPY VIDS")) { return; } for (int ii = 0; ii < model.getSize(); ii++) { File src = (File) model.getElementAt(ii); src.renameTo(new File(toDir, src.getName())); } JOptionPaneUtil.newInstance().iconInformationMessage() .showMessageDialog("copy completed!", "SUCCESS"); loadDirVids(); } }); } JPopupMenuUtil.newInstance(copyToList).applyEvent((MouseEvent) evt) .addJMenuItem(reloadMenu, copyAllToMenu).show(); } } catch (Exception ex) { JCommonUtil.handleException(ex); } } }); swingUtil.addAction("openDir.actionPerformed", new Action() { public void action(EventObject evt) throws Exception { File file = JFileChooserUtil.newInstance().selectDirectoryOnly().showOpenDialog() .getApproveSelectedFile(); if (file == null) { JOptionPaneUtil.newInstance().iconErrorMessage() .showMessageDialog("dir not corrent!, set desktop", getTitle()); loadDir = FileUtil.DESKTOP_DIR; } else { loadDir = file; } loadDirVids(); } }); swingUtil.addAction("vidList.mouseClicked", new Action() { // final String player = "C:/Program Files (x86)/GRETECH/GomPlayer/GOM.EXE"; public void action(EventObject evt) throws Exception { int pos = -1; if ((pos = vidList.getLeadSelectionIndex()) == -1) { return; } MouseEvent mevt = (MouseEvent) evt; final File selectItem = (File) vidList.getModel().getElementAt(pos); List<JMenuItem> menuList = new ArrayList<JMenuItem>(); JMenuItem simpleRenamer = new JMenuItem(); final String simpleRenamePrefix = RandomUtil.upperCase(3); simpleRenamer.setText("Rename : " + simpleRenamePrefix); simpleRenamer.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent paramActionEvent) { String value = StringUtils.defaultString(JOptionPaneUtil.newInstance() .showInputDialog("3 char prefix?", "AVI PREFIX"), simpleRenamePrefix); if (value != null && value.matches("[a-zA-Z]{3}")) { selectItem.renameTo(getNewFile(selectItem.getParentFile(), value)); loadDirVids(); } else { JOptionPaneUtil.newInstance().iconErrorMessage() .showMessageDialog("prefix is not correct!", "ERROR"); } } }); menuList.add(simpleRenamer); if (load3DSDir == null) { reload3DSDir(); if (load3DSDir == null) { JMenuItem disable = new JMenuItem(); disable.setText("MOVE : SD card is not set!"); disable.setEnabled(false); menuList.add(disable); } } else { for (final File f : load3DSDir.listFiles(new FilenameFilter() { public boolean accept(File paramFile, String paramString) { if (paramFile.isDirectory() && paramString.matches(CUSTOM_3DS_DIR_PATTERN)) { return true; } return false; } })) { JMenuItem copyTo = new JMenuItem(); copyTo.setText("MOVE : " + f.getName()); copyTo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent paramActionEvent) { if (JOptionPaneUtil.ComfirmDialogResult.YES_OK_OPTION == JOptionPaneUtil .newInstance().iconQuestionMessage().confirmButtonYesNo() .showConfirmDialog(// "are you sure move file\n" + // selectItem + "\n" + // "to\n" + // "dir : " + f + " ??"// , "COPY FILE")) { File copyToNewDirFile = new File(f, selectItem.getName()); if (copyToNewDirFile.exists()) { JOptionPaneUtil.newInstance().iconErrorMessage().showMessageDialog( "target dir file already exist!, need rename!", "FILE ALREADY EXIST"); return; } selectItem.renameTo(copyToNewDirFile); loadDirVids(); JOptionPaneUtil.newInstance().iconErrorMessage() .showMessageDialog("move completed!", "MOVE FILE"); } } }); menuList.add(copyTo); } } JPopupMenuUtil.newInstance(vidList).applyEvent(mevt) .addJMenuItem(menuList.toArray(new JMenuItem[menuList.size()])).show(); if (mevt.getClickCount() != 2) { return; } String clkItemPath = selectItem.getAbsolutePath(); String command = "cmd /c call \"" + clkItemPath + "\""; System.out.println(command); Runtime.getRuntime().exec(command); } }); swingUtil.addAction("vidList.keyPressed", new Action() { public void action(EventObject evt) throws Exception { JListUtil.newInstance(vidList).defaultJListKeyPressed(evt); } }); swingUtil.addAction("renameBtn.mouseClicked", new Action() { Pattern aviNamePattern = Pattern.compile("^([a-zA-Z]{3})_\\d{4}\\.[aA][vV][iI]$"); public void action(EventObject evt) throws Exception { String name = StringUtils.defaultIfEmpty(renameText.getText(), RandomUtil.upperCase(3)); System.out.println("name = " + name + ", force : " + forceChange.isSelected()); if (!name.matches("[a-zA-Z]{3}")) { renameText.setText(""); JOptionPaneUtil.newInstance().iconErrorMessage() .showMessageDialog("rename must eng 3 char!", "ERROR"); return; } DefaultListModel model = (DefaultListModel) vidList.getModel(); boolean matchOk = false; if (model.size() != 0) { File oldFile = null; Matcher matcher = null; for (int ii = 0; ii < model.getSize(); ii++) { oldFile = (File) model.getElementAt(ii); if (!oldFile.exists()) { JOptionPaneUtil.newInstance().iconErrorMessage().showMessageDialog( "file not exeist : \n" + oldFile.getAbsolutePath(), getTitle()); return; } matcher = aviNamePattern.matcher(oldFile.getName()); matchOk = matcher.find(); System.out.println("matchOk = " + matchOk); if (matchOk && !forceChange.isSelected()) { oldFile.renameTo(getNewFile(oldFile.getParentFile(), matcher.group(1))); } else { oldFile.renameTo(getNewFile(oldFile.getParentFile(), name)); } } JOptionPaneUtil.newInstance().iconInformationMessage().showMessageDialog("success!", getTitle()); } loadDirVids(); } }); ToolTipManager.sharedInstance().setInitialDelay(0); swingUtil.addAction(btMovList, MouseEvent.class, new Action() { public void action(EventObject evt) throws Exception { final File file = (File) JListUtil.getLeadSelectionObject(btMovList); if (JMouseEventUtil.buttonLeftClick(1, evt)) { btMovList.setToolTipText( DateFormatUtils.format(file.lastModified(), "yyyy/MM/dd HH:mm:ss") + " length:" + (file.length() / 1024) + "k"); } final Object[] objects = btMovList.getSelectedValues(); JPopupMenuUtil.newInstance(btMovList).applyEvent(evt)// .addJMenuItem("move out", (objects != null && objects.length > 0), new ActionListener() { public void actionPerformed(ActionEvent paramActionEvent) { List<File> list = new ArrayList<File>(); for (Object val : objects) { list.add((File) val); } if (!JCommonUtil._JOptionPane_showConfirmDialog_yesNoOption( "sure move file from\n" + list.toString().replace(',', '\n') + "\nto\n" + DEFAULT_BT_DIR, "MOVE")) { return; } StringBuilder sb = new StringBuilder(); File moveTo = null; for (File file : list) { sb.append((file.renameTo( moveTo = new File(DEFAULT_BT_DIR, file.getName())) && moveTo.exists()) ? "" : file + "\n"); } JCommonUtil._jOptionPane_showMessageDialog_info( sb.length() == 0 ? "move success!" : "move failed!\n" + sb); } }) .addJMenuItem("delete this", file.exists(), new ActionListener() { public void actionPerformed(ActionEvent paramActionEvent) { if (!JCommonUtil._JOptionPane_showConfirmDialog_yesNoOption( "sure delete file \n" + file, "DELETE")) { return; } boolean result = file.delete(); System.out.println("!!!!!" + result + "..." + file.exists()); JCommonUtil._jOptionPane_showMessageDialog_info( result ? "delete success!" : "delete failed!"); } }).show(); if (JMouseEventUtil.buttonLeftClick(2, evt)) { Runtime.getRuntime().exec(String.format("cmd /c call \"%s\"", file)); } } }); swingUtil.addAction(btDirTree, MouseEvent.class, new Action() { File getSingleFile() { return ((JFile) JTreeUtil.newInstance(btDirTree).getSelectItem().getUserObject()).getFile(); } public void action(EventObject evt) throws Exception { int selectCount = btDirTree.getSelectionModel().getSelectionCount(); if (selectCount == 1) { final File file = getSingleFile(); JPopupMenuUtil.newInstance(btDirTree).applyEvent(evt).addJMenuItem("delete this", selectCount == 1 && file.exists(), new ActionListener() { public void actionPerformed(ActionEvent paramActionEvent) { if (file.isFile()) { if (JCommonUtil._JOptionPane_showConfirmDialog_yesNoOption( "sure delete FILE : \n" + file, "WARNING")) { file.delete(); JCommonUtil._jOptionPane_showMessageDialog_info( (file.exists() ? "delete failed!" : "delete success!")); } } if (file.isDirectory()) { StringBuilder sb = new StringBuilder(); if (JCommonUtil._JOptionPane_showConfirmDialog_yesNoOption( "sure delete DIR : \n" + file, "WARNING")) { List<Boolean> delL = new ArrayList<Boolean>(); for (File f : file.listFiles()) { if (fileExtensionPattern.matcher(f.getName()).find() || f.length() > 1000000L) { if (!JCommonUtil ._JOptionPane_showConfirmDialog_yesNoOption( "delete this : \n" + f, "CHECK AGAIN")) { continue; } delL.add(f.delete()); } delL.add(f.delete()); } for (File f : file.listFiles()) { if (f.exists()) { sb.append(f + "\n"); } } System.out.println("delL.contains(false)==================>" + delL.contains(false)); } if (!file.delete()) { sb.append(file + "\n"); } JCommonUtil._jOptionPane_showMessageDialog_info( sb.length() > 0 ? "delete failed!\nlist:\n" + sb : "delete success!"); if (sb.length() == 0) { DefaultMutableTreeNode node = JTreeUtil.newInstance(btDirTree) .getSelectItem(); System.out.println( JTreeUtil.newInstance(btDirTree).removeNode(node)); } } } }).addJMenuItem("open dir", new ActionListener() { public void actionPerformed(ActionEvent paramActionEvent) { File openTarget = file; if (file.isFile()) { openTarget = file.getParentFile(); } try { Desktop.getDesktop().open(openTarget); } catch (IOException e) { JCommonUtil.handleException(e); } } }).show(); } } }); swingUtil.addAction(btDirTree, PropertyChangeEvent.class, new Action() { public void action(EventObject evt) throws Exception { List<File> list = new ArrayList<File>(); for (DefaultMutableTreeNode node : JTreeUtil.newInstance(btDirTree).getSelectItems()) { JFile jfile = (JFile) node.getUserObject(); if (jfile.getFile().isDirectory()) { for (File f : jfile.getFile().listFiles(new FilenameFilter() { public boolean accept(File paramFile, String paramString) { return fileExtensionPattern.matcher(paramString).find(); } })) { System.out.println(f.getName() + "...." + f.length()); list.add(f); } } } Collections.sort(list, new Comparator<File>() { public int compare(File paramT1, File paramT2) { return paramT1.lastModified() > paramT2.lastModified() ? -1 : 1; } }); btMovList.setModel(JListUtil.createModel(list.iterator())); } }); } this.setSize(702, 422); loadDirVids(); reload3DSDir(); } catch (Exception e) { e.printStackTrace(); } }
From source file:gtu._work.ui.ObnfInsertCreaterUI.java
private void initGUI() { try {/* w ww. j a v a 2 s. co m*/ JCommonUtil.defaultToolTipDelay(); BorderLayout thisLayout = new BorderLayout(); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); getContentPane().setLayout(thisLayout); { jTabbedPane1 = new JTabbedPane(); getContentPane().add(jTabbedPane1, BorderLayout.CENTER); { jPanel1 = new JPanel(); jTabbedPane1.addTab("?schema", null, jPanel1, null); { jLabel1 = new JLabel(); jPanel1.add(jLabel1); jLabel1.setText("tableName"); } { tableNameText = new JTextField(); jPanel1.add(tableNameText); tableNameText.setPreferredSize(new java.awt.Dimension(155, 22)); } { useDomainJarDefineChkBox = new JCheckBox(); jPanel1.add(useDomainJarDefineChkBox); useDomainJarDefineChkBox.setText("\u4ee5dominJar\u70ba\u6e96"); } { dominJarFileText = new JTextField(); File currentFile = new File(PropertiesUtil.getJarCurrentPath(getClass()), "sris-db-domain-2.5.0-SRIS-SNAPSHOT.jar"); if (currentFile.exists()) { dominJarFileText.setText(currentFile.getAbsolutePath()); } else { File cUserFile = new File("C:\\Users"); if (cUserFile.exists()) { String domainJarPath = "C:/Users/%s/.m2/repository/tw/gov/sris-db-domain/2.5.0-SRIS-SNAPSHOT/sris-db-domain-2.5.0-SRIS-SNAPSHOT.jar"; for (File f : cUserFile.listFiles()) { File jf = new File(String.format(domainJarPath, f.getName())); if (jf.exists()) { dominJarFileText.setText(jf.getAbsolutePath()); break; } } } } jPanel1.add(dominJarFileText); dominJarFileText.setPreferredSize(new java.awt.Dimension(219, 22)); JCommonUtil.jTextFieldSetFilePathMouseEvent(dominJarFileText, false); } { jLabel5 = new JLabel(); jPanel1.add(jLabel5); jLabel5.setText("obnfString"); jLabel5.setPreferredSize(new java.awt.Dimension(83, 15)); } { jScrollPane2 = new JScrollPane(); jPanel1.add(jScrollPane2); jScrollPane2.setPreferredSize(new java.awt.Dimension(544, 76)); { obnfArea = new JTextArea(); jScrollPane2.setViewportView(obnfArea); } } { jLabel6 = new JLabel(); jPanel1.add(jLabel6); jLabel6.setText("sql"); jLabel6.setPreferredSize(new java.awt.Dimension(58, 15)); } { jScrollPane3 = new JScrollPane(); jPanel1.add(jScrollPane3); jScrollPane3.setPreferredSize(new java.awt.Dimension(543, 116)); { insertSqlArea = new JTextArea(); jScrollPane3.setViewportView(insertSqlArea); } } { executeBtn = new JButton(); jPanel1.add(executeBtn); executeBtn.setText("\u8b80\u53d6ObnfString"); executeBtn.setPreferredSize(new java.awt.Dimension(146, 29)); executeBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { executeBtnAction(); } }); } { processSqlBtn = new JButton(); jPanel1.add(processSqlBtn); processSqlBtn.setText("\u7522\u751fSQL"); processSqlBtn.setPreferredSize(new java.awt.Dimension(135, 29)); processSqlBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { processSqlBtnAction(); } }); } } { jPanel2 = new JPanel(); BorderLayout jPanel2Layout = new BorderLayout(); jPanel2.setLayout(jPanel2Layout); jTabbedPane1.addTab("?", null, jPanel2, null); { jPanel3 = new JPanel(); jPanel2.add(jPanel3, BorderLayout.NORTH); jPanel3.setPreferredSize(new java.awt.Dimension(585, 61)); { jLabel4 = new JLabel(); jPanel3.add(jLabel4); jLabel4.setText("dbField"); } { dbFieldText = new JTextField(); jPanel3.add(dbFieldText); dbFieldText.setPreferredSize(new java.awt.Dimension(216, 22)); } { jLabel3 = new JLabel(); jPanel3.add(jLabel3); jLabel3.setText("value"); } { dbValue = new JTextField(); jPanel3.add(dbValue); dbValue.setPreferredSize(new java.awt.Dimension(244, 22)); } { pkCheckBox = new JCheckBox(); jPanel3.add(pkCheckBox); pkCheckBox.setText("\u662fPK"); } { addFieldBtn = new JButton(); jPanel3.add(addFieldBtn); addFieldBtn.setText("saveOrUpdate"); addFieldBtn.setPreferredSize(new java.awt.Dimension(116, 22)); addFieldBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { addFieldBtnAction(); } }); } { deleteFieldBtn = new JButton(); jPanel3.add(deleteFieldBtn); deleteFieldBtn.setText("delete"); deleteFieldBtn.setPreferredSize(new java.awt.Dimension(88, 22)); deleteFieldBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { deleteFieldBtnAction(); } }); } } { jScrollPane1 = new JScrollPane(); jPanel2.add(jScrollPane1, BorderLayout.CENTER); jScrollPane1.setPreferredSize(new java.awt.Dimension(585, 258)); { DefaultListModel dbFieldListModel = new DefaultListModel(); dbFieldList = new JList(); jScrollPane1.setViewportView(dbFieldList); dbFieldList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { dbFieldListMousePreformd(evt); } }); dbFieldList.setModel(dbFieldListModel); dbFieldList.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent evt) { JListUtil.newInstance(dbFieldList).defaultJListKeyPressed(evt); } }); } } } { jPanel4 = new JPanel(); GridLayout jPanel4Layout = new GridLayout(1, 1); jPanel4Layout.setColumns(1); jPanel4Layout.setHgap(5); jPanel4Layout.setVgap(5); jPanel4.setLayout(jPanel4Layout); jTabbedPane1.addTab("?", null, jPanel4, null); { manualDefineArea = new JTextArea(); jPanel4.add(manualDefineArea); manualDefineArea.setText(""); manualDefineArea.setToolTipText("?"); } { manualDefinePkArea = new JTextArea(); jPanel4.add(manualDefinePkArea); manualDefinePkArea.setText(""); manualDefinePkArea.setToolTipText("PK?"); } { manualDefineDbFieldBtn = new JButton(); jPanel4.add(manualDefineDbFieldBtn); manualDefineDbFieldBtn .setText("\u4ee5\u8cbc\u5165\u6b04\u4f4d\u5b9a\u7fa9\u6c7a\u5b9a\u6b04\u4f4d"); manualDefineDbFieldBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { manualDefineDbFieldBtnAction(); } }); } } } pack(); this.setSize(598, 366); } catch (Exception e) { //add your error handling code here e.printStackTrace(); } }