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


Java JWindow.add方法代码示例

本文整理汇总了Java中javax.swing.JWindow.add方法的典型用法代码示例。如果您正苦于以下问题:Java JWindow.add方法的具体用法?Java JWindow.add怎么用?Java JWindow.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JWindow的用法示例。


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

示例1: testSetNodesSurvivesMultipleAdd_RemoveNotifyCalls

import javax.swing.JWindow; //导入方法依赖的package包/类
public void testSetNodesSurvivesMultipleAdd_RemoveNotifyCalls() throws Exception {
    final PropertySheet ps = new PropertySheet();
    Node n = new AbstractNode( Children.LEAF );
    JWindow window = new JWindow();
    ps.setNodes( new Node[] {n} );
    window.add( ps );
    window.remove( ps );
    window.add( ps );
    window.remove( ps );
    window.add( ps );
    window.remove( ps );
    window.setVisible(true);
    assertNotNull(ps.helperNodes);
    assertEquals("Helper nodes are still available even after several addNotify()/removeNotify() calls",
            ps.helperNodes[0], n);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:MorePropertySheetTest.java

示例2: show

import javax.swing.JWindow; //导入方法依赖的package包/类
public void show(Point location) {
    Rectangle screenBounds = null;
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] gds = ge.getScreenDevices();
    for (GraphicsDevice device : gds) {
        GraphicsConfiguration gc = device.getDefaultConfiguration();
        screenBounds = gc.getBounds();
        if (screenBounds.contains(location)) {
            break;
        }
    }

    // showing the popup tooltip
    cp = new TooltipContentPanel(master.getTextComponent());

    Window w = SwingUtilities.windowForComponent(master.getTextComponent());
    contentWindow = new JWindow(w);
    contentWindow.add(cp);
    contentWindow.pack();
    Dimension dim = contentWindow.getSize();

    if (location.y + dim.height + SCREEN_BORDER > screenBounds.y + screenBounds.height) {
        dim.height = (screenBounds.y + screenBounds.height) - (location.y + SCREEN_BORDER);
    }
    if (location.x + dim.width + SCREEN_BORDER > screenBounds.x + screenBounds.width) {
        dim.width = (screenBounds.x + screenBounds.width) - (location.x + SCREEN_BORDER);
    }

    contentWindow.setSize(dim);

    contentWindow.setLocation(location.x, location.y - 1);  // slight visual adjustment
    contentWindow.setVisible(true);

    Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.MOUSE_EVENT_MASK | AWTEvent.KEY_EVENT_MASK);
    w.addWindowFocusListener(this);
    contentWindow.addWindowFocusListener(this);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:38,代码来源:TooltipWindow.java

示例3: show

import javax.swing.JWindow; //导入方法依赖的package包/类
public void show(Point location) {
    Rectangle screenBounds = null;
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] gds = ge.getScreenDevices();
    for (GraphicsDevice device : gds) {
        GraphicsConfiguration gc = device.getDefaultConfiguration();
        screenBounds = gc.getBounds();
        if (screenBounds.contains(location)) {
            break;
        }
    }

    // showing the popup tooltip
    cp = new TooltipContentPanel(master.getTextComponent());
    Window w = SwingUtilities.windowForComponent(master.getTextComponent());
    contentWindow = new JWindow(w);
    contentWindow.add(cp);
    contentWindow.pack();
    Dimension dim = contentWindow.getSize();

    if (location.y + dim.height + SCREEN_BORDER > screenBounds.y + screenBounds.height) {
        dim.height = (screenBounds.y + screenBounds.height) - (location.y + SCREEN_BORDER);
    }
    if (location.x + dim.width + SCREEN_BORDER > screenBounds.x + screenBounds.width) {
        dim.width = (screenBounds.x + screenBounds.width) - (location.x + SCREEN_BORDER);
    }

    contentWindow.setSize(dim);

    contentWindow.setLocation(location.x, location.y - 1);  // slight visual adjustment
    contentWindow.setVisible(true);
    Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.MOUSE_EVENT_MASK | AWTEvent.KEY_EVENT_MASK);
    w.addWindowFocusListener(this);
    contentWindow.addWindowFocusListener(this);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:36,代码来源:TooltipWindow.java

示例4: createInfoWindow

import javax.swing.JWindow; //导入方法依赖的package包/类
/**
 * Creates the window for the info popup. This should only be run once and
 * then reused, only changing the text and size.
 */
private void createInfoWindow() {
    infoWindow = new JWindow(SwingUtilities.getWindowAncestor(textField));
    infoLabel = new JLabel();
    infoWindow.add(infoLabel);
    JPanel contentPane = (JPanel) infoWindow.getContentPane();
    Border border = BorderFactory.createCompoundBorder(
            BorderFactory.createLineBorder(Color.GRAY),
            BorderFactory.createEmptyBorder(2, 4, 2, 4));
    contentPane.setBorder(border);
    contentPane.setBackground(HtmlColors.decode("#EEEEEE"));
    infoLabel.setFont(textField.getFont());

    /**
     * Hide the info popup if the textfield or containing window is changed
     * in any way.
     */
    containingWindow = SwingUtilities.getWindowAncestor(textField);
    if (containingWindow != null) {
        containingWindow.addComponentListener(componentListener);
    }
    textField.addComponentListener(componentListener);
}
 
开发者ID:chatty,项目名称:chatty,代码行数:27,代码来源:AutoCompletion.java

示例5: showSplashScreen

import javax.swing.JWindow; //导入方法依赖的package包/类
/** Construct a splash screen. */
public void showSplashScreen() {
	// create window, apply image
	JWindow window = new JWindow();
	ImageIcon icon = new ImageIcon("img/SQLizard.jpg");
	JLabel label = new JLabel(icon);

	window.add(label);

	Toolkit tk = Toolkit.getDefaultToolkit();
	int width = ((int) tk.getScreenSize().getWidth());
	int height = ((int) tk.getScreenSize().getHeight());

	window.setBounds((width / 2) - 440, (height / 2) - 245, 880, 495);
	window.setVisible(true);

	// provide splash screen loading effect
	try {
		Thread.sleep(2000);
	} catch (InterruptedException e) {
		e.printStackTrace();
	}

	window.setVisible(false);
}
 
开发者ID:rsanchez-wsu,项目名称:sp16-ceg3120,代码行数:26,代码来源:SplashScreen.java

示例6: SwingSplashScreen

import javax.swing.JWindow; //导入方法依赖的package包/类
SwingSplashScreen(BufferedImage image, int width, int height) {
        window = new JWindow((Window) null);
        window.setBackground(new Color(0, 0, 0, 0));
        window.setSize(width, height);
        window.setLocationRelativeTo(null);

        // alwaysOnTop keeps the LWJGL2 Display window from popping up and it can't be triggered manually
//        window.setAlwaysOnTop(true);

        window.add(new Component() {

            private static final long serialVersionUID = 1717818903226627606L;

            @Override
            public void paint(Graphics g) {
                if (image != null) {
                    g.drawImage(image, 0, 0, width, height, null);
                }
                for (Overlay overlay : getOverlays()) {
                    overlay.render((Graphics2D) g);
                }
            }
        });

        window.setVisible(true);
    }
 
开发者ID:MovingBlocks,项目名称:SplashScreen,代码行数:27,代码来源:SwingSplashScreen.java

示例7: MesquiteFileDialog

import javax.swing.JWindow; //导入方法依赖的package包/类
public MesquiteFileDialog (MesquiteWindow f, String message, int type) {
	super(getFrame(f), message, type);
	if (type == FileDialog.LOAD &&  (MesquiteTrunk.isMacOS() || MesquiteTrunk.isMacOSX()) && MesquiteTrunk.getOSXVersion()>10){
		titleWindow = new JWindow(); 
		titleWindow.setSize(twWidth,twHeight);
		titleWindowLabel = new Label();
		titleWindowLabel.setBackground(ColorDistribution.veryLightYellow); //ColorTheme.getExtInterfaceBackground()); //ColorDistribution.veryLightGray
		titleWindow.add(titleWindowLabel);
		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
		int v, h;
		h = (screenSize.width-twWidth)/2;
		v = 26;
		titleWindow.setLocation(h, v);
		titleWindowLabel.setText("  " + message);
	//	Color darkBlue = new Color((float)0.0, (float)0.0, (float)0.7);
		titleWindowLabel.setForeground(ColorDistribution.darkBlue); //ColorTheme.getExtInterfaceElement(true));

	}
	this.message = message;
	this.type = type;
	currentFileDialog = this;
	//mfdThread = new MFDThread(this);
	//mfdThread.start();
	MainThread.incrementSuppressWaitWindow();
}
 
开发者ID:MesquiteProject,项目名称:MesquiteCore,代码行数:26,代码来源:MesquiteFileDialog.java

示例8: show

import javax.swing.JWindow; //导入方法依赖的package包/类
void show(Point location) {
    Rectangle screenBounds = null;
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] gds = ge.getScreenDevices();
    for (GraphicsDevice device : gds) {
        GraphicsConfiguration gc = device.getDefaultConfiguration();
        screenBounds = gc.getBounds();
        if (screenBounds.contains(location)) {
            break;
        }
    }

    // showing the popup tooltip
    cp = new TooltipContentPanel();
    Window w = SwingUtilities.windowForComponent(parent);
    contentWindow = new JWindow(w);
    contentWindow.add(cp);
    contentWindow.pack();
    Dimension dim = contentWindow.getSize();

    if (screenBounds.width + screenBounds.x - location.x < cp.longestLine) {
        // the whole window does fully not fit to the right
        // the x position where the window has to start to fully fit to the right
        int left = screenBounds.width + screenBounds.x - cp.longestLine;
        // the window should have x pos minimally at the screen's start
        location.x = Math.max(screenBounds.x, left);
    }
    
    if (location.y + dim.height + SCREEN_BORDER > screenBounds.y + screenBounds.height) {
        dim.height = (screenBounds.y + screenBounds.height) - (location.y + SCREEN_BORDER);
    }
    if (location.x + dim.width + SCREEN_BORDER > screenBounds.x + screenBounds.width) {
        dim.width = (screenBounds.x + screenBounds.width) - (location.x + SCREEN_BORDER);
    }

    contentWindow.setSize(dim);

    contentWindow.setLocation(location.x, location.y + 1);  // slight visual adjustment
    
    contentWindow.setVisible(true);
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            cp.scrollRectToVisible(new Rectangle(1, 1));
        }
    });
    Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.MOUSE_EVENT_MASK | AWTEvent.KEY_EVENT_MASK);
    w.addWindowFocusListener(this);
    contentWindow.addWindowFocusListener(this);
    contentWindow.addKeyListener(this);
    w.addKeyListener(this);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:53,代码来源:MsgTooltipWindow.java

示例9: JLockWindow

import javax.swing.JWindow; //导入方法依赖的package包/类
public JLockWindow(final Window parent) {
	this.parent = parent;
	jWindow = new JWindow(parent);

	jProgress = new JProgressBar(0, 100);

	JPanel jPanel = new JPanel();
	jPanel.setBorder(BorderFactory.createRaisedBevelBorder());
	GroupLayout layout = new GroupLayout(jPanel);
	jPanel.setLayout(layout);
	layout.setAutoCreateGaps(true);
	layout.setAutoCreateContainerGaps(true);
	jWindow.add(jPanel);

	jLabel = new JLabel();


	layout.setHorizontalGroup(
		layout.createParallelGroup(GroupLayout.Alignment.CENTER)
			.addComponent(jLabel)
			.addComponent(jProgress)
	);
	layout.setVerticalGroup(
		layout.createSequentialGroup()
			.addComponent(jLabel)
			.addComponent(jProgress)
	);
}
 
开发者ID:GoldenGnu,项目名称:jeveassets,代码行数:29,代码来源:JLockWindow.java

示例10: showSplashWindow

import javax.swing.JWindow; //导入方法依赖的package包/类
/**
 * <p>Displays a splash window for <code>duration</code> milliseconds displaying the specified <code>image</code>.
 * An optional <code>actionListener</code> can be attached to perform a function after the splash window has
 * closed. If null is specified then the default listener will be used.</p>
 * 
 * @param image
 *      - the image icon to display
 * @param duration
 *      - how long to show the window (milliseconds)
 * @param windowSize
 *      - the size of the window
 * @param frameOwner
 *      - the parent window or owner, null if none
 * @param actionListener
 *      - a custom actionListener to be performed after the splash window is closed
 */
public static void showSplashWindow(ImageIcon image, int duration, Dimension windowSize, Window frameOwner, ActionListener actionListener) {
        JLabel splashImage = new JLabel();
        splashImage.setHorizontalAlignment(JLabel.CENTER);
        splashImage.setOpaque(true);
        splashImage.setIcon(image);

        final JWindow window = new JWindow(frameOwner);
        window.add(splashImage, BorderLayout.CENTER);
        window.setSize(windowSize);
        splashImage.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
        UITool.center(window);
        window.setVisible(true);
        
        ActionListener defaultActionListener = new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                        window.setVisible(false);
                        window.dispose();
                }
        };
        
        Timer timer = new Timer(duration, defaultActionListener);
        if(actionListener != null) {
                timer.addActionListener(actionListener);
        }

        timer.setRepeats(false);
        timer.start();
}
 
开发者ID:george-haddad,项目名称:CIMMYT,代码行数:46,代码来源:UITool.java

示例11: JLockWindow

import javax.swing.JWindow; //导入方法依赖的package包/类
public JLockWindow(final Window parent) {
	this.parent = parent;
	jWindow = new JWindow(parent);

	JPanel jPanel = new JPanel();
	jPanel.setBorder(BorderFactory.createRaisedBevelBorder());
	GroupLayout layout = new GroupLayout(jPanel);
	jPanel.setLayout(layout);
	layout.setAutoCreateGaps(true);
	layout.setAutoCreateContainerGaps(true);
	jWindow.add(jPanel);

	jLabel = new JLabel();

	jStop = new JButton("Stop");
	jStop.addActionListener(new ActionListener() {
		@Override
		public void actionPerformed(ActionEvent e) {
			if (startAndStop != null) {
				startAndStop.stop();
			}
		}
	});


	layout.setHorizontalGroup(
		layout.createParallelGroup(GroupLayout.Alignment.CENTER)
			.addComponent(jLabel)
			.addComponent(jStop, 80, 80, 80)
	);
	layout.setVerticalGroup(
		layout.createSequentialGroup()
			.addComponent(jLabel)
			.addComponent(jStop)
	);
}
 
开发者ID:GoldenGnu,项目名称:jwarframe,代码行数:37,代码来源:JLockWindow.java

示例12: initialise

import javax.swing.JWindow; //导入方法依赖的package包/类
private void initialise(double[] data, double[] xCategories, String[] toolTipLabels, String xLabel, String yLabel, String graphTitle) {
	this.data = data;
	this.xCategories = xCategories;
	this.toolTipLabels = toolTipLabels;
	this.xLabel = xLabel;
	this.yLabel = yLabel;
	this.graphTitle = graphTitle;		

	// calculate minX-maxX, minY-maxY and xInterval-yInterval
	double[] minmax = new double[]{Double.MAX_VALUE, Double.MIN_VALUE};
	calculateMinMax(this.data, minmax);
	minY = minmax[0];
	maxY = minmax[1] + minmax[1]*0.1;  // let's give some extra 10% space
	yInterval = findOptimalYInterval(maxY);
	
	minmax = new double[]{Double.MAX_VALUE, Double.MIN_VALUE};
	calculateMinMax(this.xCategories, minmax);
	minX = minmax[0];
	maxX = minmax[1] + minmax[1]*0.1;  // let's give some extra 10% space
	xInterval = findOptimalYInterval(maxX);
	
	// TOOL TIPS management
       label.setHorizontalAlignment(JLabel.CENTER);
       label.setOpaque(true);
   	label.setBackground(Color.WHITE);
       label.setBorder(UIManager.getBorder("ToolTip.border"));
       if(!GraphicsEnvironment.isHeadless()) {
       	toolTip = new JWindow();
       	toolTip.add(label);
   		// Tool tips
           tipster = new Tipster(this);
           addMouseMotionListener(tipster);
       }
       setOpaque(true);
}
 
开发者ID:s-andrews,项目名称:BamQC,代码行数:36,代码来源:ScatterGraph.java

示例13: LineWithHorizontalBarGraph

import javax.swing.JWindow; //导入方法依赖的package包/类
public LineWithHorizontalBarGraph(double[] barData, double[] lineData, double minY, double maxY, String xLabel, String[] barLabels, String xTitle, String[] xCategories, String graphTitle, String barDataLabel) {
	this.barData = barData;
	this.lineData = lineData;
	this.minY = 0-minY*(1.5*minY);
	this.maxY = maxY*(1.5*maxY);
	this.barLabels = barLabels;		
	this.xTitle = xTitle;
	this.xLabel = xLabel;
	this.xCategories = xCategories;
	this.graphTitle = graphTitle;
	this.barDataLabel = barDataLabel;
	this.yInterval = findOptimalYInterval(maxY);
	
	// TOOL TIPS management
       label.setHorizontalAlignment(JLabel.CENTER);
       label.setOpaque(true);
   	label.setBackground(Color.WHITE);
       label.setBorder(UIManager.getBorder("ToolTip.border"));
       if(!GraphicsEnvironment.isHeadless()) {
       	toolTip = new JWindow();
       	toolTip.add(label);
   		// Tool tips
           tipster = new Tipster(this);
           addMouseMotionListener(tipster);
       }
       setOpaque(true);
}
 
开发者ID:s-andrews,项目名称:BamQC,代码行数:28,代码来源:LineWithHorizontalBarGraph.java

示例14: initializeSlider

import javax.swing.JWindow; //导入方法依赖的package包/类
private void initializeSlider(TopicMapGraphPanel gp) {
    int minValue = getMinValue(gp);
    int maxValue = getMaxValue(gp);
    int defaultValue = getDefaultValue(gp);
    
    if(defaultValue < minValue) defaultValue = minValue;
    if(defaultValue > maxValue) defaultValue = maxValue;

    slider = new SimpleSlider(SimpleSlider.HORIZONTAL, minValue, maxValue, defaultValue);
    sliderLabel = new SimpleLabel();
    sliderPopup = new JWindow();

    slider.setPreferredSize(new Dimension(120, 24));
    slider.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    
    sliderLabel.setFont(UIConstants.smallButtonLabelFont);
    sliderLabel.setPreferredSize(new Dimension(30, 24));
    sliderLabel.setHorizontalAlignment(SimpleLabel.CENTER);
    
    JPanel panel = new JPanel();
    panel.setBorder(new LineBorder(UIConstants.defaultBorderShadow));
    panel.setLayout(new BorderLayout(2,2));
    panel.add(slider, BorderLayout.CENTER);
    panel.add(sliderLabel, BorderLayout.EAST);

    sliderPopup.setLayout(new BorderLayout(2,2));
    sliderPopup.add(panel, BorderLayout.CENTER);
    sliderPopup.setSize(150, 24);

    // sliderPopup.addMouseListener(this);
    sliderPopup.setAlwaysOnTop(true);
    
    slider.addChangeListener(this);
    slider.addMouseListener(this);
}
 
开发者ID:wandora-team,项目名称:wandora,代码行数:36,代码来源:AbstractSliderTool.java

示例15: run

import javax.swing.JWindow; //导入方法依赖的package包/类
public void run()
{
    splash = new JWindow();
    JPanel content = new JPanel();
    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    URL url=ClassLoader.getSystemResource("Data/splash.jpg");
    JLabel label = new JLabel(new ImageIcon(url));
    content.add(label,BorderLayout.CENTER);
    content.setBorder(BorderFactory.createLineBorder(Color.black, 1));
    splash.add(content);
    splash.pack();
    Dimension s=splash.getSize();
    int x = (screen.width-s.width)/2;
    int y = (screen.height-s.height)/2;
    splash.setBounds(x,y,s.width,s.height);
    AWTUtilities.setWindowOpacity(splash,Float.valueOf(0));
    ii=0;
    splash.setVisible(true);
    alphaChanger = new Timer(60,new ActionListener() {
        private float incrementer = .1f;
        @Override 
        public void actionPerformed(ActionEvent e)
        {
           ii=ii+incrementer;
           if(ii>((float)0.9))
           {   
               alphaChanger.stop();
               AWTUtilities.setWindowOpacity(splash,Float.valueOf(1));
               try{
                   Thread.sleep(1500);
                }catch(InterruptedException ex){}
                splash.setVisible(false);
            }
           AWTUtilities.setWindowOpacity(splash,Float.valueOf(ii));
        }
    });
    alphaChanger.start();
}
 
开发者ID:ayushmaanbhav,项目名称:iitpwebapp,代码行数:39,代码来源:Splash.java


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