当前位置: 首页>>代码示例>>Java>>正文


Java JFrame类代码示例

本文整理汇总了Java中javax.swing.JFrame的典型用法代码示例。如果您正苦于以下问题:Java JFrame类的具体用法?Java JFrame怎么用?Java JFrame使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


JFrame类属于javax.swing包,在下文中一共展示了JFrame类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: showResult

import javax.swing.JFrame; //导入依赖的package包/类
public void showResult(Mat img) {
    Imgproc.resize(img, img, new Size(640, 480));
    MatOfByte matOfByte = new MatOfByte();
    Imgcodecs.imencode(".jpg", img, matOfByte);
    byte[] byteArray = matOfByte.toArray();
    BufferedImage bufImage = null;
    try {
        InputStream in = new ByteArrayInputStream(byteArray);
        bufImage = ImageIO.read(in);
        JFrame frame = new JFrame();
        frame.getContentPane().add(new JLabel(new ImageIcon(bufImage)));
        frame.pack();
        frame.setVisible(true);
    } catch (IOException | HeadlessException e) {
        e.printStackTrace();
    }
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:18,代码来源:OpenCVFlow.java

示例2: imshow

import javax.swing.JFrame; //导入依赖的package包/类
/**
 * Display image in a frame
 *
 * @param title
 * @param img
 */
public static void imshow(String title, Mat img) {
	 
    
    // Convert image Mat to a jpeg
    MatOfByte imageBytes = new MatOfByte();
    Highgui.imencode(".jpg", img, imageBytes);
    
    try {
        // Put the jpeg bytes into a JFrame window and show.
        JFrame frame = new JFrame(title);
        frame.getContentPane().add(new JLabel(new ImageIcon(ImageIO.read(new ByteArrayInputStream(imageBytes.toArray())))));
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();
        frame.setVisible(true);
        frame.setLocation(30 + (windowNo*20), 30 + (windowNo*20));
        windowNo++;
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:fossasia,项目名称:zooracle,代码行数:27,代码来源:OpenCVUtils.java

示例3: main

import javax.swing.JFrame; //导入依赖的package包/类
public static void main(String[] args) {
	Plot3DPanel p = new Plot3DPanel();
	Object[][] XYZ = new Object[8][3];
	Object[][] XYZ2 = new Object[10][3];

	for (int j = 0; j < XYZ.length; j++) {
		XYZ[j][0] = Math.random();
		XYZ[j][1] = Math.random();
		XYZ[j][2] = "" + ((char) ('a' + j));
	}

	for (int j = 0; j < XYZ2.length; j++) {
		XYZ2[j][0] = Math.random();
		XYZ2[j][1] = Math.random();
		XYZ2[j][2] = "" + ((char) ('a' + j));
	}

	p.addScatterPlot("toto", p.mapData(XYZ));
	p.addScatterPlot("toti", p.mapData(XYZ2));
	p.setAxisScale(1, "log");

	new FrameView(p).setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	HashMap<String, Double> arg = p.getAxis(2).getStringMap();
	Collection<Double> ouch = arg.values();
	Iterator<Double> it = ouch.iterator();
	while (it.hasNext()) {
		System.out.println(it.next());
	}
}
 
开发者ID:Cvarier,项目名称:2D-Elliptic-Mesh-Generator,代码行数:30,代码来源:Axis.java

示例4: loadFX

import javax.swing.JFrame; //导入依赖的package包/类
@Test public void loadFX() throws Exception {
    final CountDownLatch cdl = new CountDownLatch(1);
    final CountDownLatch done = new CountDownLatch(1);
    final JFXPanel p = new JFXPanel();
    Platform.runLater(new Runnable() {
        @Override
        public void run() {
            Node wv = TestPages.getFX(10, cdl);
            Scene s = new Scene(new Group(wv));
            p.setScene(s);
            done.countDown();
        }
    });
    done.await();
    JFrame f = new JFrame();
    f.getContentPane().add(p);
    f.pack();
    f.setVisible(true);
    cdl.await();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:ComponentsTest.java

示例5: setIcon

import javax.swing.JFrame; //导入依赖的package包/类
public static void setIcon(JFrame frame, String icon) {
    try {
        frame.setIconImage(ImageIO.read(JUtils.class.getResourceAsStream(icon)));
    } catch (IOException ex) {
        StaticStandard.logErr(ex, false);
    }
}
 
开发者ID:Panzer1119,项目名称:JAddOn,代码行数:8,代码来源:JUtils.java

示例6: setup

import javax.swing.JFrame; //导入依赖的package包/类
private static void setup(final Point tmp) {
    comboBox = new JComboBox<>();
    for (int i = 1; i < 7; i++) {
        comboBox.addItem("Long-long-long-long-long text in the item-" + i);
    }
    String property = System.getProperty(PROPERTY_NAME);
    comboBox.putClientProperty(PROPERTY_NAME, Boolean.valueOf(property));
    frame = new JFrame();
    frame.setAlwaysOnTop(true);
    frame.setLayout(new FlowLayout());
    frame.add(comboBox);
    frame.pack();
    frame.setSize(frame.getWidth(), SIZE);
    frame.setVisible(true);
    frame.setLocation(tmp.x, tmp.y);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:JComboBoxPopupLocation.java

示例7: show

import javax.swing.JFrame; //导入依赖的package包/类
public void show() {
    JPanel p = new JPanel(new BorderLayout()) {
        public void paintComponent(Graphics g) {
            g.setColor(Color.blue);
            g.fillRect(0, 0, getWidth(), getHeight());
        }
    };
    p.add(new ImageComponent(src), BorderLayout.WEST);
    if (dst != null) {
    p.add(new ImageComponent(dst), BorderLayout.EAST);
    }

    JFrame f = new JFrame("Transparency");
    f.add(p);

    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.pack();
    f.setVisible(true);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:GifTransparencyTest.java

示例8: testPlot_3

import javax.swing.JFrame; //导入依赖的package包/类
public static void testPlot_3() {
	System.out.println("==============================================================================");
	System.out.println("plotting in your own panel , ie embedding the plot");
	System.out.println("==============================================================================");

	// explicitly create a plot
	JFrame frame = new JFrame();
	frame.setSize(new Dimension(600,600)); ///TODO
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	Container pane = frame.getContentPane();
	//JPanel pane = new JPanel();
	Figure fig1 = new Figure(pane);
	
	// simple plot (opens new window or uses existing one)
	double xVals[] = {1.0,2.0,3.0,4.0,5.0};
	double yVals[] = {1.1,2.2,3.3,4.4,5.5};
	fig1.addPlot(xVals,yVals,"curve 1");
	fig1.drawnow();
	frame.setVisible(true);
	fig1.wait(1000);
	
	// elementary layout
	fig1.setXlabel("x-axis","x-unit");
	fig1.setYlabel("y-axis","y-unit");
	fig1.setAxisTitle("My title");
	fig1.drawnow();
	frame.setVisible(true);
	fig1.wait(1000);
	
	// add another curve
	double xVals2[] = {1.0,2.0,3.0,4.0,5.0};
	double yVals2[] = {4.1,4.2,4.3,4.4,4.5};
	fig1.addPlot(xVals2,yVals2,"curve 2");
	fig1.drawnow();
	frame.setVisible(true);
	fig1.wait(3000);
}
 
开发者ID:OpenDA-Association,项目名称:OpenDA,代码行数:38,代码来源:PlotTest.java

示例9: showtext

import javax.swing.JFrame; //导入依赖的package包/类
/** Display a simple non-modal window showing some text. */
public static JFrame showtext(String title, String text) {
   JFrame window = new JFrame(title);
   JButton done = new JButton("Close");
   done.addActionListener(Runner.createDispose(window));
   JScrollPane scrollPane = OurUtil.scrollpane(OurUtil.textarea(text, 20, 60, false, false));
   window.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
   window.getContentPane().setLayout(new BorderLayout());
   window.getContentPane().add(scrollPane, BorderLayout.CENTER);
   window.getContentPane().add(done, BorderLayout.SOUTH);
   window.pack();
   window.setSize(500, 500);
   window.setLocationRelativeTo(null);
   window.setVisible(true);
   return window;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:17,代码来源:OurDialog.java

示例10: MainWindow

import javax.swing.JFrame; //导入依赖的package包/类
public MainWindow() {
    mainFrame = new JFrame("RipMe v" + UpdateUtils.getThisJarVersion());
    mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    mainFrame.setLayout(new GridBagLayout());

    createUI(mainFrame.getContentPane());
    pack();

    loadHistory();
    setupHandlers();

    Thread shutdownThread = new Thread(this::shutdownCleanup);
    Runtime.getRuntime().addShutdownHook(shutdownThread);

    if (Utils.getConfigBoolean("auto.update", true)) {
        upgradeProgram();
    }

    boolean autoripEnabled = Utils.getConfigBoolean("clipboard.autorip", false);
    ClipboardUtils.setClipboardAutoRip(autoripEnabled);
    trayMenuAutorip.setState(autoripEnabled);
}
 
开发者ID:RipMeApp,项目名称:ripme,代码行数:23,代码来源:MainWindow.java

示例11: start

import javax.swing.JFrame; //导入依赖的package包/类
public void start()
{
	System.out.println("Starting in applet mode.");
	InputStream is =
		this.getClass().getClassLoader().getResourceAsStream(
			"samples/datasets/southern_women_data.txt");
	Reader br = new InputStreamReader(is);

	TestSouthernWomenBipartite swb;
	try
	{
		swb = new TestSouthernWomenBipartite(br);
		add(new JLabel("Opening demo in new frame"));
		JFrame jf = new JFrame();
		jf.getContentPane().add(swb);
		jf.pack();
		jf.setVisible(true);
	}
	catch (IOException e)
	{
		add(new JLabel(e.toString()));
		e.printStackTrace();
	}
}
 
开发者ID:dev-cuttlefish,项目名称:cuttlefish,代码行数:25,代码来源:SouthernWomenApplet.java

示例12: main

import javax.swing.JFrame; //导入依赖的package包/类
public static void main(String[] args) {
	Runtime rt = Runtime.getRuntime();
	rt.gc();
	long start = rt.totalMemory()-rt.freeMemory();
	System.out.println( rt.totalMemory()-rt.freeMemory() );
	Credit c = null;
	try {
		c = new Credit(null, MapApp.MERCATOR_MAP);
	} catch(Exception e) {
		e.printStackTrace();
	}
	rt.gc();
	System.out.println( rt.totalMemory()-rt.freeMemory() );
	System.out.println( (rt.totalMemory()-rt.freeMemory()-start)>>10 );
	JFrame f = new JFrame("flags");
	f.setDefaultCloseOperation(EXIT_ON_CLOSE);
	f.getContentPane().add(c.getPanel());
	f.pack();
	f.setVisible(true);
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:21,代码来源:Credit.java

示例13: createAndShowGUI

import javax.swing.JFrame; //导入依赖的package包/类
/**
 * Create the GUI and show it. For thread safety, this method should be
 * invoked from the event-dispatching thread.
 */
public static JFrame createAndShowGUI() {
    // Create and set up the window.
    JFrame frame = new JFrame("DropDemo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // Create and set up the content pane.
    JComponent newContentPane = new DropDemo();
    newContentPane.setOpaque(true); // content panes must be opaque
    frame.setContentPane(newContentPane);

    // Display the window.
    frame.pack();
    frame.setVisible(true);
    return frame;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:20,代码来源:DropDemo.java

示例14: createAndShowGUI

import javax.swing.JFrame; //导入依赖的package包/类
/**
 * Create the GUI and show it.  For thread safety,
 * this method should be invoked from the
 * event-dispatching thread.
 */
private static void createAndShowGUI() {
    //Create and set up the window.
    //JFrame frame = new JFrame("MenuDemo");
    FreeColClient client = new FreeColClient(null, null);
    client.startClient(null, null, true, true, null, null);
    FreeColFrame frame = new FreeColFrame(client,
        GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(),
        null, null, true, null);
    frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);

    //Create and set up the content pane.
    FreeColMenuTest demo = new FreeColMenuTest();
    frame.setJMenuBar(demo.createMenuBar());
    frame.setContentPane(demo.createContentPane());

    //Display the window.
    frame.setPreferredSize(new Dimension(450, 260));
    frame.setVisible(true);
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:25,代码来源:FreeColMenuTest.java

示例15: errorDialogue

import javax.swing.JFrame; //导入依赖的package包/类
private void errorDialogue(String messageString, int whichField) {
    Object[] message = {messageString};
    Object[] options = {"OK"};
    int n = JOptionPane.showOptionDialog(new JFrame(),
            message, "Alert!",
            JOptionPane.ERROR_MESSAGE, JOptionPane.ERROR_MESSAGE, null,
            options, options[0]);
    if(JOptionPane.ERROR_MESSAGE == n && whichField == 0){
        this.addStudentFullName.setText("");
    } else if(n == JOptionPane.ERROR_MESSAGE && whichField == 1){
        this.addStudentID.setText("171-15-XXXX");
    } else if(n == JOptionPane.ERROR_MESSAGE && whichField == 2){
        this.addFathersNameField.setText("");
    } else if(n == JOptionPane.ERROR_MESSAGE && whichField == 3){
        this.addMothersNameField.setText("");
    } else if(n == JOptionPane.ERROR_MESSAGE && whichField == 4){
        displayUpdateStudentPanel(true, false);
    } else if(n == JOptionPane.ERROR_MESSAGE && whichField == 5){
        panelVisiblity(true, false, false, false);
    } else if(n == JOptionPane.ERROR_MESSAGE && whichField == 6){
        loginVisiblity(true, false);
    } else {
        //DO NOTHING JUST DISPLAY MESSAGE
    }
}
 
开发者ID:musfiqus,项目名称:student_database,代码行数:26,代码来源:AddPanel.java


注:本文中的javax.swing.JFrame类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。