当前位置: 首页>>代码示例>>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;未经允许,请勿转载。