Java Code Examples for javax.swing.JFrame#setSize()
The following examples show how to use
javax.swing.JFrame#setSize() .
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
Source Project: rapidminer-studio File: PopulationPlotter.java License: GNU Affero General Public License v3.0 | 6 votes |
@Override public void startVisualization(Object id) { double[] weights = lastPopulation.get(id); SimpleDataTable dataTable = new SimpleDataTable("Attribute Weights", new String[] { "Attribute", "Weight" }); int a = 0; for (Attribute attribute : exampleSet.getAttributes()) { dataTable .add(new SimpleDataTableRow(new double[] { dataTable.mapString(0, attribute.getName()), weights[a++] })); } Component visualizationComponent = new DataTableViewer(dataTable); 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(ApplicationFrame.getApplicationFrame()); frame.setVisible(true); }
Example 2
Source Project: New-Beginner-Java-Game-Programming-Src File: Display.java License: Creative Commons Zero v1.0 Universal | 6 votes |
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
Source Project: slick2d-maven File: GradientEditor.java License: BSD 3-Clause "New" or "Revised" License | 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 4
Source Project: settlers-remake File: LwjglTest.java License: MIT License | 6 votes |
/** * creates a test window. */ protected LwjglTest() { JFrame window = new JFrame("Test"); area = generateArea(); AreaContainer content = new AreaContainer(area) { @Override public void draw() { area.drawArea(context); } }; window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); window.add(content); window.setSize(500, 500); window.setVisible(true); }
Example 5
Source Project: New-Beginner-Java-Game-Programming-Src File: Display.java License: Creative Commons Zero v1.0 Universal | 6 votes |
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 6
Source Project: ghidra File: ConsoleTextPaneTest.java License: Apache License 2.0 | 6 votes |
@Test public void testScrollLock_Unlocked() throws Exception { DummyPluginTool tool = swing(() -> new DummyPluginTool()); ConsoleTextPane text = new ConsoleTextPane(tool); text.setMaximumCharacterLimit(100); text.setScrollLock(false); JFrame frame = new JFrame(); frame.setSize(600, 400); JScrollPane scroller = new JScrollPane(text); frame.getContentPane().add(scroller); frame.setVisible(true); printEnoughLinesToOverflowTheMaxCharCount(text); assertCaretAtBottom(text); }
Example 7
Source Project: jdk8u-jdk File: bug7189299.java License: GNU General Public License v2.0 | 6 votes |
private static void setup() { /** * Note the input type is not restricted to "submit". Types "image", * "checkbox", "radio" have the same problem. */ html = new JEditorPane("text/html", "<html><body><form action=\"http://localhost.cgi\">" + "<input type=submit name=submit value=\"submit\"/>" + "</form></body></html>"); frame = new JFrame(); frame.setLayout(new BorderLayout()); frame.add(html, BorderLayout.CENTER); frame.setSize(200, 100); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); }
Example 8
Source Project: karate File: RobotUtils.java License: MIT License | 6 votes |
public static void highlight(int x, int y, int width, int height, int time) { JFrame f = new JFrame(); f.setUndecorated(true); f.setBackground(new Color(0, 0, 0, 0)); f.setAlwaysOnTop(true); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setType(JFrame.Type.UTILITY); f.setFocusableWindowState(false); f.setAutoRequestFocus(false); f.setLocation(x, y); f.setSize(width, height); f.getRootPane().setBorder(BorderFactory.createLineBorder(Color.RED, 3)); f.setVisible(true); delay(time); f.dispose(); }
Example 9
Source Project: netbeans File: EditableDisplayerTest.java License: Apache License 2.0 | 5 votes |
/** Implementation of assertPixel sans invokeAndWait */ private synchronized void doAssertPixel(final String msg, final Component c, final Color toMatch, final int x, final int y) throws Exception { final BufferedImage bi = new BufferedImage(700, 700, BufferedImage.TYPE_INT_RGB); sleep(); ((JComponent) c).paintAll(bi.getGraphics()); sleep(); int[] cArr = new int[3]; bi.getData().getPixel(x, y, cArr); checkColor = new Color(cArr[0], cArr[1], cArr[2]); //uncomment the code below for diagnosing painting problems //and seeing which pixel you'return really checking JFrame jf = new JFrame("Assert pixel test " + count + " (look for the yellow line)") { public void paint(Graphics g) { new ImageIcon(bi).paintIcon(this, g, 25, 25); g.setColor(Color.YELLOW); g.drawLine(x+20, y+25, x+25, y+25); } }; jf.setLocation(400,400); jf.setSize(500,500); jf.show(); count++; assertEquals("Pixel test " + (count-1) + " " + msg + " - Color at " + x + "," + y + " does not match", toMatch, checkColor); }
Example 10
Source Project: ghidra File: StatusBarTest.java License: Apache License 2.0 | 5 votes |
@Before public void setUp() throws Exception { testFrame = new JFrame("StatusBar Test"); testFrame.setGlassPane(new GGlassPane()); testFrame.setSize(400, 100); statusBar = new StatusBar(); testFrame.getContentPane().add(statusBar); testFrame.setVisible(true); }
Example 11
Source Project: aion-germany File: Main.java License: GNU General Public License v3.0 | 5 votes |
public void showInterfaceSelector(String[] interfaceNames) { _selectInterfaceWindow = new JDialog(_frame); _selectInterfaceWindow.setTitle("Double-Click to Select the Interface"); _selectInterfaceWindow.setLocationRelativeTo(_frame); _interfaceList = new JList<String>(interfaceNames); _interfaceList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); JScrollPane scrollPane = new JScrollPane(_interfaceList); MouseListener mouseListener = new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { int index = _interfaceList.locationToIndex(e.getPoint()); if (Captor.getInstance().getCurrentDeviceId() == index) { _selectInterfaceWindow.dispose(); return; } Captor.getInstance().openDevice(index); PacketSamurai.setConfigProperty("NetworkInterface", Integer.toString(index)); _selectInterfaceWindow.dispose(); } } }; _interfaceList.addMouseListener(mouseListener); _selectInterfaceWindow.add(scrollPane); _selectInterfaceWindow.setSize(400, 350); _selectInterfaceWindow.setVisible(true); JFrame frame = new JFrame("Title"); frame.setSize(200,200); frame.setAlwaysOnTop(true); frame.setVisible(true); }
Example 12
Source Project: filthy-rich-clients File: DataBufferGrabber.java License: BSD 3-Clause "New" or "Revised" License | 5 votes |
private static void createAndShowGUI() { JFrame f = new JFrame("DataBufferGrabber"); f.getContentPane().setLayout(new FlowLayout()); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setSize(100, 100); f.add(new DataBufferGrabber()); f.validate(); f.pack(); f.setVisible(true); }
Example 13
Source Project: birt File: Regression_142687_swing.java License: Eclipse Public License 1.0 | 5 votes |
/** * Contructs the layout with a container for displaying chart and a control * panel for selecting interactivity. * * @param args */ public static void main( String[] args ) { final Regression_142687_swing siv = new Regression_142687_swing( ); JFrame jf = new JFrame( ); jf.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE ); jf.addComponentListener( siv ); Container co = jf.getContentPane( ); co.setLayout( new BorderLayout( ) ); co.add( siv, BorderLayout.CENTER ); Dimension dScreen = Toolkit.getDefaultToolkit( ).getScreenSize( ); Dimension dApp = new Dimension( 600, 400 ); jf.setSize( dApp ); jf.setLocation( ( dScreen.width - dApp.width ) / 2, ( dScreen.height - dApp.height ) / 2 ); jf.setTitle( siv.getClass( ).getName( ) + " [device=" //$NON-NLS-1$ + siv.idr.getClass( ).getName( ) + "]" );//$NON-NLS-1$ ControlPanel cp = siv.new ControlPanel( siv ); co.add( cp, BorderLayout.SOUTH ); siv.idr.setProperty( IDeviceRenderer.UPDATE_NOTIFIER, siv ); jf.addWindowListener( new WindowAdapter( ) { public void windowClosing( WindowEvent e ) { siv.idr.dispose( ); } } ); jf.setVisible( true ); }
Example 14
Source Project: openjdk-jdk9 File: JInternalFrameOverlapping.java License: GNU General Public License v2.0 | 5 votes |
/** * Creating two JInternalFrames in JDesktopPanes. Put lightweight component into one frame and heavyweight into another. */ @Override protected void prepareControls() { JDesktopPane desktopPane = new JDesktopPane(); JFrame frame = new JFrame("Test Window"); frame.setSize(300, 300); frame.setContentPane(desktopPane); frame.setVisible(true); JInternalFrame bottomFrame = new JInternalFrame("bottom frame", false, false, false, false); bottomFrame.setSize(220, 220); desktopPane.add(bottomFrame); bottomFrame.setVisible(true); super.propagateAWTControls(bottomFrame); JInternalFrame topFrame = new JInternalFrame("top frame", false, false, false, false); topFrame.setSize(200, 200); JButton jbutton = new JButton("LW Button") {{ addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { lwClicked = true; } }); }}; topFrame.add(jbutton); desktopPane.add(topFrame); topFrame.setVisible(true); lLoc = jbutton.getLocationOnScreen(); lLoc.translate(jbutton.getWidth()/2, jbutton.getWidth()/2); //click at middle of the button }
Example 15
Source Project: MeteoInfo File: JQuad.java License: GNU Lesser General Public License v3.0 | 5 votes |
public static void main(String[] args) { final GLProfile gp = GLProfile.get(GLProfile.GL2); GLCapabilities cap = new GLCapabilities(gp); final GLCanvas gc = new GLCanvas(cap); JQuad jq = new JQuad(); gc.addGLEventListener(jq); gc.setSize(400, 400); final JFrame frame = new JFrame("JOGL Primitive Quadrilateral"); frame.add(gc); frame.setSize(500, 400); frame.setVisible(true); }
Example 16
Source Project: xnx3 File: SysHotKey.java License: Apache License 2.0 | 5 votes |
public static void main(String[] args) { SysHotKey key = new SysHotKey(); key.initHotkey(); frame = new JFrame(); frame.getContentPane().add(new JLabel("Just a test.")); frame.getRootPane().setWindowDecorationStyle(JRootPane.NONE); Dimension di = Toolkit.getDefaultToolkit().getScreenSize(); frame.setSize(di.width/4 , di.height/4); frame.setVisible(true); frame.setAlwaysOnTop(true); }
Example 17
Source Project: javaGeom File: DrawClippedLinesDemo.java License: GNU Lesser General Public License v3.0 | 5 votes |
public final static void main(String[] args){ JPanel panel = new DrawClippedLinesDemo(); JFrame frame = new JFrame("Draw clipped lines demo"); frame.setContentPane(panel); frame.setSize(650, 550); frame.setVisible(true); }
Example 18
Source Project: cacheonix-core File: JTableAppender.java License: GNU Lesser General Public License v2.1 | 4 votes |
static public void main(String[] args) { JFrame frame = new JFrame("JListView test"); Container container = frame.getContentPane(); JTableAppender appender = new JTableAppender(); JTableAppenderModel model = new JTableAppenderModel(Integer.parseInt(args[0])); appender.setModel(model); //appender.createDefaultColumnsFromModel(); JScrollPane sp = new JScrollPane(appender); sp.setPreferredSize(new Dimension(250, 80)); container.setLayout(new BoxLayout(container, BoxLayout.X_AXIS)); //container.add(view); container.add(sp); JButton button = new JButton("ADD"); container.add(button); button.addActionListener(new JTableAddAction(appender)); frame.setVisible(true); frame.setSize(new Dimension(700,700)); long before = System.currentTimeMillis(); int RUN = 10000; int i = 0; while(i++ < RUN) { LoggingEvent event = new LoggingEvent("x", cat, Priority.ERROR, "Message "+i, null); event.getThreadName(); if(i % 10 == 0) { //event.throwable = new Exception("hello "+i); } appender.add(event); } long after = System.currentTimeMillis(); System.out.println("Time taken :"+ ((after-before)*1000/RUN)); }
Example 19
Source Project: hack-a-drone File: VideoFrame.java License: Apache License 2.0 | 4 votes |
public VideoFrame() { frame = new JFrame("Video Frame"); frame.setSize(FRAME_WIDTH, FRAME_HEIGHT); label = new JLabel(); frame.add(label); }
Example 20
Source Project: openjdk-8-source File: Test8013442.java License: GNU General Public License v2.0 | 4 votes |
@Override public void run() { if (this.infos == null) { this.infos = UIManager.getInstalledLookAndFeels(); Thread.currentThread().setUncaughtExceptionHandler(this); } if (this.infos.length == this.index) { LATCH.countDown(); // release main thread } else if (this.chooser == null) { // change LaF before creation of Swing components LookAndFeelInfo info = this.infos[this.index]; System.out.println(info.getName()); try { UIManager.setLookAndFeel(info.getClassName()); } catch (Exception exception) { throw new Error("could not change look and feel", exception); } // create and show new file chooser JFrame frame = new JFrame(getClass().getSimpleName()); frame.add(this.chooser = new JFileChooser()); frame.setSize(800, 600); frame.setLocationRelativeTo(null); frame.setVisible(true); SwingUtilities.invokeLater(this); } else { int count = this.chooser.getChoosableFileFilters().length; System.out.println("count = " + count + "; " + this.chooser.isAcceptAllFileFilterUsed()); if (count == 0) { if (null != this.chooser.getFileFilter()) { throw new Error("file filter is selected"); } // close window and stop testing file chooser for current LaF SwingUtilities.getWindowAncestor(this.chooser).dispose(); this.chooser = null; this.index++; } else { if (null == this.chooser.getFileFilter()) { throw new Error("file filter is not selected"); } if (count == 2) { // remove default file filter this.chooser.setAcceptAllFileFilterUsed(false); } else if (this.chooser.isAcceptAllFileFilterUsed()) { // remove add file filter this.chooser.addChoosableFileFilter(this); } else { // remove custom file filter this.chooser.removeChoosableFileFilter(this); } } SwingUtilities.invokeLater(this); } }