Java Code Examples for javax.swing.JFrame#setResizable()

The following examples show how to use javax.swing.JFrame#setResizable() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
private void createDisplay(){
	frame = new JFrame(title);
	frame.setSize(width, height);
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	frame.setResizable(false);
	frame.setLocationRelativeTo(null);
	frame.setVisible(true);
	
	canvas = new Canvas();
	canvas.setPreferredSize(new Dimension(width, height));
	canvas.setMaximumSize(new Dimension(width, height));
	canvas.setMinimumSize(new Dimension(width, height));
	canvas.setFocusable(false);
	
	frame.add(canvas);
	frame.pack();
}
 
Example 2
private void createDisplay(){
	frame = new JFrame(title);
	frame.setSize(width, height);
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	frame.setResizable(false);
	frame.setLocationRelativeTo(null);
	frame.setVisible(true);
	
	canvas = new Canvas();
	canvas.setPreferredSize(new Dimension(width, height));
	canvas.setMaximumSize(new Dimension(width, height));
	canvas.setMinimumSize(new Dimension(width, height));
	
	frame.add(canvas);
	frame.pack();
}
 
Example 3
/**
 * Test code
 */
static public void main(String[] args) {
  try {
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    Gate.init();
  }
  catch(Exception e) {
    e.printStackTrace();
  }
  JFrame frame = new JFrame("Foo");
  SingleConcatenatedFileInputDialog comp = new SingleConcatenatedFileInputDialog();
  frame.getContentPane().add(comp);
  frame.pack();
  frame.setResizable(false);
  frame.setVisible(true);
}
 
Example 4
private void createDisplay(){
	frame = new JFrame(title);
	frame.setSize(width, height);
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	frame.setResizable(false);
	frame.setLocationRelativeTo(null);
	frame.setVisible(true);
	
	canvas = new Canvas();
	canvas.setPreferredSize(new Dimension(width, height));
	canvas.setMaximumSize(new Dimension(width, height));
	canvas.setMinimumSize(new Dimension(width, height));
	
	frame.add(canvas);
	frame.pack();
}
 
Example 5
private void createDisplay(){
	frame = new JFrame(title);
	frame.setSize(width, height);
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	frame.setResizable(false);
	frame.setLocationRelativeTo(null);
	frame.setVisible(true);
	
	canvas = new Canvas();
	canvas.setPreferredSize(new Dimension(width, height));
	canvas.setMaximumSize(new Dimension(width, height));
	canvas.setMinimumSize(new Dimension(width, height));
	canvas.setFocusable(false);
	
	frame.add(canvas);
	frame.pack();
}
 
Example 6
private void createDisplay(){
	frame = new JFrame(title);
	frame.setSize(width, height);
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	frame.setResizable(false);
	frame.setLocationRelativeTo(null);
	frame.setVisible(true);
	
	canvas = new Canvas();
	canvas.setPreferredSize(new Dimension(width, height));
	canvas.setMaximumSize(new Dimension(width, height));
	canvas.setMinimumSize(new Dimension(width, height));
	canvas.setFocusable(false);
	
	frame.add(canvas);
	frame.pack();
}
 
Example 7
public static JFrame createJFrame(MTGUIComponent p, boolean resizable,boolean exitOnClose)
{
	JFrame f = new JFrame(p.getTitle());
	f.setIconImage(p.getIcon().getImage());
	f.getContentPane().add(p);
	f.pack();
	f.setResizable(resizable);
	f.addWindowListener(new WindowAdapter() {
		@Override
		public void windowClosing(WindowEvent e) {
			p.onDestroy();
			
			if(exitOnClose)
				System.exit(0);
		}
	});
	return f;
}
 
Example 8
Source Project: pumpernickel   File: FadingPanel.java    License: MIT License 5 votes vote down vote up
public static void main(String[] args) {
	JFrame f = new JFrame();
	final FadingPanel fadingPanel = new FadingPanel();
	fadingPanel.setLayout(new GridBagLayout());
	GridBagConstraints c = new GridBagConstraints();
	c.gridx = 0;
	c.gridy = 0;
	final JCheckBox checkBox = new JCheckBox("Toggle Me");
	final JSlider slider = new JSlider();
	fadingPanel.add(checkBox, c);
	c.gridy++;
	fadingPanel.add(slider, c);

	f.setResizable(false);

	f.getContentPane().add(fadingPanel);
	f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	f.pack();
	f.setVisible(true);

	checkBox.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) {
			if (checkBox.isSelected()) {
				fadingPanel.animateStates(new Runnable() {
					public void run() {
						slider.setValue(0);
					}
				}, 250);
			} else {
				fadingPanel.animateStates(new Runnable() {
					public void run() {
						slider.setValue(100);
					}
				}, 250);
			}
		}
	});
}
 
Example 9
Source Project: OptimizedImageEnhance   File: ImShow.java    License: MIT License 5 votes vote down vote up
public ImShow(String title) {
	Window = new JFrame();
	image = new ImageIcon();
	label = new JLabel();
	// matOfByte = new MatOfByte();
	label.setIcon(image);
	Window.getContentPane().add(label);
	Window.setResizable(false);
	Window.setTitle(title);
	SizeCustom = false;
	setCloseOption(0);
}
 
Example 10
Source Project: OptimizedImageEnhance   File: ImShow.java    License: MIT License 5 votes vote down vote up
public ImShow(String title, int height, int width) {
	SizeCustom = true;
	Height = height;
	Width = width;
	Window = new JFrame();
	image = new ImageIcon();
	label = new JLabel();
	// matOfByte = new MatOfByte();
	label.setIcon(image);
	Window.getContentPane().add(label);
	Window.setResizable(false);
	Window.setTitle(title);
	setCloseOption(0);

}
 
Example 11
/**
 * Test code
 */
static public void main(String[] args){
  try{
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    Gate.init();
  }catch(Exception e){
    e.printStackTrace();
  }
  JFrame frame = new JFrame("Foo");
  CorpusFillerComponent comp = new CorpusFillerComponent();
  frame.getContentPane().add(comp);
  frame.pack();
  frame.setResizable(false);
  frame.setVisible(true);
}
 
Example 12
private void displayFeatureSpace() {
    double[][] features = featureSpace.get3dFeatureSpace(lastFV);
    ResultDataParser parser = new ResultDataParser(features);
    try {
        parser.parse();
    } catch (ParserException pe) {
        System.out.println(pe.toString());
        System.exit(1);
    }


    JFrame frame = new JFrame("3D Face Recognition Results Chart");
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frame.getContentPane().setLayout(new BorderLayout());

    resultsData = parser;
    Canvas resultsCanvas = ResultsChart.getCanvas();
    JPanel resultsPanel = new JPanel();
    resultsPanel.setOpaque(false);
    resultsPanel.setLayout(new BorderLayout());
    resultsPanel.add(resultsCanvas, BorderLayout.CENTER);

    frame.getContentPane().add(resultsPanel, BorderLayout.CENTER);

    JLabel lbl = new JLabel("3D Face Recognition");
    lbl.setBackground(Color.BLACK);
    lbl.setForeground(Color.WHITE);
    lbl.setOpaque(true);
    lbl.setFont(lbl.getFont().deriveFont(Font.BOLD));
    frame.getContentPane().add(lbl, BorderLayout.SOUTH);
    ResultsChart resultsChart =
            new ResultsChart(resultsCanvas, resultsData);

    frame.setSize(800, 720);
    frame.setResizable(false);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
}
 
Example 13
private void createDisplay(){
	frame = new JFrame(title);
	frame.setSize(width, height);
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	frame.setResizable(false);
	frame.setLocationRelativeTo(null);
	frame.setVisible(true);
	
	canvas = new Canvas();
	canvas.setPreferredSize(new Dimension(width, height));
	canvas.setMaximumSize(new Dimension(width, height));
	canvas.setMinimumSize(new Dimension(width, height));
	canvas.setFocusable(false);
	
	frame.add(canvas);
	frame.pack();
}
 
Example 14
Source Project: Java-Data-Analysis   File: Example3.java    License: MIT License 5 votes vote down vote up
public static void main(String[] args) {
    Data data = new Data(new File("data/Data1.dat"));
    JFrame frame = new JFrame(data.getTitle());
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    RegressionPanel panel = new RegressionPanel(data);
    frame.add(panel);
    frame.pack();
    frame.setSize(500, 422);
    frame.setResizable(false);
    frame.setLocationRelativeTo(null);  // center frame on screen
    frame.setVisible(true);
}
 
Example 15
Source Project: ThinkJavaCode2   File: Automaton.java    License: MIT License 5 votes vote down vote up
/**
 * Creates a JFrame and runs the automaton.
 * 
 * @param title the frame title
 * @param rate frames per second
 */
public void run(String title, int rate) {
    // set up the window frame
    JFrame frame = new JFrame(title);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setResizable(false);
    frame.add(this.grid);
    frame.pack();
    frame.setVisible(true);
    this.mainloop(rate);
}
 
Example 16
private void createDisplay(){
	frame = new JFrame(title);
	frame.setSize(width, height);
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	frame.setResizable(false);
	frame.setLocationRelativeTo(null);
	frame.setVisible(true);
	
	canvas = new Canvas();
	canvas.setPreferredSize(new Dimension(width, height));
	canvas.setMaximumSize(new Dimension(width, height));
	canvas.setMinimumSize(new Dimension(width, height));
	canvas.setFocusable(false);
	
	frame.add(canvas);
	frame.pack();
}
 
Example 17
/**
 * Creates and initializes a new display.
 *
 * @param width  How wide the display is, in pixels.
 * @param height How tall the display is, in pixels.
 * @param title  The text displayed in the window's title bar.
 */
public Display(int width, int height, String title)
{
	//Set the canvas's preferred, minimum, and maximum size to prevent
	//unintentional resizing.
	Dimension size = new Dimension(width, height);
	setPreferredSize(size);
	setMinimumSize(size);
	setMaximumSize(size);

	//Creates images used for display.
	m_frameBuffer = new RenderContext(width, height);
	m_displayImage = new BufferedImage(width, height, BufferedImage.TYPE_3BYTE_BGR);
	m_displayComponents = 
		((DataBufferByte)m_displayImage.getRaster().getDataBuffer()).getData();

	m_frameBuffer.Clear((byte)0x80);
	m_frameBuffer.DrawPixel(100, 100, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xFF);

	//Create a JFrame designed specifically to show this Display.
	m_frame = new JFrame();
	m_frame.add(this);
	m_frame.pack();
	m_frame.setResizable(false);
	m_frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	m_frame.setLocationRelativeTo(null);
	m_frame.setTitle(title);
	m_frame.setSize(width, height);
	m_frame.setVisible(true);

	//Allocates 1 display buffer, and gets access to it via the buffer
	//strategy and a graphics object for drawing into it.
	createBufferStrategy(1);
	m_bufferStrategy = getBufferStrategy();
	m_graphics = m_bufferStrategy.getDrawGraphics();
	
	m_input = new Input();
	addKeyListener(m_input);
	addFocusListener(m_input);
	addMouseListener(m_input);
	addMouseMotionListener(m_input);

	setFocusable(true);
	requestFocus();
}
 
Example 18
/**
 * Initialize the contents of the frame.
 */
private void initialize() {
	discoFrame = new JFrame();
	discoFrame.setTitle("Disco Mixer");
	discoFrame.setIconImage(Toolkit.getDefaultToolkit().getImage(
			DiscoMixer.class.getResource("/resources/aurouslogo.png")));
	discoFrame.setType(Type.UTILITY);
	discoFrame.setResizable(false);
	discoFrame.setBounds(100, 100, 606, 239);
	discoFrame
	.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
	discoFrame.getContentPane().setLayout(null);
	discoFrame.addWindowListener(new java.awt.event.WindowAdapter() {
		@Override
		public void windowClosing(
				final java.awt.event.WindowEvent windowEvent) {
			final int confirm = JOptionPane.showOptionDialog(discoFrame,
					"Are You Sure You Want to Close Disco Mixer?",
					"Exit Confirmation", JOptionPane.YES_NO_OPTION,
					JOptionPane.QUESTION_MESSAGE, null, null, null);
			if (confirm == 0) {
				Playlist.getPlaylist().discoOpen = false;
				discoFrame.dispose();
			}

		}
	});

	final JLabel logoLabel = new JLabel("");
	logoLabel.setHorizontalAlignment(SwingConstants.CENTER);
	logoLabel.setIcon(new ImageIcon(DiscoMixer.class
			.getResource("/resources/fmw.png")));
	logoLabel.setBounds(10, 0, 580, 70);
	discoFrame.getContentPane().add(logoLabel);

	discoProgressBar = new JProgressBar();
	discoProgressBar.setStringPainted(true);
	discoProgressBar.setBounds(113, 119, 380, 49);
	discoProgressBar.setVisible(false);
	discoFrame.getContentPane().add(discoProgressBar);

	queryField = new JTextField();
	queryField.setFont(new Font("Segoe UI", Font.PLAIN, 20));
	queryField.setHorizontalAlignment(SwingConstants.CENTER);
	queryField.setBounds(113, 119, 380, 44);
	discoFrame.getContentPane().add(queryField);
	queryField.setColumns(10);

	final JLabel instructionsLabel = new JLabel(
			"Enter an Artist, Song or Choose from the Top 100!");
	instructionsLabel.setFont(new Font("Segoe UI", Font.PLAIN, 20));
	instructionsLabel.setHorizontalAlignment(SwingConstants.CENTER);
	instructionsLabel.setBounds(23, 81, 541, 27);
	discoFrame.getContentPane().add(instructionsLabel);

	discoBuildButton = new JButton("Disco!");
	discoBuildButton.addActionListener(e -> {
		if (!queryField.getText().trim().isEmpty()) {
			discoProgressBar.setVisible(true);
			YouTubeDiscoUtils.buildDiscoPlayList(queryField.getText());
		} else {
			JOptionPane.showMessageDialog(discoFrame,
					"Please enter search query", "Error",
					JOptionPane.ERROR_MESSAGE);
			return;
		}
	});
	discoBuildButton.setForeground(Color.BLACK);
	discoBuildButton.setBounds(197, 174, 100, 26);
	discoFrame.getContentPane().add(discoBuildButton);

	top100Button = new JButton("Top Hits!");
	top100Button.addActionListener(e -> {
		discoProgressBar.setVisible(true);
		YouTubeDiscoUtils.buildTopPlayList();
	});
	top100Button.setForeground(Color.BLACK);
	top100Button.setBounds(307, 174, 100, 26);
	discoFrame.getContentPane().add(top100Button);
	Playlist.getPlaylist().discoOpen = true;
	final GhostText ghostText = new GhostText("Ghost B.C.", queryField);
	ghostText.setHorizontalAlignment(SwingConstants.CENTER);
	discoFrame.setLocationRelativeTo(UISession.getPresenter().jfxPanel);
}
 
Example 19
public static void makeFullScreen(JFrame frame) {
	frame.setExtendedState(JFrame.MAXIMIZED_BOTH); 
	frame.setUndecorated(true);
	frame.setResizable(false);
}
 
Example 20
Source Project: MSPaintIDE   File: MainGUI.java    License: MIT License 4 votes vote down vote up
public static void main(String[] args) throws IOException, InterruptedException, ExecutionException {
    System.setProperty("logPath", APP_DATA.getAbsolutePath() + "\\log");
    LOGGER = LoggerFactory.getLogger(MainGUI.class);

    System.setProperty("java.library.path", System.getProperty("java.library.path") + ";" + System.getenv("PATH"));

    LOGGER.info("Running in dev mode: {}", DEV_MODE);

    if (!System.getProperty("os.name").toLowerCase().contains("windows")) {
        JFrame frame = new JFrame("MS Paint IDE");
        frame.setSize(700, 200);
        JPanel jPanel = new JPanel();
        jPanel.add(new JLabel("<html><br><br><div style='text-align: center;'>Sorry, MS Paint IDE only supports Windows<br> However, the developer of MS Paint IDE is going to be adding support soon. <br> Stay tuned</div><br></html>"));
        frame.add(jPanel);
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.setResizable(false);
        frame.pack();
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    }

    socketCommunicator = new DefaultInternalSocketCommunicator();

    if (args.length == 1) {
        var file = new File(args[0]);
        if (file.getName().endsWith(".ppf")) {
            if (socketCommunicator.serverAvailable()) {
                var message = "Error: You can't have more than one instance of MS Paint IDE running at the same time!";
                LOGGER.error(message);
                JOptionPane.showMessageDialog(null, message, "Fatal Error", JOptionPane.WARNING_MESSAGE);
                System.exit(1);
            }

            initialProject = initialProject.isFile() ? file : null;
        } else if (file.getName().endsWith(".png")) {
            Runtime.getRuntime().exec("mspaint.exe \"" + file.getAbsolutePath() + "\"");
            System.exit(0);
        } else {
            LOGGER.info("Name is {}", file.getName());
            if (!socketCommunicator.serverAvailable()) {
                HEADLESS = true;
                startServer(null);
                new TextEditorManager(file);
            } else {
                LOGGER.info("Server is available, connecting...");
                startDocumentClient(file.getAbsolutePath());
            }
            return;
        }
    }

    launch(args);
}