Java Code Examples for javax.swing.JPanel#addComponentListener()

The following examples show how to use javax.swing.JPanel#addComponentListener() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: arcusplatform   File: DashboardSection.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected Component createComponent() {
   JPanel content = new JPanel(new BorderLayout());
   content.add(new JScrollPane(createLogTable()), BorderLayout.CENTER);
   content.add(createToolbar(), BorderLayout.SOUTH);
   content.addComponentListener(new ComponentAdapter() {

      /* (non-Javadoc)
       * @see java.awt.event.ComponentAdapter#componentShown(java.awt.event.ComponentEvent)
       */
      @Override
      public void componentShown(ComponentEvent e) {
         controller.refreshLogs();
      }
      
   });
   return content;
}
 
Example 2
Source Project: arcusplatform   File: BehaviorSection.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected Component createComponent() {
   JPanel content = new JPanel(new BorderLayout());
   content.add(new JScrollPane(createBehaviorTable()), BorderLayout.CENTER);
   content.add(createToolbar(), BorderLayout.SOUTH);
   content.addComponentListener(new ComponentAdapter() {

      @Override
      public void componentShown(ComponentEvent e) {
         controller.refreshBehaviors();
      }

   });

   IrisClientFactory
         .getClient().addMessageListener(l -> {
            if (isBehavior().apply(l.getEvent())) {
               controller.refreshBehaviors();
            }
         });
   return content;
}
 
Example 3
public Component build() {
   JPanel panel = new JPanel();
   CardLayout layout = new CardLayout();
   panel.setLayout(layout);
   panel.add(buildSelectorPanel(), "selector");
   panel.add(buildDetailPanel(), "details");
   if(showListeners.hasListeners()) {
      panel.addComponentListener(new ComponentAdapter() {
         @Override
         public void componentShown(ComponentEvent e) {
            showListeners.fireEvent(e);
         }
         
      });
   }
   selectionModel.addSelectionListener((o) -> {
      if(o.isPresent()) {
         layout.show(panel, "details");
      }
      else {
         layout.show(panel, "selector");
      }
   });
   
   return panel;
}
 
Example 4
Source Project: sc2gears   File: MultiRepAnalysis.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Creates and returns the Chat words tab.
 * @return the Chat words tab
 */
private JComponent createChatWordsTab() {
	final JPanel panel = new JPanel( new BorderLayout() );
	panel.addComponentListener( new FirstShownListener() {
		@Override
		public void firstShown( final ComponentEvent event ) {
   		final Vector< Vector< Object > > dataVector = new Vector< Vector< Object > >( chatWordsStatisticsMap.size() );
   		
   		for ( final WordStatistics ws : chatWordsStatisticsMap.values() ) {
   			final Vector< Object > row = new Vector< Object >( 6 );
   			row.add( ws.word );
   			row.add( ws.count );
   			row.add( ws.replays );
   			row.add( NullAwareComparable.getPercent( ws.replays * 100 / replaysIncludedInAnalysis ) );
   			row.add( Language.formatDate( ws.firstDate ) );
   			row.add( Language.formatDate( ws.lastDate ) );
   			dataVector.add( row );
   		}
   		
   		createStatisticsTableTab( panel, "module.multiRepAnal.tab.chatWords.info", new Object[] { chatWordsStatisticsMap.size() }, 0, new int[] { 1, 2, 0 }, dataVector, CHAT_WORDS_HEADER_NAME_VECTOR, new WordCloudTableInput( Language.getText( "module.multiRepAnal.tab.chatWords.title" ), 0, 1 ), null, null );
		}
	} );
	
	return panel;
}
 
Example 5
public Component build() {
   JPanel panel = new JPanel();
   panel.setLayout(new BorderLayout());
   panel.setPreferredSize(new Dimension(600, 450));
   if(selector != null) {
      panel.add(selector, BorderLayout.NORTH);
   }
   panel.add(createCapabilityTable(), BorderLayout.CENTER);
   if(toolbar != null) {
      panel.add(toolbar, BorderLayout.SOUTH);
   }
   if(showListeners.hasListeners()) {
      panel.addComponentListener(new ComponentAdapter() {

         /* (non-Javadoc)
          * @see java.awt.event.ComponentAdapter#componentShown(java.awt.event.ComponentEvent)
          */
         @Override
         public void componentShown(ComponentEvent e) {
            showListeners.fireEvent(e);
         }
         
      });
   }
   
   
   return panel;
}
 
Example 6
public static JPanel createDeprecationInfoPanel(Operator operator) {
	final JPanel panel = new JPanel(new BorderLayout());
	final FixedWidthLabel info = new FixedWidthLabel(200, operator.getOperatorDescription().getDeprecationInfo());
	panel.add(info, BorderLayout.CENTER);
	panel.addComponentListener(new ComponentAdapter() {

		@Override
		public void componentResized(ComponentEvent e) {
			info.setWidth(panel.getWidth());
		}
	});
	return panel;
}
 
Example 7
Source Project: sc2gears   File: MultiRepAnalysis.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Creates and returns the maps tab.
 * @return the maps tab
 */
private JComponent createMapsTab() {
	final JPanel panel = new JPanel( new BorderLayout() );
	panel.addComponentListener( new FirstShownListener() {
		@Override
		public void firstShown( final ComponentEvent event ) {
       		final Vector< Vector< Object > > dataVector = new Vector< Vector< Object > >( mapStatisticsMap.size() );
       		final NullAwareComparable< Integer > nullWinRatio = NullAwareComparable.getPercent( null );
       		
       		for ( final MapStatistics ms : mapStatisticsMap.values() ) {
       			final Record pRecord = ms.raceRecordMap.get( Race.PROTOSS );
       			final Record tRecord = ms.raceRecordMap.get( Race.TERRAN  );
       			final Record zRecord = ms.raceRecordMap.get( Race.ZERG    );
       			final Vector< Object > row = new Vector< Object >( 9 );
       			row.add( ms.name );
       			row.add( ms.record.totalGames );
       			row.add( NullAwareComparable.getPercent( ms.record.totalGames * 100 / replaysIncludedInAnalysis ) );
       			row.add( pRecord == null ? nullWinRatio : pRecord.getWinRatio() );
       			row.add( tRecord == null ? nullWinRatio : tRecord.getWinRatio() );
       			row.add( zRecord == null ? nullWinRatio : zRecord.getWinRatio() );
       			row.add( ReplayUtils.formatMs( ms.getAvgGameLength() * 1000, GameSpeed.NORMAL ) ); // Passing GameSpeed.NORMAL because it has already been converted
       			row.add( Language.formatDate( ms.firstDate ) );
       			row.add( Language.formatDate( ms.lastDate ) );
       			dataVector.add( row );
       		}
       		
       		createStatisticsTableTab( panel, "module.multiRepAnal.tab.maps.info", new Object[] { mapStatisticsMap.size() }, 0, new int[] { 1, 0 }, dataVector, MAPS_HEADER_NAME_VECTOR, new WordCloudTableInput( Language.getText( "module.multiRepAnal.tab.maps.title" ), 0, 1 ), null, null );
		}
	} );
	
	return panel;
}
 
Example 8
/**
   * Create a PieChart view that displays the data in a particular column.
   *
   * @param model Data source.
   * @param column Index of the column to collate.
   */
  public PieChartTab(MonitorModel model, int column) {
      super(model, false, ImageLoader.getNewIcon(MonitorWindow.PIE_ICON));

      String title = model.getName() + " - " + model.getColumnName(column);
      setName(title);

      pieModel = new TablePieDataset(model, column);

      chart = ChartFactory.createPieChart3D(null, pieModel, true, true, false);
      chart.setBackgroundPaint(getBackground());

      pieModel.calculate();

      // 2015-10-18 Changed to 3D pie
      final PiePlot3D plot = (PiePlot3D)chart.getPlot();

      //plot.setCircular(false);
      //plot.setRadius(0.60);
      //plot.setSectionLabelType(PiePlot.PERCENT_LABELS);

      plot.setStartAngle(270);
      plot.setDirection(Rotation.ANTICLOCKWISE);
      plot.setForegroundAlpha(0.6f);
      //plot.setInteriorGap(0.33);

      pieModel.addChangeListener(plot);

      chartpanel = new ChartPanel(chart, true);

      // 2015-10-18 Added setting below to keep the aspect ratio of 8:5
      // see http://www.jfree.org/forum/viewtopic.php?f=3&t=115763
      // Chart will always be drawn to an off-screen buffer that is the same size as the ChartPanel, so no scaling will happen when the offscreen image is copied to the panel.
      chartpanel.setPreferredSize(new Dimension (800, 300));
      chartpanel.setMinimumDrawWidth(0);
      chartpanel.setMaximumDrawWidth(Integer.MAX_VALUE);
      chartpanel.setMinimumDrawHeight(0);
      chartpanel.setMaximumDrawHeight(Integer.MAX_VALUE);

JPanel fixedSizePane = new JPanel(new FlowLayout());
fixedSizePane.add(chartpanel);
fixedSizePane.addComponentListener(new ComponentAdapter() {
          @Override
          public void componentResized(ComponentEvent e) {
          	int w = fixedSizePane.getWidth();
              int h = fixedSizePane.getHeight();
              int size =  Math.min(w, h);
              int newWidth = (int) (size *8D/3D);
              chartpanel.setPreferredSize(new Dimension(newWidth, size));
              fixedSizePane.revalidate();
          }
      });

      add(fixedSizePane, BorderLayout.CENTER);

      // 2015-10-18 Added rotator code
      final Rotator rotator = new Rotator(plot);
      rotator.start();
//System.out.println("PieChartTab : just done calling constructor");
  }