本文整理匯總了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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();
}
示例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);
}
示例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)
);
}
示例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();
}
示例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)
);
}
示例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);
}
示例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);
}
示例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);
}
示例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();
}