當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。