Java Code Examples for javax.swing.JFrame.setPreferredSize()

The following are Jave code examples for showing how to use setPreferredSize() of the javax.swing.JFrame class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: jaer   File: MultiDavisCameraChip.java   View Source Code Vote up 7 votes
@Override
public void actionPerformed(ActionEvent e) {
    displayAPSEnable=true;
    resetBuffer = new float[sx * sy][NUM_CAMERAS];
    signalBuffer = new float[sx * sy][NUM_CAMERAS];
    displayFrame = new float[sx * sy][NUM_CAMERAS];
    displayBuffer = new float[sx * sy][NUM_CAMERAS];
    apsDisplayPixmapBuffer = new float[3 * sx * sy][NUM_CAMERAS];
    for (int c=0; c< NUM_CAMERAS; c++){
        apsDisplay[c] = ImageDisplay.createOpenGLCanvas();
        apsFrame = new JFrame("APS Camera " + c);
        apsFrame.setPreferredSize(new Dimension(400, 400));
        apsFrame.getContentPane().add(apsDisplay[c], BorderLayout.CENTER);
        apsFrame.setVisible(true);
        apsFrame.pack();
        apsDisplay[c].setImageSize(sx, sy);
        
    }
}
 
Example 2
Project: jaer   File: JspikeStack.java   View Source Code Vote up 6 votes
/** Start a menu that allows the user to launch a number of demos for the 
 * JSpikeStack package.  To add a new demo to the menu:
 * 1) Add the appropriate element to the "Demos" enumerator (above);
 * 2) Add the button in demoMenu()
 * 3) Connect the enumerator element to the appropriate function in DemoLauncher through the switch statement.
 */
public static void demoMenu()
{
            
    JFrame frm=new JFrame();
    frm.setTitle("JSpikeStack demos");
    Container pane=frm.getContentPane();
    JButton button;
    
    pane.setLayout(new GridBagLayout());
    
    addDemoButton("Network Generation Demo","Read a network From XML and let it generate",Demos.GENERATE,pane);
    addDemoButton("Learning Demo","Read an AER file, initialize a random net, and run STDP learning",Demos.LEARN,pane);
    addDemoButton("Convolution Demo",  "Here we read data from the Silicon retina.  Two output layers respond to vertically and horizontally oriented features.",Demos.CONV,pane);
    addDemoButton("RC Network",  "Takes retina inputs and fires them to a smoothing network.",Demos.RCNET,pane);
    addDemoButton("Retina",  "In this demo we mimic the behaviour of a variety of types of retinal ganglion cell.",Demos.RETINA,pane);
    
    
    frm.setPreferredSize(new Dimension(500,500));
    frm.pack();
    frm.setVisible(true);
    frm.toFront();
    frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    
}
 
Example 3
Project: jaer   File: KernelImplementor.java   View Source Code Vote up 6 votes
public KernelImplementor (AEChip chip) {
    
    super(chip);
    this.chip = chip;                                       
    
    pixelbuffer = new PixelBuffer(chip);        
    filterchain = new FilterChain(chip);        
    
    sizex = chip.getSizeX();
    sizey = chip.getSizeY();
    
    display = ImageDisplay.createOpenGLCanvas(); // makde a new ImageDisplay GLCanvas with default OpenGL capabilities
    featureFrame = new JFrame("ImageFrameth");  // make a JFrame to hold it
    featureFrame.setPreferredSize(new Dimension(sizex, sizey));  // set the window size
    featureFrame.getContentPane().add(display, BorderLayout.CENTER); // add the GLCanvas to the center of the window
    featureFrame.pack(); // otherwise it wont fill up the display
    
    initFilter();
    
    filterchain.add(new BackgroundActivityFilter(chip));
    filterchain.add( pixelbuffer );
    pixelbuffer.setKernelImplementor(this);
    setEnclosedFilterChain(filterchain);    //creates a filter chain instance and passes this object to the kernel
                                            //method for all processing
    pixelbuffer.setEnclosed(true, this);
}
 
Example 4
Project: jaer   File: PixelBuffer.java   View Source Code Vote up 6 votes
public PixelBuffer (AEChip chip){
    
    super(chip);
    this.chip = chip;

    final String sz = "Size";                        
    setPropertyTooltip(sz, "RingBufferSize", "sets size of ring buffer");               

    sizex = chip.getSizeX();
    sizey = chip.getSizeY();                      
    
    disp = ImageDisplay.createOpenGLCanvas(); // makde a new ImageDisplay GLCanvas with default OpenGL capabilities
    frame = new JFrame("ImageFrame");  // make a JFrame to hold it
    frame.setPreferredSize(new Dimension(sizex, sizey));  // set the window size
    frame.getContentPane().add(disp, BorderLayout.CENTER); // add the GLCanvas to the center of the window
    frame.pack(); // otherwise it wont fill up the display
    
    initFilter();
    resetFilter();
 
}
 
Example 5
Project: candlelight   File: Console.java   View Source Code Vote up 6 votes
private static JFrame createJavaFrame(String name, int height)
{
	final Dimension min = new Dimension(20 + 400, 20 + 100);
	final Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();

	JFrame frame = new JFrame();
	frame.setTitle(name);
	frame.setSize(min.width, height);
	frame.setMaximumSize(new Dimension(min.width, screen.height));
	frame.setPreferredSize(new Dimension(min.width, height));
	frame.setMinimumSize(min);
	frame.setLocation(screen.width / 2 - min.width / 2, screen.height / 2 - height / 2);
	frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);

	return frame;
}
 
Example 6
Project: openjdk-jdk10   File: bug4697612.java   View Source Code Vote up 6 votes
private static void createAndShowGUI() {
    frame = new JFrame();
    frame.setSize(FRAME_WIDTH, FRAME_HEIGHT);
    frame.setPreferredSize(new Dimension(FRAME_WIDTH, FRAME_HEIGHT));
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    text = new JTextArea();
    try {
        InputStream is =
                bug4697612.class.getResourceAsStream("bug4697612.txt");
        text.read(new InputStreamReader(is), null);
    } catch (IOException e) {
        throw new Error(e);
    }

    scroller = new JScrollPane(text);

    frame.getContentPane().add(scroller);

    frame.pack();
    frame.setVisible(true);
}
 
Example 7
Project: JAddOn   File: JExpandableTextArea.java   View Source Code Vote up 5 votes
public static void test() {
    JFrame frame = new JFrame();
    frame.setPreferredSize(new Dimension(400, 400));
    frame.setLayout(new BorderLayout());
    JExpandableTextArea eta = new JExpandableTextArea(10, 20);
    JScrollPane sp = new JScrollPane(eta);
    JPanel panel = new JPanel();
    panel.add(sp);
    frame.add(panel, BorderLayout.CENTER);
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
}
 
Example 8
Project: BrainControl   File: SoundDeviceSelectionUI.java   View Source Code Vote up 5 votes
public SoundDeviceSelectionUI(List<String> _InputSoundDevices, SoundInputDeviceControl sDeviceControl) {
	soundDevices = _InputSoundDevices;
	this.sDeviceControl = sDeviceControl;
	frame = new JFrame("Select Recording Device");
	frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
	frame.setPreferredSize(new Dimension(500, 300));
	setupUI();
}
 
Example 9
Project: jaer   File: ApsFrameExtractor.java   View Source Code Vote up 5 votes
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 10
Project: jaer   File: ConvolutionFeatureScheme.java   View Source Code Vote up 5 votes
public ConvolutionFeatureScheme (AEChip chip) {
	super(chip);
	this.chip = chip;

	pixelbuffer = new PixelBuffer(chip);
	filterchain = new FilterChain(chip);

	sizex = chip.getSizeX();
	sizey = chip.getSizeY();

	display = ImageDisplay.createOpenGLCanvas(); // makde a new ImageDisplay GLCanvas with default OpenGL capabilities
	featureFrame = new JFrame("ImageFrameth");  // make a JFrame to hold it
	featureFrame.setPreferredSize(new Dimension(sizex, sizey));  // set the window size
	featureFrame.getContentPane().add(display, BorderLayout.CENTER); // add the GLCanvas to the center of the window
	featureFrame.pack(); // otherwise it wont fill up the display

	initFilter();

	filterchain.add(new BackgroundActivityFilter(chip));
	filterchain.add( pixelbuffer );
	pixelbuffer.setConvolutionFeatureScheme(this);
	setEnclosedFilterChain(filterchain);    //creates a filter chain instance and passes this object to the kernel
	//method for all processing
	pixelbuffer.setEnclosed(true, this);

	strFilePath = "C:/Users/Varad/Downloads/descriptors.txt";
}
 
Example 11
Project: jaer   File: BinaryFeatureDetector.java   View Source Code Vote up 5 votes
public BinaryFeatureDetector (AEChip chip) {

		super(chip);
		this.chip = chip;

		pixelbuffer = new PixelBuffer(chip);
		filterchain = new FilterChain(chip);

		sizex = chip.getSizeX();
		sizey = chip.getSizeY();

		display = ImageDisplay.createOpenGLCanvas(); // makde a new ImageDisplay GLCanvas with default OpenGL capabilities
		featureFrame = new JFrame("ImageFrameth");  // make a JFrame to hold it
		featureFrame.setPreferredSize(new Dimension(sizex, sizey));  // set the window size
		featureFrame.getContentPane().add(display, BorderLayout.CENTER); // add the GLCanvas to the center of the window
		featureFrame.pack(); // otherwise it wont fill up the display



		filterchain.add(new BackgroundActivityFilter(chip));
		filterchain.add( pixelbuffer );
		pixelbuffer.setBinaryFeatureDetector(this);
		initFilter();
		setEnclosedFilterChain(filterchain);    //creates a filter chain instance and passes this object to the kernel
		//method for all processing
		//        initFilter();
		pixelbuffer.setEnclosed(true, this);

		//        initFilter();


	}
 
Example 12
Project: jaer   File: PlotHistogram.java   View Source Code Vote up 5 votes
public void createHistogramFrame() {        
    histogramFrame = new JFrame(histogramName);
    histogramFrame.setPreferredSize(new Dimension(820, 620));
    histogramFrame.getContentPane().setBackground(Color.white);

    histogramCanvas = new HistGCanvas(histogram);
    histogramFrame.getContentPane().add(histogramCanvas);
    histoMouselistener = new HistogramMouselistener(histogramCanvas);
    histogramFrame.addMouseListener(histoMouselistener);
    histogramCanvas.addMouseListener(histoMouselistener);
    histogramFrame.setVisible(true);
}
 
Example 13
Project: jaer   File: SourceSynchronizer.java   View Source Code Vote up 5 votes
public SourceSynchronizer(ArrayList<AEViewer.Ambassador> viewerlist)
{
    this(viewerlist,null);
    
    JFrame fr=new JFrame();
    fr.setContentPane(panel);
    fr.setTitle("Synchronization");
    fr.setPreferredSize(new Dimension(500,300));
    fr.pack();
    fr.setVisible(true);
    
}
 
Example 14
Project: ohjelmistotuotanto2017   File: GraafinenLaskin.java   View Source Code Vote up 5 votes
@Override
public void run() {
    frame = new JFrame("Laskin");
    frame.setPreferredSize(new Dimension(300, 150));
    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
     
    luoKomponentit(frame.getContentPane());
 
    frame.pack();
    frame.setVisible(true);
}
 
Example 15
Project: WePush   File: MainWindow.java   View Source Code Vote up 5 votes
public static void main(String[] args) {
    logger.info("main start");

    Init.initTheme();
    Init.initGlobalFont();  //统一设置字体

    frame = new JFrame(ConstantsUI.APP_NAME);
    frame.setIconImage(ConstantsUI.IMAGE_ICON);
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); //得到屏幕的尺寸
    frame.setBounds((int) (screenSize.width * 0.1), (int) (screenSize.height * 0.08), (int) (screenSize.width * 0.8),
            (int) (screenSize.height * 0.8));

    Dimension preferSize = new Dimension((int) (screenSize.width * 0.8),
            (int) (screenSize.height * 0.8));
    frame.setPreferredSize(preferSize);

    mainWindow = new MainWindow();

    frame.setContentPane(mainWindow.mainPanel);
    frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    frame.pack();
    frame.setVisible(true);

    Init.initOthers();
    Init.initAllTab();

    // 添加事件监听
    AboutListener.addListeners();
    SettingListener.addListeners();
    MsgListener.addListeners();
    MemberListener.addListeners();
    PushListener.addListeners();
    ScheduleListener.addListeners();
    TabListener.addListeners();
    FramListener.addListeners();
}
 
Example 16
Project: intellij-deps-ini4j   File: DemoMain.java   View Source Code Vote up 5 votes
@Override public void run()
{
    JFrame frame = new JFrame("TopLevelDemo");

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setPreferredSize(new Dimension(800, 600));
    _demo = new Demo(frame.getContentPane());
    _demo.init();
    frame.pack();
    frame.setVisible(true);
}
 
Example 17
Project: jreliability   File: ReliabilityViewer.java   View Source Code Vote up 4 votes
/**
 * Constructs and views {@link JFrame} with a given title and a list of {@link ReliabilityFunction}s.
 * 
 * @param title
 *            the title
 * @param reliabilityFunctions
 *            the reliabilityFunctions
 */
public static void view(String title, Map<String, ReliabilityFunction> reliabilityFunctions) {

	try {
		UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
	} catch (Exception e) {
		e.printStackTrace();
	}

	// Setup the aspects for the plot panel
	List<Aspect> aspects = new ArrayList<>();
	aspects.add(new ReliabilityFunctionAspect());
	aspects.add(new DistributionAspect());
	aspects.add(new DensityAspect());
	aspects.add(new FailureRateAspect());
	ReliabilityFunctionPlotPanel reliabilityFunctionPlotPanel = new ReliabilityFunctionPlotPanel(aspects);
	JPanel plotPanel = reliabilityFunctionPlotPanel.get(reliabilityFunctions);

	JPanel measuresPanel = new MeasuresPanel(reliabilityFunctions);

	JFrame frame = new JFrame();

	frame.setTitle(title);
	frame.setIconImage(getImageIcon().getImage());
	frame.setPreferredSize(new Dimension(1000, 500));
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

	Container content = frame.getContentPane();
	frame.setLayout(new GridBagLayout());
	GridBagConstraints c = new GridBagConstraints();
	c.ipady = 10;
	c.ipadx = 10;
	c.fill = GridBagConstraints.BOTH;

	c.gridx = 0;
	c.gridy = 5;
	c.weighty = 0.5;
	content.add(measuresPanel, c);
	c.gridx = 1;
	c.gridy = 5;
	c.weightx = 1.0;
	c.weighty = 0.5;
	content.add(plotPanel, c);

	c.gridx = 0;
	c.gridy = 20;
	c.gridwidth = 2;
	c.weighty = 0.0;
	c.fill = GridBagConstraints.HORIZONTAL;
	c.anchor = GridBagConstraints.PAGE_END;
	content.add(new JLabel(" \u00A9 JReliability.org 2008-2017"), c);

	frame.pack();
	frame.setVisible(true);
}
 
Example 18
Project: JavaMinicap   File: MainFrame.java   View Source Code Vote up 4 votes
public void init(){
		JFrame.setDefaultLookAndFeelDecorated(true);
		f = new JFrame();
		f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		f.setPreferredSize(new Dimension(FRAME_WIDTH, FRAME_HEIGHT));
		f.setTitle("群控");       
		f.setResizable(true);   
		f.setLocationRelativeTo(null);
		
		jpControl = new JPanel();
		jbSendZone = new JButton("发送朋友圈");
		jpControl.add(jbSendZone);
		
		jpDevice = new JPanel();
//		jpDevice.setLayout(new FlowLayout(FlowLayout.LEADING, 20, 5));
		jpDevice.setLayout(new WrapLayout(WrapLayout.LEFT));
		Iterator<Entry<String, Thread>> iter = Devices.devices.entrySet().iterator();
		int port = 1313, count=0;
		while(iter.hasNext()){
			Map.Entry<String, Thread> entry = (Map.Entry<String, Thread>)iter.next();
			String serial = entry.getKey();
			JPanel jp = new JPanel();
			DrawImageThread dit = new DrawImageThread(serial, port++, jp);
			dit.start();			//启动绘制线程
			entry.setValue(dit);	//在device list中保存线程句柄
			
			count++;
			jpDevice.add(jp);
		}
		jspDevice = new JScrollPane(jpDevice);
		jspDevice.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
	
		jsp = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, jpControl, jspDevice);
		jsp.setDividerLocation(0.3);
		jsp.setDividerSize(10);
		jsp.setOneTouchExpandable(true);
		f.add(jsp);
		
		f.pack();
		f.setVisible(true);
	}
 
Example 19
Project: propan-jogl-examples   File: AWTExample.java   View Source Code Vote up 3 votes
public static void main(String[] args) {
	JFrame frame = new JFrame("GLG2D AWT Example");
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	frame.setPreferredSize(new Dimension(300, 300));

	JComponent comp = Example.createComponent();

	GLG2DCanvas canvas = new GLG2DCanvas();
	
	frame.setContentPane(canvas);

	frame.pack();
	frame.setVisible(true);
	
}