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

The following are Jave code examples for showing how to use setSize() 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: trashjam2017   File: GradientEditor.java   View Source Code Vote up 6 votes
/**
 * Simple test case for the gradient painter
 * 
 * @param argv The arguments supplied at the command line
 */
public static void main(String[] argv) {
	JFrame frame = new JFrame();
	JPanel panel = new JPanel();
	panel.setBorder(BorderFactory.createTitledBorder("Gradient"));
	panel.setLayout(null);
	frame.setContentPane(panel);
		
	GradientEditor editor = new GradientEditor();
	editor.setBounds(10,15,270,100);
	panel.add(editor);
	frame.setSize(300,200);
	
	frame.addWindowListener(new WindowAdapter() {
		public void windowClosing(WindowEvent e) {
			System.exit(0);
		}
	});
	
	frame.setVisible(true);
}
 
Example 2
Project: openjdk-jdk10   File: bug6421058.java   View Source Code Vote up 6 votes
private static void testDefaultFont(final JFrame frame) {
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JSpinner spinner = new JSpinner();
    frame.add(spinner);
    frame.setSize(300, 100);
    frame.setVisible(true);

    final DefaultEditor editor = (DefaultEditor) spinner.getEditor();
    final Font editorFont = editor.getTextField().getFont();

    /*
     * Validate that the font of the text field is changed to the
     * font of JSpinner if the font of text field was not set by the
     * user.
     */

    if (!(editorFont instanceof UIResource)) {
        throw new RuntimeException("Font must be UIResource");
    }
    if (!editorFont.equals(spinner.getFont())) {
        throw new RuntimeException("Wrong FONT");
    }
}
 
Example 3
Project: rapidminer   File: AggregationPopulationPlotter.java   View Source Code Vote up 6 votes
@Override
public void startVisualization(Object id) {
	int index = 0;
	if (id instanceof String) {
		String idString = (String) id;
		index = Integer.parseInt(idString.substring(0, idString.indexOf("(")).trim());
	} else {
		index = ((Double) id).intValue();
	}
	AggregationIndividual individual = lastPopulation.get(index);
	ExampleSet es = null;
	try {
		es = individual.createExampleSet(originalExampleSet, allAttributes, generator);
	} catch (GenerationException e) {
		throw new RuntimeException("Cannot visualize individual '" + index + "': " + e.getMessage());
	}
	Component visualizationComponent = ResultDisplayTools.createVisualizationComponent(es, null, es.getName());
	JFrame frame = new JFrame();
	frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
	frame.getContentPane().setLayout(new BorderLayout());
	frame.getContentPane().add(new ExtendedJScrollPane(visualizationComponent), BorderLayout.CENTER);
	frame.setSize(600, 400);
	frame.setLocationRelativeTo(null);
	frame.setVisible(true);
}
 
Example 4
Project: HamJournal   File: SearchFile.java   View Source Code Vote up 6 votes
void popUpInput() {
	popUpSearch = new JFrame("Search for Entry");
	dateToSearchFor = new JTextField();
	search = new JButton("Search");
	southPanel = new JPanel();
	JLabel label = new JLabel("Entry date to search for");
	closeWindow = new JButton("Close");
	
	search.addActionListener(new GetSearchParameter());
	closeWindow.addActionListener(new CloseTheWindow());
	
	popUpSearch.getContentPane().add(BorderLayout.NORTH, label);
	popUpSearch.getContentPane().add(BorderLayout.CENTER, dateToSearchFor);
	popUpSearch.getContentPane().add(BorderLayout.SOUTH, southPanel);
	
	southPanel.add(search);
	southPanel.add(closeWindow);
	
	popUpSearch.setSize(300, 110);
	popUpSearch.setVisible(true);
	popUpSearch.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	
}
 
Example 5
Project: human-mobility-modeling-utilities   File: RegularBinningTest.java   View Source Code Vote up 6 votes
public static void main(String[] args) {

		JFrame frame = new JFrame("Displacement plot");
		frame.setSize(new Dimension(800, 300));
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setLocationRelativeTo(null);
        frame.getContentPane().add(new RegularBinningTest());
        frame.setVisible(true);
	        
	}
 
Example 6
Project: bhattiprolu-pad   File: BhattiproluPad.java   View Source Code Vote up 6 votes
public BhattiproluPad() {
	mainFrame = new JFrame("Bhattiprolu Pad - Now, type in Telugu easily");
	mainFrame.setSize(800, 800);
	mainFrame.setLayout(new GridLayout(3, 1));

	headLabel = new JLabel("Bhattiprolu Pad 0.1", JLabel.CENTER);
	contentLabel = new JLabel("Empty", JLabel.CENTER);
	mainPanel = new JPanel();
	mainPanel.setLayout(new FlowLayout());

	headLabel.setFont(englishFont);
	contentLabel.setFont(teluguFont);

	mainFrame.add(headLabel);
	mainFrame.add(mainPanel);
	mainFrame.add(contentLabel);
	mainFrame.setVisible(true);
	mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}
 
Example 7
Project: geomapapp   File: MapApp.java   View Source Code Vote up 5 votes
protected synchronized void detachDisplay() {
	if (currentDB == null) return;
	if (currentDB.getDataDisplay() == null) return;
	if (currentDB.getDataDisplay().getPreferredSize().height < 50) return;

	JFrame displayDialog = getDataDisplayDialog();
	displayDialog.setTitle( currentDB.getDBName() );

	displayDialog.getContentPane().removeAll();
	displayDialog.getContentPane().add(currentDB.getDataDisplay());

	int w = vPane.getSize().width;
	int h = currentDB.getDataDisplay().getPreferredSize().height;
	if(h>200) h=200;

	int x = frame.getLocationOnScreen().x;
	int y = frame.getLocationOnScreen().y + frame.getHeight();

	displayDialog.setSize(w, h);
	displayDialog.setLocation(x, y);

	vPane.setBottomComponent( null );
	displayDialog.setState( Frame.NORMAL );
	displayDialog.setVisible(true);
	detach_attachB.setText("Attach Profile/Table");
	attached = false;
}
 
Example 8
Project: LivroJavaComoProgramar10Edicao   File: Shapes2.java   View Source Code Vote up 5 votes
public static void main(String[] args)
{
   // create frame for Shapes2JPanel
   JFrame frame = new JFrame("Drawing 2D Shapes");
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

   Shapes2JPanel shapes2JPanel = new Shapes2JPanel(); 
   frame.add(shapes2JPanel); 
   frame.setBackground(Color.WHITE);
   frame.setSize(315, 330);
   frame.setVisible(true);
}
 
Example 9
Project: smile_1.5.0_java7   File: SpectralClusteringDemo.java   View Source Code Vote up 5 votes
public static void main(String argv[]) {
    ClusteringDemo demo = new SpectralClusteringDemo();
    JFrame f = new JFrame("Spectral Clustering");
    f.setSize(new Dimension(1000, 1000));
    f.setLocationRelativeTo(null);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.getContentPane().add(demo);
    f.setVisible(true);
}
 
Example 10
Project: smile_1.5.0_java7   File: SOMDemo.java   View Source Code Vote up 5 votes
public static void main(String argv[]) {
    ClusteringDemo demo = new SOMDemo();
    JFrame f = new JFrame("SOM");
    f.setSize(new Dimension(1000, 1000));
    f.setLocationRelativeTo(null);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.getContentPane().add(demo);
    f.setVisible(true);
}
 
Example 11
Project: openjdk-jdk10   File: ComponentResizeTest.java   View Source Code Vote up 5 votes
private static void createAndShowGUI() {
    demoFrame = new JFrame();
    demoFrame.setSize(300, 300);
    demoFrame.setLayout(new FlowLayout());
    demoFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    demoFrame.setUndecorated(true);
    demoFrame.setBackground(new Color(0f, 0, 0, 0.1f));
    JCheckBox b = new JCheckBox("Whatever");
    demoFrame.paintAll(null);
    b.setOpaque(true);
    demoFrame.add(b);
    demoFrame.add(new JButton());
    demoFrame.setVisible(true);
}
 
Example 12
Project: LivroJavaComoProgramar10Edicao   File: LabelDemo.java   View Source Code Vote up 5 votes
public static void main(String[] args)
{
   // Create a label with plain text
   JLabel northLabel = new JLabel("North");
   
   // create an icon from an image so we can put it on a JLabel
   ImageIcon labelIcon = new ImageIcon("GUItip.gif");
   
   // create a label with an Icon instead of text
   JLabel centerLabel = new JLabel(labelIcon);
   
   // create another label with an Icon
   JLabel southLabel = new JLabel(labelIcon);
   
   // set the label to display text (as well as an icon)
   southLabel.setText("South");
   
    // create a frame to hold the labels
   JFrame application = new JFrame();
   
   application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

   // add the labels to the frame; the second argument specifies
   // where on the frame to add the label 
   application.add(northLabel, BorderLayout.NORTH);
   application.add(centerLabel, BorderLayout.CENTER);      
   application.add(southLabel, BorderLayout.SOUTH);      

   application.setSize(300, 300); // set the size of the frame
   application.setVisible(true); // show the frame
}
 
Example 13
Project: incubator-netbeans   File: PropertyMarkingTest.java   View Source Code Vote up 5 votes
protected void setUp() throws Exception {
    if (setup) return;
    PropUtils.forceRadioButtons=false;
    
    try {
        
        tp = new TProperty("oh", true);
        tp1 = new TProperty2("the", true);
        tp2 = new TProperty2("pretty", true);
        tp3 = new TProperty2("pictures",true);
        tp4 = new TProperty3("I can create",true);
        postSetAction = new PostSetAction();
        
        tn = new TNode();
        
        final PropertySheet ps = new PropertySheet();
        
        //ensure no stored value in preferences:
        ps.setCurrentNode(tn);
        sleep();
        ps.setSortingMode(PropertySheet.UNSORTED);
        
        jf = new JFrame();
        jf.getContentPane().add(ps);
        jf.setLocation(20,20);
        jf.setSize(300, 400);
        new WaitWindow(jf);
        tb = ps.table;
        
        ps.setSortingMode(ps.SORTED_BY_NAMES);
        jf.repaint();
        
        
    } catch (Exception e) {
        e.printStackTrace();
        fail("FAILED - Exception thrown "+e.getClass().toString());
    } finally {
        setup = true;
    }
}
 
Example 14
Project: Install_Builder_Universal   File: LogWindow.java   View Source Code Vote up 5 votes
public LogWindow() {
	frame = new JFrame();
	frame.setTitle("Latest Log");
	frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
	frame.setSize(600, 480);
	frame.setLocationRelativeTo(null);
	frame.setResizable(false);
	frame.setLayout(null);
	
	panel = new JPanel();
	frame.add(panel);
	
	init();
}
 
Example 15
Project: Install_Builder_Universal   File: AboutWindow.java   View Source Code Vote up 5 votes
public AboutWindow() {
	frame = new JFrame();
	frame.setTitle("About");
	frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
	frame.setSize(325, 280);
	frame.setLocationRelativeTo(null);
	frame.setResizable(false);
	frame.setLayout(null);
	
	panel = new JPanel();
	frame.add(panel);
	
	initialize();
	frame.setVisible(true);
}
 
Example 16
Project: Tarski   File: Visualization.java   View Source Code Vote up 5 votes
public void showMetamodel() {
  xmlCreator.setMetamodel(true);
  frame = new JFrame("Visualization");
  frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
  frame.add(getGraph(), BorderLayout.CENTER);
  frame.setVisible(true);
  frame.setSize(500, 500);
}
 
Example 17
Project: LivroJavaComoProgramar10Edicao   File: LinesRectsOvals.java   View Source Code Vote up 5 votes
public static void main(String[] args)
{
   // create frame for LinesRectsOvalsJPanel
   JFrame frame = 
      new JFrame("Drawing lines, rectangles and ovals");
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

   LinesRectsOvalsJPanel linesRectsOvalsJPanel = 
      new LinesRectsOvalsJPanel(); 
   linesRectsOvalsJPanel.setBackground(Color.WHITE); 
   frame.add(linesRectsOvalsJPanel); 
   frame.setSize(400, 210);
   frame.setVisible(true);
}
 
Example 18
Project: openjdk-jdk10   File: Test8051548.java   View Source Code Vote up 5 votes
private static void createAndShowGUI() {
    JFrame frame = new JFrame();
    frame.setSize(700, 500);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    colorChooser = new JColorChooser();
    frame.getContentPane().add(colorChooser);
    frame.setVisible(true);
}
 
Example 19
Project: smile_1.5.0_java7   File: PPCADemo.java   View Source Code Vote up 5 votes
public static void main(String argv[]) {
    PPCADemo demo = new PPCADemo();
    JFrame f = new JFrame("Probabilistic Principal Component Analysis");
    f.setSize(new Dimension(1000, 1000));
    f.setLocationRelativeTo(null);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.getContentPane().add(demo);
    f.setVisible(true);
}
 
Example 20
Project: Community_Tieba-Data-Analyzer   File: Test.java   View Source Code Vote up 5 votes
private static void onGUI(){
	frame = new JFrame("Encrypter");
	en = new JButton("Encrypt");
	de = new JButton("Decrypt");
	panel = new JPanel();
	panel2 = new JPanel();
	panel3 = new JPanel();
	input = new JTextField("input file this is");
	output = new JTextField(10);
	code  = new JTextField(5);
	codeIn = new JTextField("Enter the Registration ID Raw");
	trans = new JButton("Get the Real Registration ID");
	frame.getContentPane().add(panel, BorderLayout.NORTH);
	frame.getContentPane().add(panel2, BorderLayout.CENTER);
	frame.getContentPane().add(panel3, BorderLayout.SOUTH);
	panel.add(input);
	panel.add(output);
	panel.add(code);
	panel2.add(en);
	panel2.add(de);
	panel3.setLayout(new GridLayout(2,1));
	panel3.add(codeIn);
	panel3.add(trans);
	trans.addActionListener(event -> getRealID(codeIn.getText()));
	en.addActionListener(event -> encrypt(input.getText(),output.getText(),Integer.parseInt(code.getText())));
	de.addActionListener(event -> decrypt(input.getText(),output.getText(),Integer.parseInt(code.getText())));
	frame.setLocation(1366/3, 768/3);
	frame.setDefaultCloseOperation(3);
	frame.setSize(500, 300);
	frame.setVisible(true);
}