當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。