当前位置: 首页>>代码示例>>Java>>正文


Java ComponentEvent类代码示例

本文整理汇总了Java中java.awt.event.ComponentEvent的典型用法代码示例。如果您正苦于以下问题:Java ComponentEvent类的具体用法?Java ComponentEvent怎么用?Java ComponentEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ComponentEvent类属于java.awt.event包,在下文中一共展示了ComponentEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: componentResized

import java.awt.event.ComponentEvent; //导入依赖的package包/类
/**
 * May be called for either component or horizontal scrollbar.
 */
public @Override void componentResized(ComponentEvent e) {
    Component c = e.getComponent();
    if (c == component) { // called for component
        // In case the caretBounds are still null
        // (component not connected to hierarchy yet or it has zero size
        // so the modelToView() returned null) re-attempt to compute the bounds.
        CaretItem caret = getLastCaretItem();
        if (caret.getCaretBounds() == null) {
            dispatchUpdate(false);
            resetBlink();
            if (caret.getCaretBounds() != null) { // detach the listener - no longer necessary
                c.removeComponentListener(this);
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:EditorCaret.java

示例2: updateValues

import java.awt.event.ComponentEvent; //导入依赖的package包/类
@Override
protected void updateValues(ComponentEvent e) {
	//			Get the textfield
	JTextField sourcefield = (JTextField) e.getSource();
	try {
		// Get the probability entered in the textfield
		Double probability = new Double(Double.parseDouble(sourcefield.getText()));
		//Probability has to be smaller or equal than 1 (otherwise don't update value)
		if (probability.doubleValue() <= 1.0) {
			//If the probability was entered into the probability field of interval B
			//then the probability parameter in the distribution has to be set to 1-enteredProbability
			if (sourcefield.getName().equals(PROBABILITY_INTERVAL_B)) {
				probability = new Double(1 - probability.doubleValue());

			}
			//set the parameter
			current.getParameter(0).setValue(probability);
		}
	} catch (NumberFormatException ex) {
		//If user enters a value that is not a number -> reset value back to the value before
	}

	refreshValues();

}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:26,代码来源:DistributionsEditor.java

示例3: setComponent

import java.awt.event.ComponentEvent; //导入依赖的package包/类
/**
 * Sets the component to be shown.
 * @param component the component to be shown.
 * @param parent the container to which the shown component should be added.
 *               This parameter can be null if you add the component yourself.
 */
public void setComponent(Component component) {
    this.component = component;
    if (null != component) {
        component.addComponentListener(new ComponentAdapter() {

            @Override
            public void componentHidden(ComponentEvent e) {
                if (null != unselectButton && isSelected()) {
                    unselectButton.setSelected(true);
                }
            }
            
        });
    }
}
 
开发者ID:Esri,项目名称:defense-solutions-proofs-of-concept,代码行数:22,代码来源:ComponentShowingButton.java

示例4: initGUI

import java.awt.event.ComponentEvent; //导入依赖的package包/类
@Override
public void initGUI() {
    if (windowClass.equals(Frame.class)) {
        window = new Frame();
        ((Frame) window).setUndecorated(true);
    } else  if (windowClass.equals(Dialog.class)) {
        window = new Dialog(background);
        ((Dialog) window).setUndecorated(true);
    } else {
        window = new Window(background);
    }
    window.setBackground(FG_COLOR);
    window.addComponentListener(new ComponentAdapter() {
        @Override
        public void componentResized(ComponentEvent e) {
            window.setShape(shape);
        }
    });
    window.setSize(200, 200);
    window.setLocation(2*dl, 2*dl);
    window.setVisible(true);

    System.out.println("Checking " + window.getClass().getName() + "...");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:SetShape.java

示例5: AutoHideStatusText

import java.awt.event.ComponentEvent; //导入依赖的package包/类
private AutoHideStatusText( JFrame frame, JPanel statusContainer  ) {
    this.statusContainer = statusContainer;
    Border outerBorder = UIManager.getBorder( "Nb.ScrollPane.border" ); //NOI18N
    if( null == outerBorder ) {
        outerBorder = BorderFactory.createEtchedBorder();
    }
    panel.setBorder( BorderFactory.createCompoundBorder( outerBorder, 
            BorderFactory.createEmptyBorder(3,3,3,3) ) );
    lblStatus.setName("AutoHideStatusTextLabel"); //NOI18N
    panel.add( lblStatus, BorderLayout.CENTER );
    frame.getLayeredPane().add( panel, Integer.valueOf( 101 ) );
    StatusDisplayer.getDefault().addChangeListener( this );

    frame.addComponentListener( new ComponentAdapter() {
        @Override
        public void componentResized( ComponentEvent e ) {
            run();
        }
    });
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:AutoHideStatusText.java

示例6: FontPanel

import java.awt.event.ComponentEvent; //导入依赖的package包/类
public FontPanel( Font2DTest demo, JFrame f ) {
    f2dt = demo;
    parent = f;

    verticalBar = new JScrollBar ( JScrollBar.VERTICAL );
    fc = new FontCanvas();

    this.setLayout( new BorderLayout() );
    this.add( "Center", fc );
    this.add( "East", verticalBar );

    verticalBar.addAdjustmentListener( this );
    this.addComponentListener( new ComponentAdapter() {
        public void componentResized( ComponentEvent e ) {
            updateFontMetrics = true;
        }
    });

    /// Initialize font and its infos
    testFont = new Font(fontName, fontStyle, (int)fontSize);
    if ((float)((int)fontSize) != fontSize) {
        testFont = testFont.deriveFont(fontSize);
    }
    updateFontInfo();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:FontPanel.java

示例7: adicionarBotaoEditar

import java.awt.event.ComponentEvent; //导入依赖的package包/类
private void adicionarBotaoEditar() {
    Tela t = this;
    btnEditar = new JButton("Editar");
    adicionarComponente(btnEditar, GridBagConstraints.EAST, 
                GridBagConstraints.NONE, 0, 0, 2, 1);
    btnEditar.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            TelaEditarMusica tem = new TelaEditarMusica(musica.getNome(), musica, t);
            tem.setVisible(true);
            tem.addComponentListener(new ComponentAdapter() {
                @Override
                public void componentHidden(ComponentEvent e) {
                    musica = tem.getMusica();
                    editou = true;
                    adicionarValores();
                }
            });
        }
    });
}
 
开发者ID:k4t0mono,项目名称:BachSys,代码行数:22,代码来源:TelaDadosMusica.java

示例8: ensureMinimumSize

import java.awt.event.ComponentEvent; //导入依赖的package包/类
public static void ensureMinimumSize(Component comp) {
    comp = getParentWindow(comp);

    if (comp != null) {
        final Component top = comp;
        top.addComponentListener(new ComponentAdapter() {
                public void componentResized(ComponentEvent e) {
                    Dimension d = top.getSize();
                    Dimension min = top.getMinimumSize();

                    if ((d.width < min.width) || (d.height < min.height)) {
                        top.setSize(Math.max(d.width, min.width), Math.max(d.height, min.height));
                    }
                }
            });
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:UIUtils.java

示例9: FontPanel

import java.awt.event.ComponentEvent; //导入依赖的package包/类
public FontPanel( Font2DTest demo, JFrame f ) {
    f2dt = demo;
    parent = f;

    verticalBar = new JScrollBar ( JScrollBar.VERTICAL );
    fc = new FontCanvas();

    this.setLayout( new BorderLayout() );
    this.add( "Center", fc );
    this.add( "East", verticalBar );

    verticalBar.addAdjustmentListener( this );
    this.addComponentListener( new ComponentAdapter() {
        public void componentResized( ComponentEvent e ) {
            updateBackBuffer = true;
            updateFontMetrics = true;
        }
    });

    /// Initialize font and its infos
    testFont = new Font(fontName, fontStyle, (int)fontSize);
    if ((float)((int)fontSize) != fontSize) {
        testFont = testFont.deriveFont(fontSize);
    }
    updateFontInfo();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:27,代码来源:FontPanel.java

示例10: updateValues

import java.awt.event.ComponentEvent; //导入依赖的package包/类
@Override
protected void updateValues(ComponentEvent e) {
	// Finds parameter number
	JTextField sourcefield = (JTextField) e.getSource();
	int num = Integer.parseInt(sourcefield.getName());
	current.getParameter(num).setValue(sourcefield.getText());
	current.updateCM();
	refreshValues();
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:10,代码来源:DistributionsEditor.java

示例11: resize

import java.awt.event.ComponentEvent; //导入依赖的package包/类
@Override
public void resize(ComponentOperator oper, int width, int height) {
    checkSupported(oper);
    oper.setSize(width, height);
    eDriver.dispatchEvent(oper.getSource(),
            new ComponentEvent(oper.getSource(),
                    ComponentEvent.COMPONENT_RESIZED));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:DefaultWindowDriver.java

示例12: installResizeHandler

import java.awt.event.ComponentEvent; //导入依赖的package包/类
private void installResizeHandler() {
    addComponentListener(new ComponentAdapter() {
        public void componentResized(ComponentEvent e) {
            fileTab.getGraphComponent().zoomAndCenter();
        }
    });
}
 
开发者ID:Blenta,项目名称:intellij-bpmn-editor,代码行数:8,代码来源:BPMNEditorDiagramTab.java

示例13: componentResized

import java.awt.event.ComponentEvent; //导入依赖的package包/类
/**
 * Applies the shape to window. It is recommended to apply shape in
 * componentResized() method
 */
@Override
public void componentResized(ComponentEvent e) {

    // We do apply shape only if PERPIXEL_TRANSPARENT is supported
    if (transparencySupported) {
        setShape(buildShape());
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:13,代码来源:Ruler.java

示例14: installResizeHandler

import java.awt.event.ComponentEvent; //导入依赖的package包/类
/**
 * Applies the zoom policy if the size of the component changes.
 */
protected void installResizeHandler()
{
	addComponentListener(new ComponentAdapter()
	{
		public void componentResized(ComponentEvent e)
		{
			zoomAndCenter();
		}
	});
}
 
开发者ID:GDSRS,项目名称:TrabalhoFinalEDA2,代码行数:14,代码来源:mxGraphComponent.java

示例15: componentResized

import java.awt.event.ComponentEvent; //导入依赖的package包/类
@Override
public void componentResized(ComponentEvent e) 
{
	/*
	 * This method is responsible for the Array Board always being the dimensions of the User Interface.
	 * This is necessary when the user changes the size of the Cells within the Array. 
	 * This inadvertently makes the array smaller and thus, the board ensure the array will stay the same size while adding more cells to accomodate.
	 * This calls the Update Universe Method.
	 */
	// Setup the game board size with proper boundaries
	GameOfLifeDimensions = new Dimension(getWidth()/cellSize-2, getHeight()/cellSize-2);
	updateUniverseSize();
}
 
开发者ID:Mannjamin,项目名称:Manns-Game-of-Life-Updated-Version,代码行数:14,代码来源:MGoL_Backend.java


注:本文中的java.awt.event.ComponentEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。