Example usage for javax.swing JFrame setResizable

List of usage examples for javax.swing JFrame setResizable

Introduction

In this page you can find the example usage for javax.swing JFrame setResizable.

Prototype

public void setResizable(boolean resizable) 

Source Link

Document

Sets whether this frame is resizable by the user.

Usage

From source file:Main.java

public static void main(String[] args) {
    JFrame.setDefaultLookAndFeelDecorated(true);
    JFrame frame = new JFrame();
    frame.setResizable(false);
    removeButtons(frame);//  w w  w.ja v  a2 s.  c  om
    JPanel panel = new JPanel(new GridBagLayout());
    JButton button = new JButton("Exit");
    panel.add(button, new GridBagConstraints());
    frame.getContentPane().add(panel);
    frame.setSize(400, 300);
    frame.setLocationRelativeTo(null);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
    button.addActionListener(e -> System.exit(0));
}

From source file:Main.java

public static void main(String[] args) {
    JFrame window = new JFrame();
    window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    window.setResizable(false);
    JTextArea textArea = new JTextArea(25, 30);

    JScrollPane textScroll = new JScrollPane(textArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);

    window.add(textScroll);//from  w  w w.  j  a  v  a 2  s .com
    window.pack();
    window.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JFrame dialog = new JFrame();
    dialog.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    dialog.setResizable(true);

    JPanel guiHolder = new JPanel();
    guiHolder.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 0;//from w  w w .j  a  v  a2 s  .  co  m
    gbc.gridy = 0;
    gbc.anchor = GridBagConstraints.PAGE_START;
    gbc.weightx = 1.0;
    gbc.weighty = 1.0;
    guiHolder.add(new JLabel("my test"), gbc);

    dialog.add(guiHolder);
    dialog.setSize(new Dimension(320, 240));
    dialog.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setResizable(false);
    JTabbedPane tabs = new JTabbedPane();
    tabs.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
    for (int i = 0; i < 5; i++) {
        tabs.addTab("Tab" + i, new TabPanel());
    }/*from   w  w w . java 2s.com*/

    frame.add(tabs);
    frame.pack();
    frame.setVisible(true);

}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setResizable(false);
    frame.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));

    JPanel navigation_panel_wrap = new JPanel() {
        @Override//from   www .j  a va2s  .co  m
        public Dimension getPreferredSize() {
            return new Dimension(250, 700);
        }
    };
    JPanel content_panel_wrap = new JPanel() {
        @Override
        public Dimension getPreferredSize() {
            return new Dimension(750, 700);
        }
    };

    content_panel_wrap.setBackground(Color.green);
    navigation_panel_wrap.setBackground(Color.red);

    frame.add(navigation_panel_wrap);
    frame.add(content_panel_wrap);
    frame.pack();
    frame.setVisible(true);

}

From source file:Main.java

public static void main(String[] args) {
    JPanel panel = new JPanel();
    panel.setPreferredSize(new Dimension(800, 600));

    String test[] = { "alpha", "bravo", "charlie", "delta", "echo", "omega", "zeta" };
    JList<String> list = new JList<>(test);
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    list.setLayoutOrientation(JList.VERTICAL);
    list.setVisibleRowCount(5);//w  w  w  .  j  ava  2s  .co  m
    list.setBounds(50, 150, 75, 90);

    JScrollPane jScrollPane1 = new JScrollPane();
    jScrollPane1.setViewportView(list);

    panel.add(jScrollPane1);

    JFrame f = new JFrame();
    f.add(panel);
    f.pack();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setResizable(false);
    f.setFocusable(true);
}

From source file:Main.java

public static void main(String[] args) {
    GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice vc = env.getDefaultScreenDevice();
    JFrame window = new JFrame();
    JPanel comp = new JPanel();
    comp.setBackground(Color.RED);
    window.add(comp);//from  w ww. j a  va 2 s. co  m
    window.setUndecorated(true);
    window.setResizable(false);
    vc.setFullScreenWindow(window);
}

From source file:de.longri.cachebox3.DesktopLauncher.java

public static void main(String[] args) {

    System.setProperty("org.lwjgl.util.NoChecks", "false");

    CommandLine cmd = getCommandLine(args);

    //initialize platform bitmap factory
    AwtGraphics.init();//w w w.  j a  va2  s.c o m

    //initialize platform connector
    PlatformConnector.init(new DesktopPlatformConnector());

    LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
    config.resizable = false;
    config.useHDPI = true;
    config.samples = 10;
    config.width = 223;
    config.height = 397;
    config.title = "Cachebox 3.0";

    config.stencil = 8;
    config.foregroundFPS = 30;
    config.backgroundFPS = 10;

    if (cmd.hasOption("note")) {
        //force note 4 layout
        config.width = 323;
        config.height = 574;
    }

    if (cmd.hasOption("scale")) {
        String value = cmd.getOptionValue("scale");
        float scale = Float.parseFloat(value);
        CB.setGlobalScale(scale);
        config.width *= scale;
        config.height *= scale;
    }

    if (cmd.hasOption("gps")) {
        JFrame f;
        try {
            f = SimulatorMain.createFrame();
            f.pack();
            f.setResizable(false);
            f.setVisible(true);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    initVtm();

    // Don't change this LogLevel
    // Cachebox use the slf4j implematation for LibGdx as Log engine.
    // so set LogLevel on CB.class if you wont (USED_LOG_LEVEL)
    new LwjglApplication(new CacheboxMain(), config).setLogLevel(LwjglApplication.LOG_DEBUG);
}

From source file:Main.java

public static void main(String[] args) {
    JFrame f = new JFrame("Fixed size content");
    f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    Container c = f.getContentPane();
    c.setBackground(Color.YELLOW);

    Dimension d = new Dimension(400, 40);
    c.setPreferredSize(d);//from   ww w .  ja v  a 2  s . c  o  m
    f.pack();
    f.setResizable(false);
    f.setVisible(true);
}

From source file:Main.java

public static void main(String args[]) {
    JFrame frame = new JFrame();

    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();

    int width = (int) screenSize.getWidth();
    int height = (int) screenSize.getHeight();
    Dimension newDim = new Dimension(width, height - 40);

    frame.setSize(newDim);//from   w  w w .  j a va  2 s. co m

    frame.setVisible(true); // FIRST visible = true
    frame.setResizable(false); // THEN resizable = false
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}