Java Code Examples for javax.swing.JPanel.getComponent()

The following are Jave code examples for showing how to use getComponent() of the javax.swing.JPanel class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: incubator-netbeans   File: AntSanityTest.java   View Source Code Vote up 6 votes
/**
 * Evaluates simple expression during debugging session.
 */
public void evaluateExpression() throws IllegalAccessException, InvocationTargetException, InterruptedException, InvalidExpressionException {
    TopComponentOperator variablesView = new TopComponentOperator(new ContainerOperator(MainWindowOperator.getDefault(), VIEW_CHOOSER), "Variables");
    JToggleButtonOperator showEvaluationResultButton = new JToggleButtonOperator(variablesView, 0);
    showEvaluationResultButton.clickMouse();
    TopComponentOperator evaluationResultView = new TopComponentOperator("Evaluation Result");
    new Action("Debug|Evaluate Expression...", null).perform();
    TopComponentOperator expressionEvaluator = new TopComponentOperator("Evaluate Expression");
    JEditorPaneOperator expressionEditor = new JEditorPaneOperator(expressionEvaluator);
    new EventTool().waitNoEvent(1000);
    expressionEditor.setText("\"If n is: \" + n + \", then n + 1 is: \" + (n + 1)");
    JPanel buttonsPanel = (JPanel) expressionEvaluator.getComponent(2);
    JButton expressionEvaluatorButton = (JButton) buttonsPanel.getComponent(1);
    assertEquals("Evaluate code fragment (Ctrl + Enter)", expressionEvaluatorButton.getToolTipText());
    expressionEvaluatorButton.doClick();
    JTableOperator variablesTable = new JTableOperator(evaluationResultView);
    assertValue(variablesTable, 0, 2, "\"If n is: 50, then n + 1 is: 51\"");
    assertEquals("\"If n is: \" + n + \", then n + 1 is: \" + (n + 1)", variablesTable.getValueAt(0, 0).toString().trim());
}
 
Example 2
Project: Mujeed-Arabic-Prolog   File: JFontChooser.java   View Source Code Vote up 5 votes
private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
  	
  	for (int i=0; i<PrincipalWindow.tabbedPaneProgram.getTabCount(); i++){
  	JPanel panelToSetFont = (JPanel) PrincipalWindow.tabbedPaneProgram.getComponentAt(i);
JScrollPane scrollpane = (JScrollPane) panelToSetFont.getComponent(0);
JTextPane textPane = (JTextPane) scrollpane.getViewport().getComponent(0);
textPane.setFont(lblPreview.getFont());
textPane.repaint();
  	}
  	PrincipalWindow.tabbedPaneProgram.setSelectedIndex(PrincipalWindow.tabbedPaneProgram.getTabCount()-1);
  	FontFile.saveFont(lblPreview.getFont());
  	
      doClose(RET_OK);
  }
 
Example 3
Project: Mujeed-Arabic-Prolog   File: CopyListener.java   View Source Code Vote up 5 votes
@Override
public void actionPerformed(ActionEvent e) {
	// TODO Auto-generated method stub
	if(PrincipalWindow.tabbedPaneProgram.getComponentCount() != 0){
		JPanel selectedPanel = (JPanel) PrincipalWindow.tabbedPaneProgram.getComponentAt(PrincipalWindow.tabbedPaneProgram.getSelectedIndex());
		JScrollPane scrollPane = (JScrollPane) selectedPanel.getComponent(0);
		JTextPane textPaneCode = (JTextPane) scrollPane.getViewport().getComponent(0);
		textPaneCode.copy();
	}

}
 
Example 4
Project: Mujeed-Arabic-Prolog   File: CutListener.java   View Source Code Vote up 5 votes
@Override
public void actionPerformed(ActionEvent e) {
	// TODO Auto-generated method stub
	if(PrincipalWindow.tabbedPaneProgram.getComponentCount() != 0){
		JPanel selectedPanel = (JPanel) PrincipalWindow.tabbedPaneProgram.getComponentAt(PrincipalWindow.tabbedPaneProgram.getSelectedIndex());
		JScrollPane scrollPane = (JScrollPane) selectedPanel.getComponent(0);
		JTextPane textPaneCode = (JTextPane) scrollPane.getViewport().getComponent(0);
		textPaneCode.cut();
	}

}
 
Example 5
Project: Mujeed-Arabic-Prolog   File: UndoListener.java   View Source Code Vote up 5 votes
@Override
public void actionPerformed(ActionEvent e) {
	// TODO Auto-generated method stub
	if(PrincipalWindow.tabbedPaneProgram.getComponentCount() != 0){
		JPanel selectedPanel = (JPanel) PrincipalWindow.tabbedPaneProgram.getComponentAt(PrincipalWindow.tabbedPaneProgram.getSelectedIndex());
		JScrollPane scrollPane = (JScrollPane) selectedPanel.getComponent(0);
		JTextPane textPaneCode = (JTextPane) scrollPane.getViewport().getComponent(0);
		  try {
	            undo.undo();
	        } catch (CannotRedoException cre) {
	        }
	}

}
 
Example 6
Project: Mujeed-Arabic-Prolog   File: RedoListener.java   View Source Code Vote up 5 votes
@Override
public void actionPerformed(ActionEvent e) {
	// TODO Auto-generated method stub
	if(PrincipalWindow.tabbedPaneProgram.getComponentCount() != 0){
		JPanel selectedPanel = (JPanel) PrincipalWindow.tabbedPaneProgram.getComponentAt(PrincipalWindow.tabbedPaneProgram.getSelectedIndex());
		JScrollPane scrollPane = (JScrollPane) selectedPanel.getComponent(0);
		JTextPane textPaneCode = (JTextPane) scrollPane.getViewport().getComponent(0);
		 try {
	            undo.redo();
	        } catch (CannotRedoException cre) {
	        }
	}

}
 
Example 7
Project: Mujeed-Arabic-Prolog   File: SelectAllListener.java   View Source Code Vote up 5 votes
@Override
public void actionPerformed(ActionEvent e) {
	// TODO Auto-generated method stub
	if(PrincipalWindow.tabbedPaneProgram.getComponentCount() != 0){
		JPanel selectedPanel = (JPanel) PrincipalWindow.tabbedPaneProgram.getComponentAt(PrincipalWindow.tabbedPaneProgram.getSelectedIndex());
		JScrollPane scrollPane = (JScrollPane) selectedPanel.getComponent(0);
		JTextPane textPaneCode = (JTextPane) scrollPane.getViewport().getComponent(0);
		textPaneCode.selectAll();
	}
}
 
Example 8
Project: Mujeed-Arabic-Prolog   File: PasteListener.java   View Source Code Vote up 5 votes
@Override
public void actionPerformed(ActionEvent e) {
	// TODO Auto-generated method stub
	if(PrincipalWindow.tabbedPaneProgram.getComponentCount() != 0){
		JPanel selectedPanel = (JPanel) PrincipalWindow.tabbedPaneProgram.getComponentAt(PrincipalWindow.tabbedPaneProgram.getSelectedIndex());
		JScrollPane scrollPane = (JScrollPane) selectedPanel.getComponent(0);
		JTextPane textPaneCode = (JTextPane) scrollPane.getViewport().getComponent(0);
		textPaneCode.paste();
	}

}
 
Example 9
Project: Mujeed-Arabic-Prolog   File: SearchListener.java   View Source Code Vote up 5 votes
@Override
public void insertUpdate(DocumentEvent e) {
	// TODO Auto-generated method stub
	JPanel panel = (JPanel) PrincipalWindow.tabbedPaneProgram.getComponentAt(PrincipalWindow.tabbedPaneProgram.getSelectedIndex());
	JScrollPane scrollpane = (JScrollPane) panel.getComponent(0);
	JTextPane textPane = (JTextPane) scrollpane.getViewport().getComponent(0);
	search(textPane);

}
 
Example 10
Project: Mujeed-Arabic-Prolog   File: SearchListener.java   View Source Code Vote up 5 votes
@Override
public void removeUpdate(DocumentEvent e) {
	// TODO Auto-generated method stub
	JPanel panel = (JPanel) PrincipalWindow.tabbedPaneProgram.getComponentAt(PrincipalWindow.tabbedPaneProgram.getSelectedIndex());
	JScrollPane scrollpane = (JScrollPane) panel.getComponent(0);
	JTextPane textPane = (JTextPane) scrollpane.getViewport().getComponent(0);
	search(textPane);

}
 
Example 11
Project: rapidminer   File: OpenChartAction.java   View Source Code Vote up 4 votes
@Override
public void actionPerformed(ActionEvent e) {

	// look up the panel invoking the pop up invoking the action
	AttributeStatisticsPanel asp = null;

	// the action should only be invoked by AttributePopupMenus
	Container parent = ((JComponent) e.getSource()).getParent();
	if ((parent instanceof AttributePopupMenu)) {
		asp = ((AttributePopupMenu) parent).getAttributeStatisticsPanel();
	} else {
		asp = (AttributeStatisticsPanel) SwingUtilities.getAncestorOfClass(AttributeStatisticsPanel.class, parent);
		if (asp == null) {
			// we are not inside a AttributesStatisticPanel
			return;
		}
	}

	ButtonBarCardPanel cardPanel = (ButtonBarCardPanel) SwingUtilities.getAncestorOfClass(ButtonBarCardPanel.class, asp);
	AbstractAttributeStatisticsModel model = asp.getModel();

	// select the plotter view
	cardPanel.selectCard("plot_view");

	// get the opened plotter
	JPanel outerPanel = (JPanel) cardPanel.getShownComponent();
	for (Component innerComp : outerPanel.getComponents()) {
		if (innerComp instanceof PlotterPanel) {
			PlotterPanel plotterPanel = (PlotterPanel) outerPanel.getComponent(0);
			PlotterConfigurationModel settings = plotterPanel.getPlotterSettings();

			// adjust settings
			if (model instanceof NominalAttributeStatisticsModel) {
				settings.setPlotter(PlotterConfigurationModel.BAR_CHART);
				settings.setParameterAsString(PlotterConfigurationSettings.AXIS_PLOT_COLUMN, model.getAttribute()
						.getName());
				settings.setParameterAsString(PlotterConfigurationSettings.GROUP_BY_COLUMN, model.getAttribute()
						.getName());
			} else if (model instanceof NumericalAttributeStatisticsModel
					|| model instanceof DateTimeAttributeStatisticsModel) {
				settings.setPlotter(PlotterConfigurationModel.HISTOGRAM_PLOT);
				settings.setParameterAsString(PlotterConfigurationSettings.NUMBER_OF_BINS, "10");
				settings.setParameterAsString(PlotterConfigurationSettings.AXIS_PLOT_COLUMNS, model.getAttribute()
						.getName());
			}
			break;
		}
	}
}
 
Example 12
Project: Mujeed-Arabic-Prolog   File: CompileListener.java   View Source Code Vote up 4 votes
private void getReady() {
	for (int i=0; i<PrincipalWindow.interpreter.getKeyListeners().length; i++)
		PrincipalWindow.interpreter.removeKeyListener(PrincipalWindow.interpreter.getKeyListeners()[i]);
	PrincipalWindow.interpreter.addKeyListener(new KeyMonitor());
	PrincipalWindow.interpreter.requestFocus();
	String message;
	if(PrincipalWindow.tabbedPaneProgram.getTabCount()==0){
		message = "\n"+"#/>	"+"لا يوجد ملف يحوي قاعدة معرفة     ( إنشاء ملف  CTRL+N )"+"\n";
		FromGui.insert(PrincipalWindow.interpreter, message, new Color(204,0,0));
		FromGui.insert(PrincipalWindow.interpreter, "/>  ", Color.BLACK);
		PrincipalWindow.interpreter.setCaretPosition(PrincipalWindow.interpreter.getDocument().getLength());
	}
	else{
		String nameFile = PrincipalWindow.tabbedPaneProgram.getTitleAt(PrincipalWindow.tabbedPaneProgram.getSelectedIndex());
		if(nameFile.charAt(0)=='*'){
			message = "\n"+"#/>	"+"يجب حفظ الملف أوّلا     ( حفظ  CTRL+S )"+"\n";
			FromGui.insert(PrincipalWindow.interpreter, message, new Color(204,0,0));
			FromGui.insert(PrincipalWindow.interpreter, "/>  ", Color.BLACK);
			PrincipalWindow.interpreter.setCaretPosition(PrincipalWindow.interpreter.getDocument().getLength());
		}
		else { //Ready
			try {
				ArabicPrologBaseListener.code ="";
				message = "\n"+"#/>	"+"ملف قاعدة المعرفة :    "+PrincipalWindow.tabbedPaneProgram.getTitleAt(PrincipalWindow.tabbedPaneProgram.getSelectedIndex())+"\n";
				//Islamic green :-)
				Color islamicGreen = new Color(	0	,144,	0);
				FromGui.insert(PrincipalWindow.interpreter, message, islamicGreen);
				PrincipalWindow.interpreter.setCaretPosition(PrincipalWindow.interpreter.getDocument().getLength());
				
				int indexTab = PrincipalWindow.tabbedPaneProgram.getSelectedIndex();
				JPanel panelCode = (JPanel) PrincipalWindow.tabbedPaneProgram.getComponentAt(indexTab);
				JScrollPane scrollpaneToSave = (JScrollPane) panelCode.getComponent(0);
				JTextPane textPaneCode = (JTextPane) scrollpaneToSave.getViewport().getComponent(0);
				Parser parser = new Parser();
				parser.createknowledgeBase(textPaneCode.getText());
			}
			catch( Exception e1){
				message = "\n"+"#/>	"+"خطأ في قاعدة المعرفة"+"\n";
				e1.printStackTrace();
				FromGui.insert(PrincipalWindow.interpreter, message, new Color(204,0,0));
				FromGui.insert(PrincipalWindow.interpreter, "/>  ", Color.BLACK);
				PrincipalWindow.interpreter.setCaretPosition(PrincipalWindow.interpreter.getDocument().getLength());
			}
		}
	}
}