public static void main(String[] args) throws Exception { SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); Frame frame = new Frame(); frame.setSize(300, 300); frame.setVisible(true); toolkit.realSync(); Robot robot = new Robot(); robot.keyPress(KeyEvent.VK_DELETE); robot.keyRelease(KeyEvent.VK_DELETE); toolkit.realSync(); frame.dispose(); if (eventsCount != 3) { throw new RuntimeException("Wrong number of key events: " + eventsCount); } }
/** * Check if state is supported. * Note that a compound state is always reported as not supported. * Note also that MAXIMIZED_BOTH is considered not a compound state. * Therefore, a compound state is just ICONIFIED | anything else. * */ boolean supportsExtendedState(int state) { switch (state) { case Frame.MAXIMIZED_VERT: case Frame.MAXIMIZED_HORIZ: /* * WMs that talk NET/WIN protocol, but do not support * unidirectional maximization. */ if (getWMID() == METACITY_WM) { /* "This is a deliberate policy decision." -hp */ return false; } /* FALLTROUGH */ case Frame.MAXIMIZED_BOTH: for (XStateProtocol proto : getProtocols(XStateProtocol.class)) { if (proto.supportsState(state)) { return true; } } default: return false; } }
/** * Статический метод который показывает модально диалог регистрации клиентов. * * @param parent фрейм относительно которого будет модальность * @param modal модальный диалог или нет */ public static void showTimedDialog(Frame parent, boolean modal, String message, int timeout) { if (dialog == null) { dialog = new FTimedDialog(parent, modal); dialog.setTitle("Сообщение."); } dialog.setBounds(10, 10, 1024, 400); dialog.changeTextToLocale(); dialog.labelMess.setText(message); Uses.setLocation(dialog); dialog.clockClose = new ATalkingClock(timeout, 1) { @Override public void run() { dialog.buttonCloseActionPerformed(null); } }; dialog.clockClose.start(); dialog.setVisible(true); }
public static void main(final String[] args) { final Frame frame = new Frame("RemoveHelpMenu Test"); try { frame.pack(); // peer exists test1(getMenuBar(frame)); test2(getMenuBar(frame)); test3(getMenuBar(frame)); test4(getMenuBar(frame)); } finally { frame.dispose(); } // peer is null test1(getMenuBar(frame)); test2(getMenuBar(frame)); test3(getMenuBar(frame)); test4(getMenuBar(frame)); }
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed try { //JOptionPane pane = new JOptionPane(); //pane.setMessageType(JOptionPane.INFORMATION_MESSAGE); JDialog dialog = new JDialog((Frame)null, "Result of COAP GET for bulb " + bulb.getName(), false); JTextArea msg = new JTextArea(bulb.getJsonObject().toString(4) + "\n"); msg.setFont(new Font("monospaced", Font.PLAIN, 10)); msg.setLineWrap(true); msg.setWrapStyleWord(true); JScrollPane scrollPane = new JScrollPane(msg); dialog.getContentPane().add(scrollPane); dialog.setSize(350, 350); //dialog.pack(); dialog.setVisible(true); } catch (JSONException ex) { Logger.getLogger(BulbPanel.class.getName()).log(Level.SEVERE, null, ex); } }
public static void main(String args[]) throws Exception { Frame frame = new Frame("Frame Minimize Test"); Button b = new Button("Focus ownder"); frame.add("South", b); frame.pack(); frame.setVisible(true); Util.waitForIdle(null); if (!b.hasFocus()) { throw new RuntimeException("button is not a focus owner after showing :("); } frame.setExtendedState(Frame.ICONIFIED); Util.waitForIdle(null); frame.setExtendedState(Frame.NORMAL); Util.waitForIdle(null); if (!b.hasFocus()) { throw new RuntimeException("button is not a focus owner after restoring :("); } }
@Override public void createMenu(final InitMenuData data) { if (this.frame != null) { try { SwingUtilities.invokeAndWait(new Runnable() { public void run() { frame.dispose(); } }); } catch (Exception e) { e.printStackTrace(); } this.canvas = null; this.scoreboard = null; this.frame = null; } // Create and set up the window. this.frame = new JFrame("IBM Slovakia / Fall Fest 2017 / Anthill"); this.frame.setExtendedState(this.frame.getExtendedState() | Frame.MAXIMIZED_BOTH); this.frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.frame.setLayout(new BorderLayout()); // Set up the content pane. this.frame.add(new Menu(data, this.listener, this.frame)); // Display the window. this.frame.pack(); this.frame.setVisible(true); }
public static void main(final String[] args) throws HeadlessException { final Frame frame = new Frame("Test Frame"); final List list = new List(); frame.setSize(300, 200); list.add(ITEM_NAME); list.select(0); frame.add(list); frame.validate(); frame.setVisible(true); sleep(); if (!ITEM_NAME.equals(list.getSelectedItem())) { throw new RuntimeException("List item not selected item."); } list.removeAll(); frame.dispose(); }
public void loadReport(String reportName, ReportObject reportObject) { logging = LoggingEngine.getInstance(); try { final InputStream inputStream = ShowReport.class .getResourceAsStream("/com/coder/hms/reportTemplates/" + reportName + ".jrxml"); JasperReport report = JasperCompileManager.compileReport(inputStream); HashMap<String, Object> parameters = new HashMap<String, Object>(); List<ReportObject> list = new ArrayList<ReportObject>(); list.add(reportObject); JRBeanCollectionDataSource beanColDataSource = new JRBeanCollectionDataSource(list); JasperPrint jasperPrint = JasperFillManager.fillReport(report, parameters, beanColDataSource); final JRViewer viewer = new JRViewer(jasperPrint); setType(Type.POPUP); setResizable(false); setModalExclusionType(ModalExclusionType.APPLICATION_EXCLUDE); this.setTitle("Reservation [Report]"); this.setExtendedState(Frame.MAXIMIZED_BOTH); this.setAlwaysOnTop(isAlwaysOnTopSupported()); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); getContentPane().setLayout(new BorderLayout()); this.setIconImage(Toolkit.getDefaultToolkit(). getImage(LoginWindow.class.getResource(LOGOPATH))); this.setResizable(false); getContentPane().add(viewer, BorderLayout.CENTER); } catch (JRException e) { logging.setMessage("JRException report error!"); } }
void preInit(XCreateWindowParams params) { super.preInit(params); Frame target = (Frame)(this.target); // set the window attributes for this Frame winAttr.initialState = target.getExtendedState(); state = 0; undecorated = Boolean.valueOf(target.isUndecorated()); winAttr.nativeDecor = !target.isUndecorated(); if (winAttr.nativeDecor) { winAttr.decorations = winAttr.AWT_DECOR_ALL; } else { winAttr.decorations = winAttr.AWT_DECOR_NONE; } winAttr.functions = MWMConstants.MWM_FUNC_ALL; winAttr.isResizable = true; // target.isResizable(); winAttr.title = target.getTitle(); winAttr.initialResizability = target.isResizable(); if (log.isLoggable(PlatformLogger.Level.FINE)) { log.fine("Frame''s initial attributes: decor {0}, resizable {1}, undecorated {2}, initial state {3}", Integer.valueOf(winAttr.decorations), Boolean.valueOf(winAttr.initialResizability), Boolean.valueOf(!winAttr.nativeDecor), Integer.valueOf(winAttr.initialState)); } }
public static void main(final String[] args) { final Frame frame = new Frame(); final TextArea ta = new TextArea(); frame.add(ta); frame.pack(); frame.setVisible(true); sleep(); final Dimension before = frame.getSize(); frame.pack(); final Dimension after = frame.getSize(); if (!after.equals(before)) { throw new RuntimeException( "Expected size: " + before + ", actual size: " + after); } frame.dispose(); }
public static void initTestWindow() { mainFrame = new Frame(); mainFrame.setTitle("TestWindow"); mainFrame.setBounds(700, 10, 300, 300); mainFrame.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { int ex = e.getModifiersEx(); if ((ex & InputEvent.ALT_GRAPH_DOWN_MASK) == 0) { AltGraphModifierTest.fail("Alt-Gr Modifier bit is not set."); } else { AltGraphModifierTest.pass(); } } }); mainFrame.setVisible(true); }
static void testFocus() throws Exception { Robot robot = new Robot(); robot.setAutoDelay(50); Frame frame = new Frame(); frame.setSize(100, 100); String test = "123"; TextField textField = new TextField(test); textField.selectAll(); frame.add(textField); frame.setVisible(true); robot.waitForIdle(); robot.keyPress(KeyEvent.VK_A); robot.keyRelease(KeyEvent.VK_A); robot.keyPress(KeyEvent.VK_B); robot.keyRelease(KeyEvent.VK_B); robot.waitForIdle(); frame.dispose(); if (!textField.getText().equals("ab")) { throw new RuntimeException("Focus is lost!"); } }
public static void main(String[] args) throws Exception { Robot r = new Robot(); for (int i = 0; i < 100; i++) { Frame f = new Frame(); f.pack(); f.dispose(); } r.waitForIdle(); Disposer.addRecord(new Object(), () -> disposerPhantomComplete = true); while (!disposerPhantomComplete) { Util.generateOOME(); } Vector<WeakReference<Window>> windowList = (Vector<WeakReference<Window>>) AppContext.getAppContext().get(Window.class); if (windowList != null && !windowList.isEmpty()) { throw new RuntimeException("Test FAILED: Window list is not empty: " + windowList.size()); } System.out.println("Test PASSED"); }
private void setInitialState(XWindowPeer window, int state) { XAtomList old_state = window.getNETWMState(); if (log.isLoggable(PlatformLogger.Level.FINE)) { log.fine("Current state of the window {0} is {1}", window, old_state); } if ((state & Frame.MAXIMIZED_VERT) != 0) { old_state.add(XA_NET_WM_STATE_MAXIMIZED_VERT); } else { old_state.remove(XA_NET_WM_STATE_MAXIMIZED_VERT); } if ((state & Frame.MAXIMIZED_HORIZ) != 0) { old_state.add(XA_NET_WM_STATE_MAXIMIZED_HORZ); } else { old_state.remove(XA_NET_WM_STATE_MAXIMIZED_HORZ); } if (log.isLoggable(PlatformLogger.Level.FINE)) { log.fine("Setting initial state of the window {0} to {1}", window, old_state); } window.setNETWMState(old_state); }
private static void createUI() throws Exception { SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { background = new Frame(); background.setUndecorated(true); background.setBackground(Color.blue); background.setSize(300, 300); background.setLocation(100, 100); background.setVisible(true); window = new Window(background); window.setBackground(Color.red); window.add(new Panel(), BorderLayout.CENTER); window.setLocation(200, 200); window.setSize(100, 100); Area a = new Area(); a.add(new Area(new Rectangle2D.Double(0, 0, 100, 100))); window.setShape(a); window.setVisible(true); window.toFront(); } }); }
private JDialog createDialog(Component parentComponent, String title, int style) throws HeadlessException { final JDialog dialog; Window window = JOptionPane.getWindowForComponent(parentComponent); if (window instanceof Frame) { dialog = new JDialog((Frame)window, title, true); } else { dialog = new JDialog((Dialog)window, title, true); } if (window instanceof SwingUtilities.SharedOwnerFrame) { WindowListener ownerShutdownListener = SwingUtilities.getSharedOwnerFrameShutdownListener(); dialog.addWindowListener(ownerShutdownListener); } initDialog(dialog, style, parentComponent); return dialog; }
private FileDialog createFileDialog( File currentDirectory ) { if( badger != null ) return null; if( !Boolean.getBoolean("nb.native.filechooser") ) return null; if( dirsOnly && !BaseUtilities.isMac() ) return null; Component parentComponent = findDialogParent(); Frame parentFrame = (Frame) SwingUtilities.getAncestorOfClass(Frame.class, parentComponent); FileDialog fileDialog = new FileDialog(parentFrame); if (title != null) { fileDialog.setTitle(title); } if( null != currentDirectory ) fileDialog.setDirectory(currentDirectory.getAbsolutePath()); return fileDialog; }
public static void main(String args[]) { if (!Toolkit.getDefaultToolkit().isFrameStateSupported(Frame.MAXIMIZED_BOTH)) { return; } MaximizedUndecorated test = new MaximizedUndecorated(); boolean doPass = true; try{ if( !test.doTest(true) ) { System.out.println("Actual bounds differ from Maximum Window Bounds for JFrame"); doPass = false; } if( !test.doTest(false) ) { System.out.println("Actual bounds differ from Maximum Window Bounds for Frame"); doPass = false; } }catch(Exception ie) { ie.printStackTrace(); throw new RuntimeException("Interrupted or InvocationTargetException occured"); } if(!doPass) { throw new RuntimeException("Actual bounds of undecorated frame differ from Maximum Windows Bounds for this platform"); } }
public static void changeServiceLangList(Frame parent, boolean modal, final QService service) { QLog.l().logger().info("Редактирование языковых локаций \"" + service.getName() + "\""); if (serviceLangList == null) { serviceLangList = new FServiceLangList(parent, modal); } serviceLangList.setTitle(service.getName()); serviceLangList.service = service; serviceLangList.listLng.setModel(new javax.swing.AbstractListModel() { @Override public int getSize() { return service.getLangs().size(); } @Override public Object getElementAt(int i) { return service.getLangs().toArray()[i]; } }); Uses.setLocation(serviceLangList); serviceLangList.setVisible(true); }
public StopDialog(String title, String text) { super((Frame) null, title, false); getContentPane().setLayout(new BorderLayout()); JLabel label = new JLabel(text); label.setBorder(BorderFactory.createEmptyBorder(7, 7, 7, 7)); getContentPane().add(label, BorderLayout.CENTER); Icon informationIcon = UIManager.getIcon("OptionPane.informationIcon"); if (informationIcon != null) { JLabel informationIconLabel = new JLabel(informationIcon); informationIconLabel.setBorder(BorderFactory.createEmptyBorder(7, 7, 7, 7)); getContentPane().add(informationIconLabel, BorderLayout.WEST); } JPanel buttonPanel = new JPanel(); JButton stopButton = new JButton("Stop"); stopButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { stillRunning = false; } }); buttonPanel.add(stopButton); getContentPane().add(buttonPanel, BorderLayout.SOUTH); pack(); setLocationRelativeTo(null); }
/** * Method declaration * * * @param owner * @param title */ public static Connection createConnection(Frame owner, String title, Insets defInsets) { ZaurusConnectionDialog dialog = new ZaurusConnectionDialog(owner, title); dialog.create(defInsets); return dialog.mConnection; }
@Override public void iconify(ComponentOperator oper) { checkSupported(oper); eDriver.dispatchEvent(oper.getSource(), new WindowEvent((Window) oper.getSource(), WindowEvent.WINDOW_ICONIFIED)); ((FrameOperator) oper).setState(Frame.ICONIFIED); }
public String saveFile(Frame f, String title, String defDir, String fileType) { FileDialog fd = new FileDialog(f, title, FileDialog.SAVE); fd.setFile(fileType); fd.setDirectory(defDir); fd.setLocation(50, 50); fd.show(); return fd.getDirectory()+fd.getFile(); }
public SetAppDialog(Frame frame, String title) { super(frame, title, true); try { jbInit(); pack(); } catch(Exception ex) { new ExceptionDialog(ex); } }
public TdDialog(Frame frame) { super(frame, Local.getString("Table properties"), true); try { jbInit(); pack(); } catch(Exception ex) { ex.printStackTrace(); } }
public void close() { Env.INSTANCE.setFullScreen(getExtendedState() == Frame.MAXIMIZED_BOTH); if (_mainPanel != null) { _mainPanel.dispose(); } LOGGER.info("Application exited."); }
public SrcDialog(Frame frame, String text) { super(frame, "Source text", true); try { setText(text); jbInit(); pack(); } catch (Exception ex) { ex.printStackTrace(); } }
public StickerDialog(Frame frame, String text, String backcolor, String forecolor, int sP, int size){ super(frame, Local.getString("Sticker"), true); try { jbInit(); pack(); } catch (Exception ex) { new ExceptionDialog(ex); } stickerText.setText(text); Color back = Color.decode(backcolor); Color front = Color.decode(forecolor); int i = findColorIndex(back); if (i > -1) stickerColor.setSelectedIndex(i); else stickerColor.setSelectedIndex(10); i = findColorIndex(front); if (i > -1) textColor.setSelectedIndex(i); else textColor.setSelectedIndex(stickerColor.getSelectedIndex()+1); if (sP > -1 && sP < 5) priorityList.setSelectedIndex(sP); else priorityList.setSelectedIndex(2); if(size==10) fontSize.setSelectedIndex(0); else if(size == 20) fontSize.setSelectedIndex(2); else fontSize.setSelectedIndex(1); }
public StickerDialog(Frame frame) { super(frame, Local.getString("Sticker"), true); try { jbInit(); pack(); } catch (Exception ex) { new ExceptionDialog(ex); } }
public void start() { String[] instructions = new String[] { "1. Notice components in test window: main-panel, box-for-text," +" 2 scroll-sliders, and 4 scroll-buttons.", "2. Hover mouse over box-for-text." +" Make sure, that mouse cursor is TextCursor (a.k.a. \"beam\").", "3. Hover mouse over each of components (see item 1), except for box-for-text." +" Make sure, that cursor is DefaultCursor (arrow).", "4. Drag mouse (using any mouse button) from box-for-text to every" +" component in item 1, and also outside application window." +" Make sure, that cursor remains TextCursor while mouse button is pressed.", "5. Repeat item 4 for each other component in item 1, except for box-for-text," +" _but_ now make sure that cursor is DefaultCursor.", "6. If cursor behaves as described in items 2-3-4-5, then test passed; otherwise it failed." }; Sysout.createDialogWithInstructions( instructions ); Panel panel = new Panel(); panel.setLayout( new GridLayout(3,3) ); for( int y=0; y<3; ++y ) { for( int x=0; x<3; ++x ) { if( x==1 && y==1 ) { panel.add( new TextArea( bigString() ) ); } else { panel.add( new Panel() ); } } } Frame frame = new Frame( "TextArea cursor icon test" ); frame.setSize( 300, 300 ); frame.add( panel ); frame.setVisible( true ); }
@Override boolean isTargetUndecorated() { if (undecorated != null) { return undecorated.booleanValue(); } else { return ((Frame)target).isUndecorated(); } }
public ImageDialog(Frame frame) { super(frame, Local.getString("Image"), true); try { jbInit(); pack(); } catch (Exception ex) { ex.printStackTrace(); } super.addWindowListener(this); }
public ExitConfirmationDialog(Frame frame, String title) { super(frame, title, true); try { jbInit(); pack(); } catch (Exception ex) { new ExceptionDialog(ex); } super.addWindowListener(this); }
public static void main(String args[]) { Frame f = new Frame("DitherTest"); DitherTest ditherTest = new DitherTest(); ditherTest.init(); f.add("Center", ditherTest); f.pack(); f.setVisible(true); ditherTest.start(); }
public static void createDialog( ) { dialog = new TestDialog( new Frame(), "Instructions" ); String[] defInstr = { "Instructions will appear here. ", "" } ; dialog.printInstructions( defInstr ); dialog.show(); println( "Any messages for the tester will display here." ); }
public EditTypeDialog(Frame frame, String title) { super(frame, title, true); try { jbInit(); pack(); } catch (Exception ex) { new ExceptionDialog(ex); } }
/** * Статический метод который показывает модально диалог выбора времени для предварительной * записи клиентов. * * @param parent фрейм относительно которого будет модальность * @param modal модальный диалог или нет * @param netProperty свойства работы с сервером * @param fullscreen растягивать форму на весь экран и прятать мышку или нет * @param delay задержка перед скрытием диалога. если 0, то нет автозакрытия диалога * @return XML-описание результата предварительной записи, по сути это номерок. если null, то * отказались от предварительной записи */ public static RpcStandInService showAdvanceStandDialog(Frame parent, boolean modal, INetProperty netProperty, boolean fullscreen, int delay) { FStandAdvance.delay = delay; QLog.l().logger().info("Ввод кода предварительной записи"); if (standAdvance == null) { standAdvance = new FStandAdvance(parent, modal); standAdvance.setTitle(getLocaleMessage("dialog.input_code")); } result = null; Uses.setLocation(standAdvance); FStandAdvance.netProperty = netProperty; if (!(QConfig.cfg().isDebug() || QConfig.cfg().isDemo() && !fullscreen)) { //Uses.setFullSize(standAdvance); if (QConfig.cfg().isHideCursor()) { int[] pixels = new int[16 * 16]; Image image = Toolkit.getDefaultToolkit() .createImage(new MemoryImageSource(16, 16, pixels, 0, 16)); Cursor transparentCursor = Toolkit.getDefaultToolkit() .createCustomCursor(image, new Point(0, 0), "invisibleCursor"); standAdvance.setCursor(transparentCursor); } } standAdvance.changeTextToLocale(); if (standAdvance.clockBack.isActive()) { standAdvance.clockBack.stop(); } standAdvance.clockBack.start(); standAdvance.setVisible(true); return result; }
private static Frame createFrame(String title, int x, int y) { Frame frame = new Frame(); frame.setSize(200, 200); frame.setLocation(x, y); frame.setTitle(title); frame.setVisible(true); return frame; }