List of usage examples for java.awt.event WindowEvent isConsumed
protected boolean isConsumed()
From source file:course_generator.frmMain.java
/** * This method is called to initialize the form. *//*from w ww . jav a2s. c o m*/ private void initComponents() { // -- Main windows // ------------------------------------------------------ setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); // java.util.ResourceBundle bundle = // java.util.ResourceBundle.getBundle("course_generator/Bundle"); setTitle(bundle.getString("frmMain.title")); setIconImages(null); // setName("FrameMain"); // setPreferredSize(new java.awt.Dimension(812, 800)); addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent evt) { formWindowClosing(evt); } }); // -- Layout // ------------------------------------------------------------ Container paneGlobal = getContentPane(); // paneGlobal.setLayout(new GridBagLayout()); paneGlobal.setLayout(new BorderLayout()); // -- Menu bar // ---------------------------------------------------------- Create_MenuBarMain(); // -- Main toolbar // ------------------------------------------------------ Create_MainToolbar(); paneGlobal.add(ToolBarMain, BorderLayout.NORTH); // -- Status bar // ------------------------------------------------------ Create_Statusbar(); paneGlobal.add(StatusBar, BorderLayout.SOUTH); // -- Main split bar (vertical) // ----------------------------------------- SplitPaneMain = new javax.swing.JSplitPane(); paneGlobal.add(SplitPaneMain, BorderLayout.CENTER); // -- Left side of the split bar // ---------------------------------------- jPanelLeft = new javax.swing.JPanel(); jPanelLeft.setLayout(new java.awt.BorderLayout()); // -- Add the left panel to the main split panel // ------------------------ SplitPaneMain.setLeftComponent(jPanelLeft); // -- Content of the tree javax.swing.tree.DefaultMutableTreeNode treeNode1 = new javax.swing.tree.DefaultMutableTreeNode( "Course Generator"); javax.swing.tree.DefaultMutableTreeNode treeNode2 = new javax.swing.tree.DefaultMutableTreeNode("Parcours"); javax.swing.tree.DefaultMutableTreeNode treeNode3 = new javax.swing.tree.DefaultMutableTreeNode( "Utmb 2011"); javax.swing.tree.DefaultMutableTreeNode treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Prvu"); treeNode3.add(treeNode4); treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Fait"); treeNode3.add(treeNode4); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("Montagnard"); treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Prvu"); treeNode3.add(treeNode4); treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Fait"); treeNode3.add(treeNode4); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("UCDHL2008"); treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Prvu"); treeNode3.add(treeNode4); treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Fait"); treeNode3.add(treeNode4); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("UCDHL2009"); treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Prvu"); treeNode3.add(treeNode4); treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Fait"); treeNode3.add(treeNode4); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("UCDHL2010"); treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Prvu"); treeNode3.add(treeNode4); treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Fait"); treeNode3.add(treeNode4); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("UCDHL2011"); treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Prvu"); treeNode3.add(treeNode4); treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Fait"); treeNode3.add(treeNode4); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("UCDHL2012"); treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Prvu"); treeNode3.add(treeNode4); treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Fait"); treeNode3.add(treeNode4); treeNode2.add(treeNode3); treeNode3 = new javax.swing.tree.DefaultMutableTreeNode("UCDHL2013"); treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Prvu"); treeNode3.add(treeNode4); treeNode4 = new javax.swing.tree.DefaultMutableTreeNode("Fait"); treeNode3.add(treeNode4); treeNode2.add(treeNode3); treeNode1.add(treeNode2); treeNode2 = new javax.swing.tree.DefaultMutableTreeNode("Configuration"); treeNode1.add(treeNode2); // -- Tree // -------------------------------------------------------------- jTreeMain = new javax.swing.JTree(); jTreeMain.setModel(new javax.swing.tree.DefaultTreeModel(treeNode1)); jTreeMain.setPreferredSize(new java.awt.Dimension(109, 25)); // -- Add the tree to a scroll panel // ------------------------------------ jScrollPaneTree = new javax.swing.JScrollPane(); jScrollPaneTree.setBorder(javax.swing.BorderFactory.createEtchedBorder()); jScrollPaneTree.setViewportView(jTreeMain); // -- Add the scroll panel to the left panel // ---------------------------- jPanelLeft.add(jScrollPaneTree, java.awt.BorderLayout.CENTER); // -- Right split pane // -------------------------------------------------- SplitPaneMainRight = new javax.swing.JSplitPane(); SplitPaneMainRight.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT); SplitPaneMain.setRightComponent(SplitPaneMainRight); // -- Tabbed panel // ------------------------------------------------------ TabbedPaneMain = new javax.swing.JTabbedPane(); // -- Create the listener ChangeListener changeListener = new ChangeListener() { public void stateChanged(ChangeEvent changeEvent) { JTabbedPane sourceTabbedPane = (JTabbedPane) changeEvent.getSource(); int index = sourceTabbedPane.getSelectedIndex(); if (index == 4) // Tab Resume RefreshResume(); } }; TabbedPaneMain.addChangeListener(changeListener); SplitPaneMainRight.setTopComponent(TabbedPaneMain); // -- Tab - data (grid) // ------------------------------------------------- TableMain = new javax.swing.JTable(); TableMain.setModel(ModelTableMain); TableMain.getTableHeader() .setDefaultRenderer(new MainHeaderRenderer(TableMain.getTableHeader().getDefaultRenderer())); TableMain.getTableHeader().setReorderingAllowed(false); TableMain.setDefaultRenderer(ElevationClass.class, new ElevationRenderer()); TableMain.setDefaultRenderer(DistClass.class, new DistRenderer()); TableMain.setDefaultRenderer(TotalClass.class, new TotalRenderer()); TableMain.setDefaultRenderer(DiffClass.class, new DiffRenderer()); TableMain.setDefaultRenderer(CoeffClass.class, new CoeffRenderer()); TableMain.setDefaultRenderer(LatClass.class, new LatRenderer()); TableMain.setDefaultRenderer(LonClass.class, new LonRenderer()); TableMain.setDefaultRenderer(RecupClass.class, new RecupRenderer()); TableMain.setDefaultRenderer(TimeClass.class, new TimeRenderer()); TableMain.setDefaultRenderer(TimelimitClass.class, new TimelimitRenderer()); TableMain.setDefaultRenderer(HourClass.class, new HourRenderer()); TableMain.setDefaultRenderer(StationClass.class, new StationRenderer()); TableMain.setDefaultRenderer(TagClass.class, new TagRenderer()); TableMain.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF); TableMain.setRowHeight(20); TableMain.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { if (evt.getButton() == evt.BUTTON1 && evt.getClickCount() >= 2 && !evt.isConsumed()) { evt.consume(); int row = TableMain.rowAtPoint(evt.getPoint()); int col = TableMain.columnAtPoint(evt.getPoint()); frmEditPosition frm = new frmEditPosition(); if (frm.showDialog(Settings, Track, row, col)) { Track.isModified = true; RefreshTableMain(); RefreshProfil(); RefreshStatusbar(Track); } } else TableMainMouseClicked(evt); } }); TableMain.addKeyListener(new java.awt.event.KeyAdapter() { public void keyReleased(java.awt.event.KeyEvent evt) { TableMainKeyReleased(evt); } }); // -- Add the grid to a scroll panel // ------------------------------------ jScrollPaneData = new javax.swing.JScrollPane(); jScrollPaneData.setViewportView(TableMain); // -- Add the scroll panel to the tabbed panel // -------------------------- addTab(TabbedPaneMain, jScrollPaneData, bundle.getString("frmMain.TabData.tabTitle"), new javax.swing.ImageIcon(getClass().getResource("/course_generator/images/satellite16.png"))); // -- Tab - Profil // ------------------------------------------------------ jPanelProfil = new javax.swing.JPanel(); jPanelProfil.setPreferredSize(new java.awt.Dimension(677, 150)); jPanelProfil.setLayout(new java.awt.BorderLayout()); // -- Profil tool bar // --------------------------------------------------- // Create_Profil_Toolbar(); // jPanelProfil.add(ToolBarProfil, java.awt.BorderLayout.WEST); // -- Profil chart // ------------------------------------------------------ jPanelProfilChart = new ChartPanel(chart); CrosshairOverlay crosshairOverlay = new CrosshairOverlay(); xCrosshair = new Crosshair(Double.NaN, Color.DARK_GRAY, new BasicStroke(0f)); // xCrosshair.setLabelVisible(true); xCrosshair.setLabelBackgroundPaint(Color.WHITE); yCrosshair = new Crosshair(Double.NaN, Color.DARK_GRAY, new BasicStroke(0f)); // yCrosshair.setLabelVisible(true); yCrosshair.setLabelBackgroundPaint(Color.WHITE); crosshairOverlay.addDomainCrosshair(xCrosshair); crosshairOverlay.addRangeCrosshair(yCrosshair); jPanelProfilChart.addOverlay(crosshairOverlay); jPanelProfilChart.setBackground(new java.awt.Color(255, 0, 51)); jPanelProfilChart.addChartMouseListener(new ChartMouseListener() { @Override public void chartMouseClicked(ChartMouseEvent event) { ChartEntity chartentity = event.getEntity(); if (chartentity instanceof XYItemEntity) { XYItemEntity e = (XYItemEntity) chartentity; XYDataset d = e.getDataset(); int s = e.getSeriesIndex(); int i = e.getItem(); double x = d.getXValue(s, i); double y = d.getYValue(s, i); xCrosshair.setValue(x); yCrosshair.setValue(y); RefreshProfilInfo(i); //Refresh the position on the data grid TableMain.setRowSelectionInterval(i, i); Rectangle rect = TableMain.getCellRect(i, 0, true); TableMain.scrollRectToVisible(rect); //Refresh the marker position on the map RefreshCurrentPosMarker(Track.data.get(i).getLatitude(), Track.data.get(i).getLongitude()); } } @Override public void chartMouseMoved(ChartMouseEvent event) { } }); jPanelProfil.add(jPanelProfilChart, java.awt.BorderLayout.CENTER); // -- Profil info bar // --------------------------------------------------- jPanelProfilInfo = new javax.swing.JPanel(); jPanelProfilInfo.setLayout(new GridBagLayout()); jPanelProfil.add(jPanelProfilInfo, java.awt.BorderLayout.SOUTH); // -- Line 0 // -- Distance // ---------------------------------------------------------- lbProfilDistance = new javax.swing.JLabel(); lbProfilDistance.setText(" " + bundle.getString("frmMain.lbProfilDistance.text") + "=0.000km "); lbProfilDistance.setBorder(javax.swing.BorderFactory.createEtchedBorder()); Utils.addComponent(jPanelProfilInfo, lbProfilDistance, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.EAST, GridBagConstraints.BOTH); // -- Time // -------------------------------------------------------------- lbProfilTime = new javax.swing.JLabel(); lbProfilTime.setText(" " + bundle.getString("frmMain.lbProfilTime.text") + "=00:00:00 "); lbProfilTime.setBorder(javax.swing.BorderFactory.createEtchedBorder()); Utils.addComponent(jPanelProfilInfo, lbProfilTime, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.EAST, GridBagConstraints.BOTH); // -- Slope // ------------------------------------------------------------- lbProfilSlope = new javax.swing.JLabel(); lbProfilSlope.setText(" " + bundle.getString("frmMain.lbProfilSlope.text") + "=0.0% "); lbProfilSlope.setBorder(javax.swing.BorderFactory.createEtchedBorder()); Utils.addComponent(jPanelProfilInfo, lbProfilSlope, 2, 0, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.EAST, GridBagConstraints.BOTH); // -- Name // -------------------------------------------------------------- lbProfilName = new javax.swing.JLabel(); lbProfilName.setText(" " + bundle.getString("frmMain.lbProfilName.text") + "= "); lbProfilName.setBorder(javax.swing.BorderFactory.createEtchedBorder()); Utils.addComponent(jPanelProfilInfo, lbProfilName, 3, 0, 1, 1, 1, 0, 0, 0, 0, 0, GridBagConstraints.EAST, GridBagConstraints.BOTH); // -- Line 1 // -- Elevation // --------------------------------------------------------- lbProfilElevation = new javax.swing.JLabel(); lbProfilElevation.setText(" " + bundle.getString("frmMain.lbProfilElevation.text") + "=0m "); lbProfilElevation.setBorder(javax.swing.BorderFactory.createEtchedBorder()); Utils.addComponent(jPanelProfilInfo, lbProfilElevation, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.EAST, GridBagConstraints.BOTH); // -- Hour // -------------------------------------------------------------- lbProfilHour = new javax.swing.JLabel(); lbProfilHour.setText(" " + bundle.getString("frmMain.lbProfilHour.text") + "=00:00:00 "); lbProfilHour.setBorder(javax.swing.BorderFactory.createEtchedBorder()); Utils.addComponent(jPanelProfilInfo, lbProfilHour, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.EAST, GridBagConstraints.BOTH); // -- Speed // ------------------------------------------------------------- lbProfilSpeed = new javax.swing.JLabel(); lbProfilSpeed.setText(" " + bundle.getString("frmMain.lbProfilSpeed.text") + "=0.0km/h "); lbProfilSpeed.setBorder(javax.swing.BorderFactory.createEtchedBorder()); Utils.addComponent(jPanelProfilInfo, lbProfilSpeed, 2, 1, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.EAST, GridBagConstraints.BOTH); // -- Comment // ----------------------------------------------------------- lbProfilComment = new javax.swing.JLabel(); lbProfilComment.setText(" " + bundle.getString("frmMain.lbProfilComment.text") + "= "); lbProfilComment.setBorder(javax.swing.BorderFactory.createEtchedBorder()); Utils.addComponent(jPanelProfilInfo, lbProfilComment, 3, 1, 1, 1, 1, 0, 0, 0, 0, 0, GridBagConstraints.EAST, GridBagConstraints.BOTH); // -- Distance / Temps / Pente / Nom // -- Altitude / Heure / Vitesse / Commentaire // -- Add the panel to the tabbed panel // --------------------------------- addTab(TabbedPaneMain, jPanelProfil, bundle.getString("frmMain.TabProfil.tabTitle"), new javax.swing.ImageIcon(getClass().getResource("/course_generator/images/profil.png"))); // -- Tab - Statistic // --------------------------------------------------- jPanelStatistic = new javax.swing.JPanel(); jPanelStatistic.setLayout(new java.awt.BorderLayout()); // -- Statistic tool bar // --------------------------------------------------- Create_Statistic_Toolbar(); jPanelStatistic.add(ToolBarStatistic, java.awt.BorderLayout.NORTH); // TODO Add the component to display the statistics addTab(TabbedPaneMain, jPanelStatistic, bundle.getString("frmMain.TabStatistic.tabTitle"), new javax.swing.ImageIcon(getClass().getResource("/course_generator/images/stat.png"))); // -- Tab - Analysis // ---------------------------------------------------- jPanelAnalyze = new javax.swing.JPanel(); // TODO Define this panel addTab(TabbedPaneMain, jPanelAnalyze, bundle.getString("frmMain.TabAnalyze.tabTitle"), new javax.swing.ImageIcon(getClass().getResource("/course_generator/images/search.png"))); // -- Tab - Resume // ------------------------------------------------------ jPanelResume = new javax.swing.JPanel(); jPanelResume.setLayout(new java.awt.BorderLayout()); // -- Resume tool bar // --------------------------------------------------- Create_Resume_Toolbar(); jPanelResume.add(ToolBarResume, java.awt.BorderLayout.NORTH); TableResume = new javax.swing.JTable(); TableResume.setModel(ModelTableResume); TableResume.setRowHeight(20); TableResume.getTableHeader().setReorderingAllowed(false); TableResume.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF); TableResume.getTableHeader() .setDefaultRenderer(new ResumeHeaderRenderer(TableResume.getTableHeader().getDefaultRenderer())); // TODO Change the Renderer name. Add Resume... TableResume.setDefaultRenderer(ResumeNumClass.class, new ResumeNumRenderer()); TableResume.setDefaultRenderer(ResumeNameClass.class, new ResumeNameRenderer()); TableResume.setDefaultRenderer(ResumeLineClass.class, new ResumeLineRenderer()); TableResume.setDefaultRenderer(ResumeElevationClass.class, new ResumeElevationRenderer()); TableResume.setDefaultRenderer(ResumeClimbPClass.class, new ResumeClimbPRenderer()); TableResume.setDefaultRenderer(ResumeClimbNClass.class, new ResumeClimbNRenderer()); TableResume.setDefaultRenderer(ResumeDistanceClass.class, new ResumeDistanceRenderer()); TableResume.setDefaultRenderer(ResumeTimeClass.class, new ResumeTimeRenderer()); TableResume.setDefaultRenderer(ResumeHourClass.class, new ResumeHourRenderer()); TableResume.setDefaultRenderer(ResumedtTimeClass.class, new ResumedtTimeRenderer()); TableResume.setDefaultRenderer(ResumeTimeLimitClass.class, new ResumeTimeLimitRenderer()); TableResume.setDefaultRenderer(ResumeStationTimeClass.class, new ResumeStationTimeRenderer()); TableResume.setDefaultRenderer(ResumedtDistanceClass.class, new ResumedtDistanceRenderer()); TableResume.setDefaultRenderer(ResumedtClimbPClass.class, new ResumedtClimbPRenderer()); TableResume.setDefaultRenderer(ResumedtClimbNClass.class, new ResumedtClimbNRenderer()); TableResume.setDefaultRenderer(ResumeSpeedPClass.class, new ResumeSpeedPRenderer()); TableResume.setDefaultRenderer(ResumeSpeedNClass.class, new ResumeSpeedNRenderer()); TableResume.setDefaultRenderer(ResumeAvgSlopePClass.class, new ResumeAvgSlopePRenderer()); TableResume.setDefaultRenderer(ResumeAvgSlopeNClass.class, new ResumeAvgSlopeNRenderer()); TableResume.setDefaultRenderer(ResumeAvgSpeedClass.class, new ResumeAvgSpeedRenderer()); TableResume.setDefaultRenderer(ResumeCommentClass.class, new ResumeCommentRenderer()); // TableResume.addMouseListener(new java.awt.event.MouseAdapter() { // public void mouseClicked(java.awt.event.MouseEvent evt) { // TableMainMouseClicked(evt); // } // }); // TableResume.addKeyListener(new java.awt.event.KeyAdapter() { // public void keyReleased(java.awt.event.KeyEvent evt) { // TableMainKeyReleased(evt); // } // }); // -- Add the grid to a scroll panel // ------------------------------------ jScrollPaneResume = new javax.swing.JScrollPane(); jScrollPaneResume.setViewportView(TableResume); jPanelResume.add(jScrollPaneResume, java.awt.BorderLayout.CENTER); addTab(TabbedPaneMain, jPanelResume, bundle.getString("frmMain.TabResume.tabTitle"), new javax.swing.ImageIcon(getClass().getResource("/course_generator/images/grid.png"))); // -- Map panel // --------------------------------------------------------- jPanelMap = new javax.swing.JPanel(); jPanelMap.setLayout(new java.awt.BorderLayout()); Create_Map_Toolbar(); jPanelMap.add(jToolBarMapViewer, java.awt.BorderLayout.WEST); MapViewer = new org.openstreetmap.gui.jmapviewer.JMapViewer(); MapViewer.setMapMarkerVisible(true); MapViewer.setScrollWrapEnabled(true); MapViewer.setZoomButtonStyle(org.openstreetmap.gui.jmapviewer.JMapViewer.ZOOM_BUTTON_STYLE.VERTICAL); MapViewer.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { MapViewerMouseClicked(evt); } }); jPanelMap.add(MapViewer, java.awt.BorderLayout.CENTER); jScrollPanelMap = new javax.swing.JScrollPane(); jScrollPanelMap.setViewportView(jPanelMap); SplitPaneMainRight.setRightComponent(jScrollPanelMap); // -- Finished - Pack // --------------------------------------------------- pack(); }