本文整理匯總了Java中javax.swing.JWindow類的典型用法代碼示例。如果您正苦於以下問題:Java JWindow類的具體用法?Java JWindow怎麽用?Java JWindow使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
JWindow類屬於javax.swing包,在下文中一共展示了JWindow類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: WindowNotification
import javax.swing.JWindow; //導入依賴的package包/類
public WindowNotification() {
m_window = new JWindow();
m_window.setAlwaysOnTop(true);
m_listener = new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
fireListeners(CLICKED);
if (m_closeOnClick)
removeFromManager();
}
};
setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);
setPanel(new JPanel());
}
示例2: 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);
}
示例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: 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);
}
示例5: getJWindowCount
import javax.swing.JWindow; //導入依賴的package包/類
public static int getJWindowCount() {
return new QueueTool().invokeAndWait(new QueueTool.QueueAction<Integer>(null) {
@Override
public Integer launch() throws Exception {
Window[] windows = Window.getWindows();
int windowCount = 0;
for (Window w : windows) {
if (w.getClass().equals(JWindow.class)) {
windowCount++;
}
}
return windowCount;
}
});
}
示例6: getJWindow
import javax.swing.JWindow; //導入依賴的package包/類
public static JWindow getJWindow(int index) {
return new QueueTool().invokeAndWait(new QueueTool.QueueAction<JWindow>(null) {
@Override
public JWindow launch() throws Exception {
Window[] windows = Window.getWindows();
int windowIndex = 0;
for (Window w : windows) {
if (w.getClass().equals(JWindow.class)) {
if (windowIndex == index) {
return (JWindow) w;
}
windowIndex++;
}
}
return null;
}
});
}
示例7: show
import javax.swing.JWindow; //導入依賴的package包/類
public static JWindow show( Frame parent ) {
final JWindow window = new KSUCreditsWindow( parent );
SwingUtils.centerInParent( window );
window.setVisible( true );
/*
* Dispose of ksuCreditsWindow after N seconds.
* Take care to call dispose in the Swing thread.
*/
Timer timer = new Timer( 4000, new ActionListener() {
public void actionPerformed( ActionEvent e ) {
if ( window.isDisplayable() ) {
window.dispose();
}
}
} );
timer.setRepeats( false );
timer.start();
return window;
}
示例8: init
import javax.swing.JWindow; //導入依賴的package包/類
public static void init( Window applicationWindow ) {
if ( inited ) {
throw new RuntimeException( "Multiple inits." );
}
// System.out.println( "Setting repaintManagerPhet." );
RepaintManager.setCurrentManager( repaintManagerPhet );
offscreen = new JWindow( applicationWindow ) {
public void invalidate() {
}
public void paint( Graphics g ) {
}
}; //this seems to work. I thought you might have needed a visible component, though (maybe for some JVM implementations?)
// System.out.println( "offscreen.getOwner() = " + offscreen.getOwner() );
// offscreen.getOwner().setVisible( true );
offscreen.setSize( 0, 0 );
offscreen.setVisible( true );
offscreenContentPane.setOpaque( false );
offscreen.setContentPane( offscreenContentPane );
inited = true;
}
示例9: showNotification
import javax.swing.JWindow; //導入依賴的package包/類
/**
* Shows the notification
* @param window window to show
*/
protected static void showNotification(final JWindow window) {
try {
sLock.lock();
sWindows.addLast(window);
window.addWindowListener(new WindowAdapter() {
@Override
public void windowClosed(WindowEvent e) {
window.removeWindowListener(this);
sWindowOpen = false;
nextWindow();
}
});
nextWindow();
} finally {
sLock.unlock();
}
}
示例10: nextWindow
import javax.swing.JWindow; //導入依賴的package包/類
/**
* shows the next window on the stack
*/
private static void nextWindow() {
try {
sLock.lock();
if(!sWindowOpen && sWindows.size() > 0) {
sWindowOpen = true;
final JWindow window = sWindows.removeFirst();
Timer delayVisibleTimer = new Timer(DELAY, new ActionListener() {
public void actionPerformed(ActionEvent e) {
final Timer t = (Timer) e.getSource();
t.stop();
window.setVisible(true);
window.getGlassPane().setVisible(true);
}
});
delayVisibleTimer.start();
}
} finally {
sLock.unlock();
}
}
示例11: createJWindow
import javax.swing.JWindow; //導入依賴的package包/類
/**
* 創建JWindow,該Window用於作為Jfx組件的容器,這個window始終覆蓋在frame上。
* @param ms
* @param mainFrame
* @param jfxRoot
* @return
*/
private static JWindow createJWindow(JFrame parent, final Pane jfxRoot) {
JWindow jwin = new JWindow(parent);
jwin.setLocationRelativeTo(null);
jwin.setVisible(true);
jfxPanel = new JFXPanel();
jwin.getContentPane().add(jfxPanel);
Platform.runLater(() -> {
// 設置JFX主場景,並讓JFX主界麵變得透明,這樣不會覆蓋整個Canvas.
jfxRoot.setBackground(Background.EMPTY);
jfxPanel.setScene(new Scene(jfxRoot, Color.TRANSPARENT));
});
return jwin;
}
示例12: AutoSuggestor
import javax.swing.JWindow; //導入依賴的package包/類
/**
* Istanzia il suggeritore su un componente testo
*
* @param textComp finestra di testo su cui istanziare il suggeritore
* @param mainWindow finestra principale
* @param words lista di parole
* @param popUpBackground colore dello sfondo
* @param textColor colore del testo
* @param suggestionFocusedColor colore del suggeritore
* @param opacity indice di opacità
*/
public AutoSuggestor(JTextComponent textComp, Window mainWindow, List<String> words, Color popUpBackground, Color textColor, Color suggestionFocusedColor, float opacity) {
this.textComp = textComp;
this.suggestionsTextColor = textColor;
this.container = mainWindow;
this.suggestionFocusedColor = suggestionFocusedColor;
this.textComp.getDocument().addDocumentListener(documentListener);
setDictionary(words);
typedWord = "";
currentIndexOfSpace = 0;
tW = 0;
tH = 0;
autoSuggestionPopUpWindow = new JWindow(mainWindow);
autoSuggestionPopUpWindow.setOpacity(opacity);
suggestionsPanel = new JPanel();
suggestionsPanel.setLayout(new GridLayout(0, 1));
suggestionsPanel.setBackground(popUpBackground);
suggestionsPanel.setBorder(new LineBorder(Color.black));
addKeyBindingToRequestFocusInPopUpWindow();
}
示例13: dispose
import javax.swing.JWindow; //導入依賴的package包/類
/**
* Frees any resources the <code>Popup</code> may be holding onto.
*/
protected void dispose()
{
Component component = getComponent();
Window window = SwingUtilities.getWindowAncestor(component);
if (component instanceof JWindow)
{
((Window) component).dispose();
component = null;
}
// If our parent is a DefaultFrame, we need to dispose it, too.
if (window instanceof DefaultFrame)
{
window.dispose();
}
}
示例14: 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);
}
示例15: SplashScreen
import javax.swing.JWindow; //導入依賴的package包/類
/**
* Constructor.
*
* @param parent
* @param isApplet
*/
public SplashScreen(JFrame parent, boolean isApplet) {
this.isApplet = isApplet;
splashLabel = new JLabel(IconsRegistry.getImageIcon("splash.gif"));
if (!isApplet) {
splashScreen = new JWindow(parent);
splashScreen.getContentPane().add(splashLabel);
splashScreen.pack();
Rectangle screenRect = parent.getGraphicsConfiguration()
.getBounds();
splashScreen
.setLocation(screenRect.x + screenRect.width / 2
- splashScreen.getSize().width / 2, screenRect.y
+ screenRect.height / 2
- splashScreen.getSize().height / 2);
}
}