本文整理汇总了Java中javax.swing.JPanel.getComponent方法的典型用法代码示例。如果您正苦于以下问题:Java JPanel.getComponent方法的具体用法?Java JPanel.getComponent怎么用?Java JPanel.getComponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JPanel
的用法示例。
在下文中一共展示了JPanel.getComponent方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: evaluateExpression
import javax.swing.JPanel; //导入方法依赖的package包/类
/**
* 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());
}
示例2: actionPerformed
import javax.swing.JPanel; //导入方法依赖的package包/类
@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) {
}
}
}
示例3: okButtonActionPerformed
import javax.swing.JPanel; //导入方法依赖的package包/类
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);
}
示例4: actionPerformed
import javax.swing.JPanel; //导入方法依赖的package包/类
@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();
}
}
示例5: actionPerformed
import javax.swing.JPanel; //导入方法依赖的package包/类
@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();
}
}
示例6: actionPerformed
import javax.swing.JPanel; //导入方法依赖的package包/类
@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) {
}
}
}
示例7: actionPerformed
import javax.swing.JPanel; //导入方法依赖的package包/类
@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();
}
}
示例8: actionPerformed
import javax.swing.JPanel; //导入方法依赖的package包/类
@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();
}
}
示例9: insertUpdate
import javax.swing.JPanel; //导入方法依赖的package包/类
@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);
}
示例10: removeUpdate
import javax.swing.JPanel; //导入方法依赖的package包/类
@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);
}
示例11: actionPerformed
import javax.swing.JPanel; //导入方法依赖的package包/类
@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;
}
}
}
示例12: getReady
import javax.swing.JPanel; //导入方法依赖的package包/类
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());
}
}
}
}