Java Code Examples for javax.swing.JFrame

The following are top voted examples for showing how to use javax.swing.JFrame. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: jaer   File: OpenCVFlow.java   Source Code and License 10 votes vote down vote up
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();
    }
}
 
Example 2
Project: 2D-Elliptic-Mesh-Generator   File: Axis.java   Source Code and License 8 votes vote down vote up
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());
	}
}
 
Example 3
Project: incubator-netbeans   File: ComponentsTest.java   Source Code and License 8 votes vote down vote up
@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();
}
 
Example 4
Project: Tarski   File: OurDialog.java   Source Code and License 8 votes vote down vote up
/** 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;
}
 
Example 5
Project: jdk8u-jdk   File: TextViewOOM.java   Source Code and License 8 votes vote down vote up
private static void createAndShowGUI() {
    frame = new JFrame();
    final JScrollPane jScrollPane1 = new JScrollPane();
    ta = new JTextArea();

    ta.setEditable(false);
    ta.setColumns(20);
    ta.setRows(5);
    jScrollPane1.setViewportView(ta);
    frame.add(ta);

    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
}
 
Example 6
Project: zooracle   File: OpenCVUtils.java   Source Code and License 8 votes vote down vote up
/**
 * 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();
    }
}
 
Example 7
Project: openjdk-jdk10   File: bug8017284.java   Source Code and License 8 votes vote down vote up
public static void main(String[] args) throws Exception {

        Robot robot = new Robot();
        SwingUtilities.invokeAndWait(() -> {
            frame = new JFrame();
            frame.setSize(500, 500);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

            tabbedPane = new JTabbedPane();

            for (int i = 0; i < TAB_COUNT; i++) {
                tabbedPane.add("Header " + i, new JLabel("Content: " + i));
            }

            frame.getContentPane().setLayout(new BorderLayout());
            frame.getContentPane().add(tabbedPane, BorderLayout.CENTER);
            frame.setVisible(true);
        });

        robot.waitForIdle();

        SwingUtilities.invokeAndWait(() -> {
            for (int j = 0; j < ITERATIONS; j++) {
                for (int i = 0; i < TAB_COUNT; i++) {
                    tabbedPane.setTitleAt(i, getHtmlText(j * TAB_COUNT + i));
                }
            }
        });
        robot.waitForIdle();

        SwingUtilities.invokeAndWait(() -> frame.dispose());
    }
 
Example 8
Project: JAddOn   File: JUtils.java   Source Code and License 7 votes vote down vote up
public static void setIcon(JFrame frame, String icon) {
    try {
        frame.setIconImage(ImageIO.read(JUtils.class.getResourceAsStream(icon)));
    } catch (IOException ex) {
        StaticStandard.logErr(ex, false);
    }
}
 
Example 9
Project: openjdk-jdk10   File: JComboBoxPopupLocation.java   Source Code and License 7 votes vote down vote up
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);
}
 
Example 10
Project: jdk8u-jdk   File: GifTransparencyTest.java   Source Code and License 7 votes vote down vote up
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);
}
 
Example 11
Project: OpenDA   File: PlotTest.java   Source Code and License 7 votes vote down vote up
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);
}
 
Example 12
Project: ripme   File: MainWindow.java   Source Code and License 7 votes vote down vote up
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);
}
 
Example 13
Project: cuttlefish   File: SouthernWomenApplet.java   Source Code and License 7 votes vote down vote up
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();
	}
}
 
Example 14
Project: geomapapp   File: Credit.java   Source Code and License 7 votes vote down vote up
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);
}
 
Example 15
Project: marathonv5   File: DropDemo.java   Source Code and License 7 votes vote down vote up
/**
 * 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;
}
 
Example 16
Project: freecol   File: FreeColMenuTest.java   Source Code and License 7 votes vote down vote up
/**
 * 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);
}
 
Example 17
Project: student_database   File: AddPanel.java   Source Code and License 7 votes vote down vote up
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
    }
}
 
Example 18
Project: jdk8u-jdk   File: ScreenMenuMemoryLeakTest.java   Source Code and License 7 votes vote down vote up
private static void showUI() {
    sFrame = new JFrame();
    sFrame.add(new JLabel("Some dummy content"));

    JMenuBar menuBar = new JMenuBar();

    sMenu = new JMenu("Menu");
    JMenuItem item = new JMenuItem("Item");
    sMenu.add(item);

    sMenuItem = new WeakReference<>(item);

    menuBar.add(sMenu);

    sFrame.setJMenuBar(menuBar);

    sFrame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    sFrame.pack();
    sFrame.setVisible(true);
}
 
Example 19
Project: SER316-Munich   File: App.java   Source Code and License 7 votes vote down vote up
/**
 * Method showSplash.
 */
private void showSplash() {
	splash = new JFrame();
	ImageIcon spl =
		new ImageIcon(App.class.getResource("resources/splash.png"));
	JLabel l = new JLabel();
	l.setSize(400, 300);
	l.setIcon(spl);
	splash.getContentPane().add(l);
	splash.setSize(400, 300);
	Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
	splash.setLocation(
		(screenSize.width - 400) / 2,
		(screenSize.height - 300) / 2);
	splash.setUndecorated(true);
	splash.setVisible(true);
}
 
Example 20
Project: incubator-netbeans   File: ModeResizer.java   Source Code and License 7 votes vote down vote up
private void start() {
    Toolkit.getDefaultToolkit().addAWTEventListener( this, KeyEvent.KEY_EVENT_MASK );
    TopComponent.getRegistry().addPropertyChangeListener( this );
    
    Window w = SwingUtilities.getWindowAncestor( resizingComponent );
    if( w instanceof JFrame ) {
        frame = ( JFrame ) w;
        oldGlass = frame.getGlassPane();
        glass = new GlassPane( resizingComponent );
        frame.setGlassPane( glass );
        glass.setVisible( true );
        glass.invalidate();
        glass.revalidate();
        glass.repaint();
        glass.refresh();
        
    }
}
 
Example 21
Project: openjdk-jdk10   File: UpdateUIRecursionTest.java   Source Code and License 7 votes vote down vote up
public UpdateUIRecursionTest() {
    super("UpdateUIRecursionTest");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setSize(400, 400);

    String[] listData = {
        "First", "Second", "Third", "Fourth", "Fifth", "Sixth"
    };

    list = new JList(listData);
    list.setCellRenderer(this);
    renderer = new DefaultListCellRenderer();
    getContentPane().add(new JScrollPane(list), BorderLayout.CENTER);

    setVisible(true);
}
 
Example 22
Project: jdk8u-jdk   File: RenderBadPictureCrash.java   Source Code and License 7 votes vote down vote up
public static void main(String[] args) throws InterruptedException, InvocationTargetException {
    SwingUtilities.invokeAndWait(() -> {
        JFrame f = new JFrame();
        f.setUndecorated(true);
        f.setBackground(new Color(0, 0, 0, 0));
        f.setSize(200, 300);
        f.setVisible(true);

        try {
            UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
        } catch (Exception e) {
            System.err.println(e);
            System.err.println("Could not set GTKLookAndFeel, skipping this test");
        } finally {
            f.dispose();
        }
    });
}
 
Example 23
Project: geomapapp   File: ImageComponent.java   Source Code and License 7 votes vote down vote up
public void save() throws IOException {
	initChooser();
	int ok = JOptionPane.NO_OPTION;
	if( file!=null ) {
		ok = JOptionPane.showConfirmDialog(
			(JFrame)getTopLevelAncestor(),
			"overwrite "+file.getName()+"?",
			"overwrite?",
			JOptionPane.YES_NO_CANCEL_OPTION);
		if( ok==JOptionPane.CANCEL_OPTION) return;
		chooser.setSelectedFile( file);
	}
	if( ok==JOptionPane.NO_OPTION) {
		ok = chooser.showSaveDialog((JFrame)getTopLevelAncestor());
		if( ok==chooser.CANCEL_OPTION) return;
		file = chooser.getSelectedFile();
	}
	apply();
	String type = file.getName().substring(
		file.getName().indexOf(".")+1).toLowerCase();
	if( !type.equals("jpg") && !type.equals("png") && !type.equals("tif")) type="jpg";
	ImageIO.write( image, type, file);
}
 
Example 24
Project: marathonv5   File: RComboBox2Test.java   Source Code and License 7 votes vote down vote up
@BeforeMethod public void showDialog() throws Throwable {
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override public void run() {
            frame = new JFrame(RComboBox2Test.class.getName());
            frame.setName("dialog-1");
            Employee[] items = { new Employee("Phillip"), new Employee("Larry"), new Employee("Lisa"), new Employee("James"),
                    new Employee("Larry") };
            MyComboBoxModel model = new MyComboBoxModel(items);
            JComboBox comboBox = new JComboBox(model);
            comboBox.setName("Employee");
            frame.getContentPane().add(comboBox);
            frame.pack();
            frame.setVisible(true);
        }
    });
}
 
Example 25
Project: smile_1.5.0_java7   File: BoxPlotDemo.java   Source Code and License 6 votes vote down vote up
public static void main(String[] args) {
    JFrame frame = new JFrame("Box Plot");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setLocationRelativeTo(null);
    frame.getContentPane().add(new BoxPlotDemo());
    frame.setVisible(true);
}
 
Example 26
Project: smile_1.5.0_java7   File: SurfaceDemo.java   Source Code and License 6 votes vote down vote up
public static void main(String[] args) {
    JFrame frame = new JFrame("Surface Plot");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setLocationRelativeTo(null);
    frame.getContentPane().add(new SurfaceDemo());
    frame.setVisible(true);
}
 
Example 27
Project: smile_1.5.0_java7   File: ExponentialDistributionDemo.java   Source Code and License 6 votes vote down vote up
public static void main(String[] args) {
    JFrame frame = new JFrame("Exponential Distribution");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setLocationRelativeTo(null);
    frame.getContentPane().add(new ExponentialDistributionDemo());
    frame.setVisible(true);
}
 
Example 28
Project: Tarski   File: UserObject.java   Source Code and License 6 votes vote down vote up
public static void main(String[] args)
{
	UserObject frame = new UserObject();
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	frame.setSize(400, 320);
	frame.setVisible(true);
}
 
Example 29
Project: SpeechToText-REST   File: ExtendedExample.java   Source Code and License 6 votes vote down vote up
private static void createAndShowGUI() {
  JFrame frame = new JFrame("Extended Speech Services Example");
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.add(new ExtendedExample());
  frame.pack();
  frame.setVisible(true);
  frame.setLocationRelativeTo(null);
}
 
Example 30
Project: marathonv5   File: JTableColumnSelectionTest.java   Source Code and License 6 votes vote down vote up
@BeforeMethod public void showDialog() throws InterruptedException, InvocationTargetException, NoSuchWindowException {
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override public void run() {
            frame = new JFrame(JTableRowSelectionTest.class.getSimpleName());
            frame.setName("frame-" + JTableRowSelectionTest.class.getSimpleName());
            frame.getContentPane().add(new TableSelectionDemo(), BorderLayout.CENTER);
            frame.pack();
            frame.setAlwaysOnTop(true);
            frame.setVisible(true);
        }
    });
}
 
Example 31
Project: smile_1.5.0_java7   File: GaussianMixtureDemo.java   Source Code and License 6 votes vote down vote up
public static void main(String[] args) {
    JFrame frame = new JFrame("Gaussian Mixture");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setLocationRelativeTo(null);
    frame.getContentPane().add(new GaussianMixtureDemo());
    frame.setVisible(true);
}
 
Example 32
Project: openjdk-jdk10   File: JInternalFrameMoveOverlapping.java   Source Code and License 6 votes vote down vote up
@Override
protected void prepareControls() {


    JDesktopPane desktopPane = new JDesktopPane();

    JInternalFrame bottomFrame = new JInternalFrame("bottom frame", false, false, false, false);
    bottomFrame.setSize(220, 220);
    super.propagateAWTControls(bottomFrame);
    desktopPane.add(bottomFrame);
    bottomFrame.setVisible(true);

    JInternalFrame topFrame = new JInternalFrame("top frame", false, false, false, false);
    topFrame.setSize(200, 200);
    topFrame.add(new JButton("LW Button") {

        {
            addMouseListener(new MouseAdapter() {

                @Override
                public void mouseClicked(MouseEvent e) {
                    lwClicked = true;
                }
            });
        }
    });
    desktopPane.add(topFrame);
    topFrame.setVisible(true);

    JFrame frame = new JFrame("Test Window");
    frame.setSize(300, 300);
    frame.setContentPane(desktopPane);
    frame.setVisible(true);

    locTopFrame = topFrame.getLocationOnScreen();
    locTarget = new Point(locTopFrame.x + bottomFrame.getWidth() / 2, locTopFrame.y + bottomFrame.getHeight()/2);
}
 
Example 33
Project: QN-ACTR-Release   File: KFuzzyScatter.java   Source Code and License 6 votes vote down vote up
public KFuzzyScatter(int x, int y, WorkloadAnalysisSession model, JFrame f, int clustering, int clust/*,double err*/) { //Passare il numero del clustering
	super();
	parent = f;
	//this.err = err;
	graph = new BufferedImage(WIDTH + 1, HEIGHT + 1, BufferedImage.TYPE_INT_RGB);
	valueFormat = new DecimalFormat("####.##E0");
	parent.setResizable(false);
	curClust = clust;
	this.clustering = clustering;
	//c1 = ((FuzzyKMean)(model.getListOfClustering().get(clustering))).getAssignment(curClust);
	c1 = ((ClusteringInfosFuzzy) ((FuzzyKMean) (model.getListOfClustering().get(clustering))).getClusteringInfos(curClust)).getAssignment();
	xVar = x;
	yVar = y;
	this.model = (ModelWorkloadAnalysis) model.getDataModel();
	this.session = model;
	this.model.addOnChangeVariableValue(new ChangeVariableListener() {
		public void onChangeVariableValues() {
			first = true;
			xMin = KFuzzyScatter.this.model.getMatrix().getVariables()[xVar].getUniStats().getMinValue();
			xMax = KFuzzyScatter.this.model.getMatrix().getVariables()[xVar].getUniStats().getMaxValue();
			yMin = KFuzzyScatter.this.model.getMatrix().getVariables()[yVar].getUniStats().getMinValue();
			yMax = KFuzzyScatter.this.model.getMatrix().getVariables()[yVar].getUniStats().getMaxValue();
			repaint();
		}
	});

	xMin = this.model.getMatrix().getVariables()[xVar].getUniStats().getMinValue();
	xMax = this.model.getMatrix().getVariables()[xVar].getUniStats().getMaxValue();
	yMin = this.model.getMatrix().getVariables()[yVar].getUniStats().getMinValue();
	yMax = this.model.getMatrix().getVariables()[yVar].getUniStats().getMaxValue();

	p = new GlassPanel();
	f.setGlassPane(p);
	p.setVisible(true);
	addMouseListener(p);
	addMouseMotionListener(p);

}
 
Example 34
Project: marathonv5   File: JTableRowSelectionTest.java   Source Code and License 6 votes vote down vote up
@BeforeMethod public void showDialog() throws InterruptedException, InvocationTargetException, NoSuchWindowException {
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override public void run() {
            frame = new JFrame(JTableRowSelectionTest.class.getSimpleName());
            frame.setName("frame-" + JTableRowSelectionTest.class.getSimpleName());
            frame.getContentPane().add(new TableSelectionDemo(), BorderLayout.CENTER);
            frame.pack();
            frame.setAlwaysOnTop(true);
            frame.setVisible(true);
        }
    });
}
 
Example 35
Project: Library-app   File: Busqueda.java   Source Code and License 6 votes vote down vote up
public Busqueda(Connection conn, JFrameJTable principal, String sql, char QuienEs) {
	setIconImage(Toolkit.getDefaultToolkit().getImage(Busqueda.class.getResource("/biblioteca/images/book.png")));
	this.QuienEs=QuienEs;
	this.conn=conn;
	this.principal=principal;
	this.principal.setEnabled(false);
	setTitle("B�squeda");
	
	setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
	setBounds(100, 100, 492, 370);
	contentPane = new JPanel();
	contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
	setContentPane(contentPane);
	contentPane.setLayout(null);
	
	txtUsuario = new JTextField();
	txtUsuario.setBounds(10, 33, 328, 23);
	contentPane.add(txtUsuario);
	txtUsuario.setColumns(10);
	txtUsuario.addKeyListener(this);
	
	btnBuscar = new JButton("Buscar");
	btnBuscar.setBounds(357, 32, 109, 23);
	contentPane.add(btnBuscar);
	btnBuscar.addActionListener(this);
	
	table = new PanelJtable(conn,sql,this);
	table.setBounds(10, 78, 456, 242);
	contentPane.add(table);
	
	addWindowListener(this);
	setVisible(true);
	setLocationRelativeTo(null);
}
 
Example 36
Project: jaer   File: ApsFrameExtractor.java   Source Code and License 6 votes vote down vote up
public ApsFrameExtractor(final AEChip chip) {
    super(chip);
    apsDisplay = ImageDisplay.createOpenGLCanvas();
    apsDisplay.addMouseMotionListener(new MouseInfo(apsDisplay));
    apsFrame = new JFrame("APS Frame");
    apsFrame.setPreferredSize(new Dimension(400, 400));
    apsFrame.getContentPane().add(apsDisplay, BorderLayout.CENTER);
    apsFrame.pack();
    apsFrame.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(final WindowEvent e) {
            setShowAPSFrameDisplay(false);
        }
    });
    apsDisplayLegend = apsDisplay.addLegend("", 0, 0);
    final float[] displayColor = new float[3];
    displayColor[0] = 1.0f;
    displayColor[1] = 1.0f;
    displayColor[2] = 1.0f;
    apsDisplayLegend.color = displayColor;
    initFilter();

    setPropertyTooltip("invertIntensity", "Inverts grey scale, e.g. for raw samples of signal level");
    setPropertyTooltip("preBufferFrame", "Only display and use complete frames; otherwise display APS samples as they arrive");
    setPropertyTooltip("logCompress", "Should the displayBuffer be log compressed");
    setPropertyTooltip("logDecompress", "Should the logComressed displayBuffer be rendered in log scale (true) or linearly (false)");
    setPropertyTooltip("displayContrast", "Gain for the rendering of the APS display");
    setPropertyTooltip("displayBrightness", "Offset for the rendering of the APS display");
    setPropertyTooltip("extractionMethod",
            "Method to extract a frame; CDSframe is the final result after subtracting signal from reset frame. Signal and reset frames are the raw sensor output before correlated double sampling.");
    setPropertyTooltip("showAPSFrameDisplay", "Shows the JFrame frame display if true");
    chip.addObserver(this);

}
 
Example 37
Project: JITRAX   File: NewDatabaseDialog.java   Source Code and License 6 votes vote down vote up
private void buildWindow() {
	setTitle(WINDOW_TITLE);
	setSize(FRAME_WIDTH, FRAME_HEIGHT);
	setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	setLocationRelativeTo(null);
	setResizable(false);
}
 
Example 38
Project: JDigitalSimulator   File: ArrowIcon.java   Source Code and License 6 votes vote down vote up
public static void main(String args[]) {
	JFrame frame = new JFrame();
	JPanel panel = new JPanel();
	frame.add(panel);

	panel.add(new JLabel("north", new ArrowIcon(ArrowIcon.NORTH), JLabel.CENTER));
	panel.add(new JLabel("west", new ArrowIcon(ArrowIcon.WEST), JLabel.CENTER));
	panel.add(new JLabel("south", new ArrowIcon(ArrowIcon.SOUTH), JLabel.CENTER));
	panel.add(new JLabel("east", new ArrowIcon(ArrowIcon.EAST), JLabel.CENTER));
	panel.add(new JLabel("east-20", new ArrowIcon(ArrowIcon.EAST, 20, Color.blue), JLabel.CENTER));

	frame.pack();
	frame.setVisible(true);
}
 
Example 39
Project: myster   File: MysterMenuBarFactory.java   Source Code and License 6 votes vote down vote up
public JMenuBar makeMenuBar(JFrame frame) {
    JMenuBar menuBar = new JMenuBar();

    for (int i = 0; i < mysterMenuFactories.size(); i++) {
        menuBar.add(mysterMenuFactories.get(i).makeMenu(frame));
    }

    return menuBar;
}
 
Example 40
Project: marathonv5   File: JTableHeaderJavaElementTest.java   Source Code and License 6 votes vote down vote up
@BeforeMethod public void showDialog() throws Throwable {
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override public void run() {
            frame = new JFrame(JTableHeaderJavaElementTest.class.getSimpleName());
            frame.setName("frame-" + JTableHeaderJavaElementTest.class.getSimpleName());
            TableDemo demo = new TableDemo();
            demo.start();
            frame.getContentPane().add(demo, BorderLayout.CENTER);
            frame.pack();
            frame.setAlwaysOnTop(true);
            frame.setVisible(true);
        }
    });
    driver = new JavaAgent();
    JavaElementFactory.add(JTableHeader.class, JTableHeaderJavaElement.class);
}
 
Example 41
Project: PTEAssistant   File: SkinManager.java   Source Code and License 6 votes vote down vote up
public void initialize() throws Exception {
    String skin = ObjectUtils.toString(config.get("UISkin")).trim();
    String theme = ObjectUtils.toString(config.get("UITheme")).trim();
    
    if(skin.equalsIgnoreCase("default")) //java default
        return;
    
    UIManager.setLookAndFeel(new SubstanceLookAndFeel());
    JFrame.setDefaultLookAndFeelDecorated(true);
    JDialog.setDefaultLookAndFeelDecorated(true);
    
    if(StringUtils.isNotEmpty(theme))
        SubstanceLookAndFeel.setCurrentTheme(theme);
    else if(StringUtils.isNotEmpty(skin))
        SubstanceLookAndFeel.setSkin((SubstanceSkin)newInstance(skin));
    String watermark = ObjectUtils.toString(config.get("UIWatermark")).trim();
    if(StringUtils.isNotEmpty(watermark))
        SubstanceLookAndFeel.setCurrentWatermark((SubstanceWatermark)newInstance(watermark));
    String buttonShaper = ObjectUtils.toString(config.get("UIButtonShaper")).trim();
    if(StringUtils.isNotEmpty(buttonShaper))
        SubstanceLookAndFeel.setCurrentButtonShaper((SubstanceButtonShaper)newInstance(buttonShaper));
    String borderPainter = ObjectUtils.toString(config.get("UIBorderPainter")).trim();
    if(StringUtils.isNotEmpty(borderPainter))
        SubstanceLookAndFeel.setCurrentBorderPainter((SubstanceBorderPainter)newInstance(borderPainter));
    String gradientPainter = ObjectUtils.toString(config.get("UIGradientPainter")).trim();
    if(StringUtils.isNotEmpty(gradientPainter))
        SubstanceLookAndFeel.setCurrentGradientPainter((SubstanceGradientPainter)newInstance(gradientPainter));
}
 
Example 42
Project: javase   File: SetCardLayout.java   Source Code and License 5 votes vote down vote up
public static void main(String[] args) {
	JFrame f = new JFrame();
	CardLayout card = new CardLayout();
	f.setLayout(card);
	Container c = f.getContentPane();
	JButton[] b = new JButton[6];
	for (int i = 0; i < b.length; i++) {
		b[i] = new JButton("第" + (i + 1) + "页");
		c.add(b[i], "page" + (i + 1));
	}
	b[0].setBackground(Color.blue);
	b[1].setBackground(Color.yellow);
	b[2].setBackground(Color.red);
	b[3].setBackground(Color.green);
	b[4].setBackground(Color.orange);
	b[5].setBackground(Color.pink);
	f.setSize(300, 300);
	f.setVisible(true);
	card.show(c, "1");
	while (true) {
		try {
			Thread.sleep(1000);
		} catch (InterruptedException e) {
			// TODO 自动生成的 catch 块
			e.printStackTrace();
		}
		card.next(c);
	}
	/*
	 * for (int i = 0; i < 6; i++) { try { while (true) {
	 * Thread.sleep(1000); card.next(c); } } catch (InterruptedException e)
	 * { e.printStackTrace(); } }
	 */
}
 
Example 43
Project: geomapapp   File: XYGraph.java   Source Code and License 5 votes vote down vote up
public void dispose() {
	xy = null;

	Container c = getParent();
	while (!(c instanceof JDialog) &&
			!(c instanceof JFrame) && 
			c != null) c = c.getParent();
	if (c != null)
		if (c instanceof JDialog) 
		((JDialog)c).dispose();
		else if (c instanceof JFrame) 
			((JFrame)c).dispose();
}
 
Example 44
Project: openjdk-jdk10   File: UpdateUIRecursionTest.java   Source Code and License 5 votes vote down vote up
public UpdateUIRecursionTest() {
    super("UpdateUIRecursionTest");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setSize(400, 400);

     String[] columnNames = {
            "First Name",
            "Last Name",
            "Sport",
            "# of Years",
            "Vegetarian"};

            Object[][] data = {
                {"Mary", "Campione",
                "Snowboarding", new Integer(5), new Boolean(false)},
                {"Alison", "Huml",
                "Rowing", new Integer(3), new Boolean(true)},
                {"Kathy", "Walrath",
                "Knitting", new Integer(2), new Boolean(false)},
                {"Sharon", "Zakhour",
                "Speed reading", new Integer(20), new Boolean(true)},
                {"Philip", "Milne",
                "Pool", new Integer(10), new Boolean(false)}
            };

    JTableHeader tableHeader =  new JTableHeader();
    table = new JTable(data, columnNames);
    table.setTableHeader(tableHeader);
    tableHeader.setDefaultRenderer(this);

    getContentPane().add(new JScrollPane(table), BorderLayout.CENTER);

    setVisible(true);
}
 
Example 45
Project: openjdk-jdk10   File: MouseModifiersInKeyEvent.java   Source Code and License 5 votes vote down vote up
private static void createAndShowGUI() {
    f = new JFrame();

    final Component component = new JTextField();
    component.addKeyListener(new MyKeyListener());

    f.add(component);
    f.setSize(300, 300);
    f.setLocationRelativeTo(null);
    f.setAlwaysOnTop(true);
    f.setVisible(true);
}
 
Example 46
Project: Luyten4Forge   File: MainWindow.java   Source Code and License 5 votes vote down vote up
private void adjustWindowPositionBySavedState() {
	Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
	if (!windowPosition.isSavedWindowPositionValid()) {
		final Dimension center = new Dimension((int) (screenSize.width * 0.75), (int) (screenSize.height * 0.75));
		final int x = (int) (center.width * 0.2);
		final int y = (int) (center.height * 0.2);
		this.setBounds(x, y, center.width, center.height);

	} else if (windowPosition.isFullScreen()) {
		int heightMinusTray = screenSize.height;
		if (screenSize.height > 30)
			heightMinusTray -= 30;
		this.setBounds(0, 0, screenSize.width, heightMinusTray);
		this.setExtendedState(JFrame.MAXIMIZED_BOTH);

		this.addComponentListener(new ComponentAdapter() {
			@Override
			public void componentResized(ComponentEvent e) {
				if (MainWindow.this.getExtendedState() != JFrame.MAXIMIZED_BOTH) {
					windowPosition.setFullScreen(false);
					if (windowPosition.isSavedWindowPositionValid()) {
						MainWindow.this.setBounds(windowPosition.getWindowX(), windowPosition.getWindowY(),
								windowPosition.getWindowWidth(), windowPosition.getWindowHeight());
					}
					MainWindow.this.removeComponentListener(this);
				}
			}
		});

	} else {
		this.setBounds(windowPosition.getWindowX(), windowPosition.getWindowY(), windowPosition.getWindowWidth(),
				windowPosition.getWindowHeight());
	}
}
 
Example 47
Project: VASSAL-src   File: PrivateChatManager.java   Source Code and License 5 votes vote down vote up
public PrivateChatter getChatterFor(final Player sender) {
  if (banned.contains(sender)) {
    return null;
  }
  PrivateChatter chat = null;
  int index = chatters.indexOf(new Entry(sender, null));
  if (index >= 0) {
    chat = chatters.get(index).chatter;
  }
  if (chat == null) {
    chat = new PrivateChatter(sender, client);
    chatters.add(new Entry(sender, chat));

    final JFrame f = new JFrame();
    f.addWindowListener(new WindowAdapter() {
      public void windowClosing(WindowEvent e) {
        promptToBan(sender);
      }
    });

    f.setTitle(Resources.getString("Chat.private_channel", sender.getName())); //$NON-NLS-1$
    f.setJMenuBar(MenuManager.getInstance().getMenuBarFor(f));
    f.getContentPane().add(chat);
    f.pack();
    f.setLocation(Toolkit.getDefaultToolkit().getScreenSize().width / 2 -
                  f.getSize().width / 2, 0);
  }
  return chat;
}
 
Example 48
Project: openjdk-jdk10   File: HangNonVolatileBuffer.java   Source Code and License 5 votes vote down vote up
public static void main(final String[] args)
        throws InvocationTargetException, InterruptedException {
    SwingUtilities.invokeAndWait(() -> {
        f = new JFrame("JFrame");
        f.setSize(300, 300);
        f.setLocationRelativeTo(null);
        f.setVisible(true);
    });
    SwingUtilities.invokeAndWait(() -> {
        // flush the EDT
    });
    Thread.sleep(1000);
    SwingUtilities.invokeAndWait(f::dispose);
}
 
Example 49
Project: QN-ACTR-Release   File: KMeanScatterPanelChoose.java   Source Code and License 5 votes vote down vote up
public void actionPerformed(ActionEvent e) {
	JFrame f = new JFrame();
	f.setSize(600, 620);
	KMeanScatter s = new KMeanScatter(varXCombo.getSelectedIndex(), varYCombo.getSelectedIndex(), KMeanScatterPanelChoose.this.session, f,
			clustering, clust);
	f.setContentPane(s);
	f.setVisible(true);
}
 
Example 50
Project: LivroJavaComoProgramar10Edicao   File: MenuTest.java   Source Code and License 5 votes vote down vote up
public static void main(String[] args)
{ 
   MenuFrame menuFrame = new MenuFrame(); 
   menuFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   menuFrame.setSize(500, 200); 
   menuFrame.setVisible(true);
}
 
Example 51
Project: LinkGame   File: Main.java   Source Code and License 5 votes vote down vote up
public static void main(String[] args) {
	JFrame.setDefaultLookAndFeelDecorated(true);
	JDialog.setDefaultLookAndFeelDecorated(true);
	try {
		UIManager.setLookAndFeel(new SubstanceOfficeBlue2007LookAndFeel());
	} catch (UnsupportedLookAndFeelException e) {
		e.printStackTrace();
	}
       System.out.println(111);
	initSetting();
	MenuFrame.open();
}
 
Example 52
Project: iConA   File: ConverterView.java   Source Code and License 5 votes vote down vote up
@Action
public void showAboutBox() {
    if (aboutBox == null) {
        JFrame mainFrame = ConverterApp.getApplication().getMainFrame();
        aboutBox = new ConverterAboutBox(mainFrame);
        aboutBox.setLocationRelativeTo(mainFrame);
    }
    ConverterApp.getApplication().show(aboutBox);
}
 
Example 53
Project: openjdk-jdk10   File: bug4213634.java   Source Code and License 5 votes vote down vote up
public  void createAndShowGUI() {
    frame = new JFrame("TEST");
    JMenuBar mb = new JMenuBar();
    menu = mb.add(createMenu("1 - First Menu", true));
    mb.add(createMenu("2 - Second Menu", false));
    frame.setJMenuBar(mb);
    JTextArea ta = new JTextArea("This test dedicated to Nancy and Kathleen, testers and bowlers extraordinaire\n\n\nNo exception means pass.");
    frame.getContentPane().add("Center", ta);
    JButton button = new JButton("Test");
    frame.getContentPane().add("South", button);
    frame.setBounds(100, 100, 400, 400);
    frame.setVisible(true);
    button.requestFocusInWindow();
}
 
Example 54
Project: LogisticApp   File: MenuFrame.java   Source Code and License 5 votes vote down vote up
@Override
public void initialize() {
	this.setTitle("LogisticApp");
	this.setBounds(100, 100, 273, 299);
	this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	this.setLocationRelativeTo(null);
	this.initializeElements();
	this.setResizable(false);
	this.setVisible(true);
}
 
Example 55
Project: smile_1.5.0_java7   File: SIBDemo.java   Source Code and License 5 votes vote down vote up
public static void main(String argv[]) {
    SIBDemo demo = new SIBDemo();
    JFrame f = new JFrame("SIB");
    f.setSize(new Dimension(1000, 1000));
    f.setLocationRelativeTo(null);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.getContentPane().add(demo);
    f.setVisible(true);
}
 
Example 56
Project: openjdk-jdk10   File: WindowClosedEventOnDispose.java   Source Code and License 5 votes vote down vote up
/**
 * Test if a dialog fire the WINDOW_CLOSED event
 * on parent dispose().
 * @throws Exception
 */
public static void testVisibleChildParentDispose() throws Exception {
    JFrame f = new JFrame();
    JDialog dlg = new JDialog(f);
    Listener l = new Listener();
    dlg.addWindowListener(l);
    dlg.setVisible(true);
    f.dispose();
    waitEvents();

    assertEquals(1, l.getCount());
}
 
Example 57
Project: openjdk-jdk10   File: Test7194184.java   Source Code and License 5 votes vote down vote up
private static void createUI() throws Exception {
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            String title = getClass().getName();
            frame = new JFrame(title);
            colorChooser = new JColorChooser();
            frame.add(colorChooser);
            frame.pack();
            frame.setVisible(true);
        }
    });
}
 
Example 58
Project: openjdk-jdk10   File: JFrameOperator.java   Source Code and License 5 votes vote down vote up
/**
 * Maps {@code JFrame.getContentPane()} through queue
 */
public Container getContentPane() {
    return (runMapping(new MapAction<Container>("getContentPane") {
        @Override
        public Container map() {
            return ((JFrame) getSource()).getContentPane();
        }
    }));
}
 
Example 59
Project: openjdk-jdk10   File: JTableAccessibleGetLocationOnScreen.java   Source Code and License 5 votes vote down vote up
private static void constructInEDT() {
    String[] columnNames = { "col1", "col2", };
    Object[][] data = { { "row1, col1", "row1, col2" },
            { "row2, col1", "row2, col2" }, };

    frame = new JFrame(
            "JTable AccessibleTableHeader and AccessibleJTableCell test");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    table = new JTable(data, columnNames);
    frame.add(table);
    frame.pack();
}
 
Example 60
Project: ants   File: MenuListener.java   Source Code and License 5 votes vote down vote up
public MenuListener(JFrame mainContainer, GuiEventListener listener, JTabbedPane tabbedPane,
		JList<String> firstListOfAnthills, JList<String> secondListOfAnthills, JList<String> thirdListOfAnthills,
		JList<String> replays, JButton buttonStart, JRadioButton radioQualification,
		JRadioButton radioTournamentSemiFinals, JScrollPane scrollPaneQualification,
		JScrollPane scrollPaneTournament, JCheckBox runInBackgroundCheckbox) {
	this.tabbedPane = tabbedPane;
	this.buttonStart = buttonStart;
	this.firstListOfAnthills = firstListOfAnthills;
	this.secondListOfAnthills = secondListOfAnthills;
	this.thirdListOfAnthills = thirdListOfAnthills;
	this.replays = replays;
	this.radioQualification = radioQualification;
	this.radioTournamentSemiFinals = radioTournamentSemiFinals;
	this.scrollPaneQualification = scrollPaneQualification;
	this.scrollPaneTournament = scrollPaneTournament;
	this.listener = listener;
	this.runInBackgroundCheckbox = runInBackgroundCheckbox;

	tabbedPane.addChangeListener(this);
	firstListOfAnthills.addListSelectionListener(this);
	secondListOfAnthills.addListSelectionListener(this);
	thirdListOfAnthills.addListSelectionListener(this);
	replays.addListSelectionListener(this);
	buttonStart.addActionListener(this);
	radioQualification.addActionListener(this);
	radioTournamentSemiFinals.addActionListener(this);
}