當前位置: 首頁>>代碼示例>>Java>>正文


Java Frame類代碼示例

本文整理匯總了Java中java.awt.Frame的典型用法代碼示例。如果您正苦於以下問題:Java Frame類的具體用法?Java Frame怎麽用?Java Frame使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Frame類屬於java.awt包,在下文中一共展示了Frame類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: main

import java.awt.Frame; //導入依賴的package包/類
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();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:17,代碼來源:TextAreaTwicePack.java

示例2: supportsExtendedState

import java.awt.Frame; //導入依賴的package包/類
/**
 * 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;
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:31,代碼來源:XWM.java

示例3: showTimedDialog

import java.awt.Frame; //導入依賴的package包/類
/**
 * Статический метод который показывает модально диалог регистрации клиентов.
 *
 * @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);
}
 
開發者ID:bcgov,項目名稱:sbc-qsystem,代碼行數:26,代碼來源:FTimedDialog.java

示例4: main

import java.awt.Frame; //導入依賴的package包/類
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));
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:19,代碼來源:RemoveHelpMenu.java

示例5: jButton1ActionPerformed

import java.awt.Frame; //導入依賴的package包/類
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);
    }
}
 
開發者ID:ffleurey,項目名稱:ThingML-Tradfri,代碼行數:23,代碼來源:BulbPanel.java

示例6: main

import java.awt.Frame; //導入依賴的package包/類
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 :(");
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:19,代碼來源:FrameMinimizeTest.java

示例7: main

import java.awt.Frame; //導入依賴的package包/類
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);
        }
    }
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:22,代碼來源:KeyCharTest.java

示例8: createMenu

import java.awt.Frame; //導入依賴的package包/類
@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);
}
 
開發者ID:gamefest2017,項目名稱:ants,代碼行數:31,代碼來源:SimpleGUI.java

示例9: main

import java.awt.Frame; //導入依賴的package包/類
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();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:17,代碼來源:R2303044ListSelection.java

示例10: loadReport

import java.awt.Frame; //導入依賴的package包/類
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!");
		}

	}
 
開發者ID:Coder-ACJHP,項目名稱:Hotel-Properties-Management-System,代碼行數:36,代碼來源:ShowReport.java

示例11: preInit

import java.awt.Frame; //導入依賴的package包/類
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));
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:24,代碼來源:XFramePeer.java

示例12: initTestWindow

import java.awt.Frame; //導入依賴的package包/類
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);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:18,代碼來源:AltGraphModifierTest.java

示例13: testFocus

import java.awt.Frame; //導入依賴的package包/類
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!");
        }
    }
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:27,代碼來源:MultiResolutionSplashTest.java

示例14: main

import java.awt.Frame; //導入依賴的package包/類
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");
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:25,代碼來源:WindowsLeak.java

示例15: windowClosing

import java.awt.Frame; //導入依賴的package包/類
public void windowClosing(WindowEvent e) {
    e.getWindow().setVisible(false);
    e.getWindow().dispose();
    if ( !(e.getWindow() instanceof Frame))
        return;
    ((Frame)e.getWindow()).setMenuBar(null);
    ((Frame)e.getWindow()).removeAll();
}
 
開發者ID:addertheblack,項目名稱:myster,代碼行數:9,代碼來源:StandardWindowBehavior.java


注:本文中的java.awt.Frame類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。