javax.swing.JFrame Java Examples
The following examples show how to use
javax.swing.JFrame.
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 File: DisplayChangesException.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
private void test() throws Exception { SunToolkit.createNewAppContext(); EventQueue.invokeAndWait(() -> { frame = new JFrame(); final JButton b = new JButton(); b.addPropertyChangeListener(evt -> { if (!SunToolkit.isDispatchThreadForAppContext(b)) { System.err.println("Wrong thread:" + currentThread()); fail = true; } }); frame.add(b); frame.setSize(100, 100); frame.setLocationRelativeTo(null); frame.pack(); }); go.await(); EventQueue.invokeAndWait(() -> { frame.dispose(); }); }
Example #2
Source File: SetRootPaneSkin.java From radiance with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Opens a sample frame under the specified skin. * * @param skin * Skin. */ private void openSampleFrame(SubstanceSkin skin) { JFrame sampleFrame = new JFrame(skin.getDisplayName()); sampleFrame.setLayout(new FlowLayout()); JButton defaultButton = new JButton("active"); JButton button = new JButton("default"); JButton disabledButton = new JButton("disabled"); disabledButton.setEnabled(false); sampleFrame.getRootPane().setDefaultButton(defaultButton); sampleFrame.add(defaultButton); sampleFrame.add(button); sampleFrame.add(disabledButton); sampleFrame.setVisible(true); sampleFrame.pack(); sampleFrame.setLocationRelativeTo(null); sampleFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); sampleFrame.setIconImage(new BufferedImage(1, 1, BufferedImage.TYPE_4BYTE_ABGR)); SubstanceCortex.RootPaneScope.setSkin(sampleFrame.getRootPane(), skin); SwingUtilities.updateComponentTreeUI(sampleFrame); sampleFrame.repaint(); }
Example #3
Source File: UpdateUIRecursionTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public UpdateUIRecursionTest() { super("UpdateUIRecursionTest"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setSize(400, 400); String[] listData = { "First", "Second", "Third", "Fourth", "Fifth", "Sixth" }; tree = new JTree(listData); renderer = new DefaultTreeCellRenderer(); getContentPane().add(new JScrollPane(tree), BorderLayout.CENTER); tree.setCellRenderer(this); setVisible(true); }
Example #4
Source File: LineNumber.java From bigtable-sql with Apache License 2.0 | 6 votes |
public static void main(String[] args) { JFrame frame = new JFrame("LineNumberDemo"); frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); JPanel panel = new JPanel(); frame.setContentPane( panel ); panel.setBorder(BorderFactory.createEmptyBorder(20,20,20,20)); panel.setLayout(new BorderLayout()); JTextPane textPane = new JTextPane(); textPane.setFont( new Font("monospaced", Font.PLAIN, 12) ); textPane.setText("abc"); JScrollPane scrollPane = new JScrollPane(textPane); panel.add(scrollPane); scrollPane.setPreferredSize(new Dimension(300, 250)); LineNumber lineNumber = new LineNumber( textPane ); scrollPane.setRowHeaderView( lineNumber ); frame.pack(); frame.setVisible(true); }
Example #5
Source File: AddAndMoveGraphicsApp.java From arcgis-runtime-demo-java with Apache License 2.0 | 6 votes |
/** * Starting point of this application. * * @param args * arguments to this application. */ public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { try { // instance of this application AddAndMoveGraphicsApp addGraphicsApp = new AddAndMoveGraphicsApp(); // create the UI, including the map, for the application. JFrame appWindow = addGraphicsApp.createWindow(); appWindow.add(addGraphicsApp.createUI()); appWindow.setVisible(true); } catch (Exception ex) { ex.printStackTrace(); } } }); }
Example #6
Source File: JButtonPaintNPE.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public static void main(final String[] args) throws InvocationTargetException, InterruptedException { SwingUtilities.invokeAndWait(() -> { frame = new JFrame(); frame.add(new JButton() { @Override protected void paintComponent(final Graphics g) { Graphics gg = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_ARGB).createGraphics(); super.paintComponent(gg); gg.dispose(); } }); frame.setSize(300, 300); frame.setLocationRelativeTo(null); frame.setVisible(true); }); sleep(); SwingUtilities.invokeAndWait(() -> { if (frame != null) { frame.dispose(); } }); }
Example #7
Source File: ProgressPanel.java From FoxTelem with GNU General Public License v3.0 | 6 votes |
public ProgressPanel(JFrame owner, String message, boolean modal) { super(owner, modal); title = message; setTitle(message); setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); // setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); int x = 100; int y = 100; if (MainWindow.frame != null) { x = MainWindow.frame.getX() + MainWindow.frame.getWidth()/2 - (message.length()*9)/2; y = MainWindow.frame.getY() + MainWindow.frame.getHeight()/2; } else { Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize(); x = (int) ((dimension.getWidth() - this.getWidth()) / 2); y = (int) ((dimension.getHeight() - this.getHeight()) / 2); } setBounds(100, 100, message.length()*11, 10); this.setLocation(x, y); }
Example #8
Source File: DemoTheatreApp.java From arcgis-runtime-demo-java with Apache License 2.0 | 6 votes |
/** * Starting point of this application. * * @param args arguments to this application. */ public static void main(String[] args) { // Tip: Use HTTP request intercepter such as Fiddler to track requests // ProxySetup.setupProxy("localhost", 8888); // create the UI, including the map, for the application SwingUtilities.invokeLater(new Runnable() { @Override public void run() { try { DemoTheatreApp app = new DemoTheatreApp(); JFrame appWindow = app.createWindow(); appWindow.add(app.createUI()); appWindow.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); }
Example #9
Source File: RaceGUI.java From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Creates a new instance of RaceGUI */ public RaceGUI(String appName) { UIManager.put("swing.boldMetal", Boolean.FALSE); JFrame f = new JFrame(appName); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setLayout(new BorderLayout()); // Add Track view track = new TrackView(); f.add(track, BorderLayout.CENTER); // Add control panel controlPanel = new RaceControlPanel(); f.add(controlPanel, BorderLayout.SOUTH); f.pack(); f.setVisible(true); }
Example #10
Source File: RobotUtils.java From karate with 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 #11
Source File: RSClient.java From osrsclient with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws IrcException, IOException { Toolkit.getDefaultToolkit().setDynamicLayout(true); System.setProperty("sun.awt.noerasebackground", "true"); JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); try { UIManager.setLookAndFeel("de.muntjak.tinylookandfeel.TinyLookAndFeel"); } catch (Exception e) { e.printStackTrace(); } initUI(); }
Example #12
Source File: EmployeeListFrame.java From JavaMainRepo with Apache License 2.0 | 6 votes |
/** * * @param emp * An array of employees. * @throws IOException * @throws SAXException * @throws ParserConfigurationException */ private static JFrame printEmployees(final ArrayList<Employee> emp) throws ParserConfigurationException, SAXException, IOException { TableEModel m = new TableEModel(emp); JTable t = new JTable(m); JPanel panel = new JPanel(); JFrame fram = new JFrame("Employees"); panel.setLayout(new BorderLayout()); JScrollPane tableC = new JScrollPane(t); tableC.getViewport().add(t); panel.add(tableC); fram.getContentPane().add(panel); fram.pack(); fram.setVisible(true); return fram; }
Example #13
Source File: SnapshotTool.java From osp with GNU General Public License v3.0 | 6 votes |
/** * Constructor ComponentImage * @param comp */ public ComponentImage(Component comp) { c = comp; if(comp instanceof JFrame) { comp = ((JFrame) comp).getContentPane(); } else if(comp instanceof JDialog) { comp = ((JDialog) comp).getContentPane(); } image = new BufferedImage(comp.getWidth(), comp.getHeight(), BufferedImage.TYPE_3BYTE_BGR); if(comp instanceof Renderable) { image = ((Renderable) comp).render(image); } else { java.awt.Graphics g = image.getGraphics(); comp.paint(g); g.dispose(); } }
Example #14
Source File: JPolicyMappings.java From keystore-explorer with GNU General Public License v3.0 | 6 votes |
private void addPressed() { Container container = getTopLevelAncestor(); DPolicyMappingChooser dPolicyMappingChooser = null; if (container instanceof JDialog) { dPolicyMappingChooser = new DPolicyMappingChooser((JDialog) container, title, null); } else { dPolicyMappingChooser = new DPolicyMappingChooser((JFrame) container, title, null); } dPolicyMappingChooser.setLocationRelativeTo(container); dPolicyMappingChooser.setVisible(true); PolicyMapping newPolicyMapping = dPolicyMappingChooser.getPolicyMapping(); if (newPolicyMapping == null) { return; } policyMappings = PolicyMappingsUtil.add(newPolicyMapping, policyMappings); populate(); selectPolicyMappingInTable(newPolicyMapping); }
Example #15
Source File: Metalworks.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) { UIManager.put("swing.boldMetal", Boolean.FALSE); JDialog.setDefaultLookAndFeelDecorated(true); JFrame.setDefaultLookAndFeelDecorated(true); Toolkit.getDefaultToolkit().setDynamicLayout(true); System.setProperty("sun.awt.noerasebackground", "true"); try { UIManager.setLookAndFeel(new MetalLookAndFeel()); } catch (UnsupportedLookAndFeelException e) { System.out.println( "Metal Look & Feel not supported on this platform. \n" + "Program Terminated"); System.exit(0); } JFrame frame = new MetalworksFrame(); frame.setVisible(true); }
Example #16
Source File: Regression_116616_swing.java From birt with Eclipse Public License 1.0 | 5 votes |
public void componentShown( ComponentEvent cev ) { JFrame jf = (JFrame) cev.getComponent( ); Rectangle r = jf.getBounds( ); setLocation( r.x, r.y + r.height ); setSize( r.width, 50 ); setVisible( true ); }
Example #17
Source File: CCombinedMemoryPanel.java From binnavi with Apache License 2.0 | 5 votes |
/** * Creates a new combined memory panel object. * * @param parent Parent window of the panel. * @param debugPerspectiveModel Describes the active debugger GUI options. */ public CCombinedMemoryPanel( final JFrame parent, final CDebugPerspectiveModel debugPerspectiveModel) { super(new BorderLayout()); Preconditions.checkNotNull(parent, "IE01361: Parent argument can not be null"); m_debugPerspectiveModel = Preconditions.checkNotNull( debugPerspectiveModel, "IE01362: Debug perspective model argument can not be null"); m_debugPerspectiveModel.addListener(m_internalListener); final JideSplitPane pane = new JideSplitPane(JideSplitPane.HORIZONTAL_SPLIT) { private static final long serialVersionUID = -1326165812499630343L; // ESCA-JAVA0025: Workaround for Case 1168 @Override public void updateUI() { // Workaround for Case 1168: The mere presence of a JIDE component // screws up the look and feel. } }; pane.setDividerSize(3); // ATTENTION: Part of the Case 1168 workaround pane.setProportionalLayout(true); final CMemoryRefreshButtonPanel refreshPanel = new CMemoryRefreshButtonPanel( parent, debugPerspectiveModel, new InternalRangeProvider(), new InternalStackRangeProvider()); m_memorySelectionPanel = new CMemorySelectionPanel(parent, debugPerspectiveModel, refreshPanel); // Create the GUI pane.addPane(m_memorySelectionPanel); m_stackPanel = new CStackView(debugPerspectiveModel); pane.addPane(m_stackPanel); add(pane); }
Example #18
Source File: Regression_119810_swing.java From birt with Eclipse Public License 1.0 | 5 votes |
public void componentMoved( ComponentEvent cev ) { JFrame jf = (JFrame) cev.getComponent( ); Rectangle r = jf.getBounds( ); setLocation( r.x, r.y + r.height ); setSize( r.width, 50 ); }
Example #19
Source File: Main.java From freeinternals with Apache License 2.0 | 5 votes |
private Main(final String[] args) { this.setTitle(TITLE); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); UITool.centerJFrame(this); this.createMenu(); this.setVisible(true); if (args.length > 0) { final String fileName = args[0]; final File file = new File(fileName); if (file.exists()) { try { if (fileName.endsWith(ClassFile.EXTENTION_CLASS)) { this.open_ClassFile(file); } else if (fileName.endsWith(ClassFile.EXTENTION_JAR) || fileName.endsWith(ClassFile.EXTENTION_JMOD)) { this.open_JarFile(file); } else { LOGGER.log(Level.WARNING, "The provided file does not supported: filename={0}", fileName); } } catch (Exception e) { LOGGER.log(Level.SEVERE, "Failed to open the file. filename=" + fileName, e); } this.exit4Masstestmode(); } else { LOGGER.log(Level.WARNING, "The provided file does not exist: filename={0}", fileName); } } }
Example #20
Source File: SliderTester.java From swing_library with MIT License | 5 votes |
public static void main (String[] args) { SliderTester t = new SliderTester(); t.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); t.setSize(500, 600); t.add(SliderTester.getPanel()); t.setVisible(true); }
Example #21
Source File: StartScreen.java From WorldGrower with GNU General Public License v3.0 | 5 votes |
public StartScreen(ImageInfoReader imageInfoReaderValue, SoundIdReader soundIdReaderValue, MusicPlayer musicPlayerValue, KeyBindings keyBindings, JFrame parentFrame) { initialize(parentFrame); imageInfoReader = imageInfoReaderValue; soundIdReader = soundIdReaderValue; musicPlayer = musicPlayerValue; this.keyBindings = keyBindings; this.parentFrame = parentFrame; }
Example #22
Source File: UpdateControllerImpl.java From bigtable-sql with Apache License 2.0 | 5 votes |
/** * @see net.sourceforge.squirrel_sql.client.update.UpdateController#showUpdateDialog() */ public void showUpdateDialog() { final JFrame parent = _app.getMainFrame(); final IUpdateSettings settings = getUpdateSettings(); final boolean isRemoteUpdateSite = settings.isRemoteUpdateSite(); GUIUtils.processOnSwingEventThread(new Runnable() { @Override public void run() { UpdateManagerDialog dialog = new UpdateManagerDialog(parent, isRemoteUpdateSite); if (isRemoteUpdateSite) { dialog.setUpdateServerName(settings.getUpdateServer()); dialog.setUpdateServerPort(settings.getUpdateServerPort()); dialog.setUpdateServerPath(settings.getUpdateServerPath()); dialog.setUpdateServerChannel(settings.getUpdateServerChannel()); } else { dialog.setLocalUpdatePath(settings.getFileSystemUpdatePath()); } dialog.addCheckUpdateListener(UpdateControllerImpl.this); dialog.setVisible(true); } }); }
Example #23
Source File: RegisterTabCloseChangeListener_GeneralMultiple.java From radiance with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * The main method for <code>this</code> sample. The arguments are ignored. * * @param args * Ignored. */ public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(() -> { SubstanceCortex.GlobalScope.setSkin(new BusinessBlackSteelSkin()); new RegisterTabCloseChangeListener_GeneralMultiple().setVisible(true); }); }
Example #24
Source File: bug8069348.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static void createAndShowGUI() { frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JDesktopPane desktopPane = new JDesktopPane(); desktopPane.setBackground(DESKTOPPANE_COLOR); internalFrame = new JInternalFrame("Test") { @Override public void paint(Graphics g) { super.paint(g); g.setColor(FRAME_COLOR); g.fillRect(0, 0, getWidth(), getHeight()); } }; internalFrame.setSize(WIN_WIDTH / 3, WIN_HEIGHT / 3); internalFrame.setVisible(true); desktopPane.add(internalFrame); JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); panel.add(desktopPane, BorderLayout.CENTER); frame.add(panel); frame.setSize(WIN_WIDTH, WIN_HEIGHT); frame.setVisible(true); frame.requestFocus(); }
Example #25
Source File: ImageViewer.java From moa with GNU General Public License v3.0 | 5 votes |
/** * Class constructor. * * @param imgPanel * @param resultsPath * @throws HeadlessException */ public ImageViewer(ImageTreePanel imgPanel, String resultsPath) throws HeadlessException { super("Preview"); this.imgPanel = imgPanel; this.resultsPath = resultsPath; setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); // Create and set up the content pane. JPanel panel = new JPanel(); JPanel main = new JPanel(); JLabel label = new JLabel("Output format"); String op[] = {"PNG", "JPG", "SVG"}; imgType = new JComboBox(op); imgType.setSelectedIndex(0); btn = new JButton("Save all images as..."); btn.addActionListener(this::btnMenuActionPerformed); panel.add(label); panel.add(imgType); panel.add(btn); main.setLayout(new BorderLayout()); main.add(this.imgPanel, BorderLayout.CENTER); main.add(panel, BorderLayout.SOUTH); setContentPane(main); // Display the window. pack(); setSize(700, 500); setVisible(true); }
Example #26
Source File: CBreakpointRemoveFunctions.java From binnavi with Apache License 2.0 | 5 votes |
/** * Removes all breakpoints that are part of a given view. * * @param parent Parent window used for dialogs. * @param debuggerProvider Provides the debuggers where breakpoints can be set. * @param view The view to consider when removing breakpoints. */ public static void removeAllView(final JFrame parent, final BackEndDebuggerProvider debuggerProvider, final INaviView view) { Preconditions.checkNotNull(parent, "IE01933: Parent argument can't be null"); Preconditions.checkNotNull(debuggerProvider, "IE02251: Debugger provider argument can not be null"); Preconditions.checkNotNull(view, "IE01956: View argument can't be null"); if (JOptionPane.YES_OPTION == CMessageBox.showYesNoCancelQuestion(parent, "Do you really want to remove all breakpoints from this view?")) { for (final IDebugger debugger : debuggerProvider) { removeAllView(debugger.getBreakpointManager(), view); } } }
Example #27
Source File: bug8033069NoScrollBar.java From hottub with GNU General Public License v2.0 | 5 votes |
private void setupUI() { frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); cb1 = new JComboBox<>(items); cb2 = new JComboBox<>(items); JPanel panel = new JPanel(new GridLayout(1, 2)); panel.add(cb1); panel.add(cb2); frame.add(panel); frame.pack(); frame.setVisible(true); }
Example #28
Source File: CheckBoxListDemo.java From marathonv5 with Apache License 2.0 | 5 votes |
static public void main(String[] s) { SwingUtilities.invokeLater(new Runnable() { public void run() { LookAndFeelFactory.installDefaultLookAndFeelAndExtension(); JFrame frame = new JFrame("CheckBoxList Demo"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(new CheckBoxListDemo()); frame.pack(); frame.setVisible(true); } }); }
Example #29
Source File: Regression_117986_swing.java From birt with 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_117986_swing siv = new Regression_117986_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 #30
Source File: ProjectUtilities.java From netbeans with Apache License 2.0 | 5 votes |
@Override public void run() { try { JFrame f = (JFrame)WindowManager.getDefault ().getMainWindow (); Component c = f.getGlassPane (); c.setVisible ( show ); c.setCursor (show ? Cursor.getPredefinedCursor (Cursor.WAIT_CURSOR) : null); } catch (NullPointerException npe) { Exceptions.printStackTrace(npe); } }