Java Code Examples for javax.swing.JFrame#setLocationRelativeTo()
The following examples show how to use
javax.swing.JFrame#setLocationRelativeTo() .
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: MissingDragExitEventTest.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
private static void initAndShowUI() { frame = new JFrame("Test frame"); frame.setSize(SIZE, SIZE); frame.setLocationRelativeTo(null); final JTextArea jta = new JTextArea(); jta.setBackground(Color.RED); frame.add(jta); jta.setText("1234567890"); jta.setFont(jta.getFont().deriveFont(150f)); jta.setDragEnabled(true); jta.selectAll(); jta.setDropTarget(new DropTarget(jta, DnDConstants.ACTION_COPY, new TestdropTargetListener())); jta.addMouseListener(new TestMouseAdapter()); frame.setVisible(true); }
Example 2
Source File: Display.java From New-Beginner-Java-Game-Programming-Src with 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)); canvas.setFocusable(false); frame.add(canvas); frame.pack(); }
Example 3
Source File: TicTacToePlugin.java From Spark with Apache License 2.0 | 6 votes |
/** * Creates The TicTacToe Window and starts the Game * @param gop * @param opponentJID */ private void createTTTWindow(GameOfferPacket gop, EntityFullJid opponentJID) { Localpart name = opponentJID.getLocalpart(); // tictactoe versus ${name} JFrame f = new JFrame(TTTRes.getString("ttt.window.title", TTTRes.getString("ttt.game.name"),name.toString() )); f.setIconImage(buttonimg.getImage()); GamePanel gp = new GamePanel(SparkManager.getConnection(), gop.getGameID(), gop.isStartingPlayer(), opponentJID,f); f.add(gp); f.pack(); f.setLocationRelativeTo(SparkManager.getChatManager().getChatContainer()); f.setVisible(true); }
Example 4
Source File: MissingDragExitEventTest.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
private static void initAndShowUI() { frame = new JFrame("Test frame"); frame.setSize(SIZE, SIZE); frame.setLocationRelativeTo(null); final JTextArea jta = new JTextArea(); jta.setBackground(Color.RED); frame.add(jta); jta.setText("1234567890"); jta.setFont(jta.getFont().deriveFont(150f)); jta.setDragEnabled(true); jta.selectAll(); jta.setDropTarget(new DropTarget(jta, DnDConstants.ACTION_COPY, new TestdropTargetListener())); jta.addMouseListener(new TestMouseAdapter()); frame.setVisible(true); }
Example 5
Source File: ParticleGraphicsEllipseApp.java From arcgis-runtime-demo-java with Apache License 2.0 | 6 votes |
private JFrame createWindow() { JFrame window = new JFrame("Particle Graphics Application"); window.setSize(900, 900); window.setLocationRelativeTo(null); window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); window.getContentPane().setLayout(new BorderLayout()); window.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent windowEvent) { super.windowClosing(windowEvent); if (map != null) { map.dispose(); } } }); return window; }
Example 6
Source File: Game.java From Lunar with MIT License | 6 votes |
/** * Initialize the game. * * @param title The string on the window's title bar. * @param width Width of the window * @param height Height of the window * @param pref The window preferences. * @param tickRate Determines how fast the game loop is. */ public Game(String title, int width, int height, FramePreferences pref, int tickRate) { this.width = width; this.height = height; stack = new ArrayList<>(); maxTPS = tickRate; frame = new JFrame(title); frame.setSize(width, height); frame.setDefaultCloseOperation(pref.getCloseOperation()); frame.setLocationRelativeTo(pref.getRelativeLocation()); frame.setResizable(pref.isResizable()); frame.setFocusable(pref.isFocusable()); frame.addKeyListener(new InputListener()); frame.addMouseListener(new MouseInput()); }
Example 7
Source File: Display.java From New-Beginner-Java-Game-Programming-Src with 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)); canvas.setFocusable(false); frame.add(canvas); frame.pack(); }
Example 8
Source File: MissingDragExitEventTest.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
private static void initAndShowUI() { frame = new JFrame("Test frame"); frame.setSize(SIZE, SIZE); frame.setLocationRelativeTo(null); final JTextArea jta = new JTextArea(); jta.setBackground(Color.RED); frame.add(jta); jta.setText("1234567890"); jta.setFont(jta.getFont().deriveFont(150f)); jta.setDragEnabled(true); jta.selectAll(); jta.setDropTarget(new DropTarget(jta, DnDConstants.ACTION_COPY, new TestdropTargetListener())); jta.addMouseListener(new TestMouseAdapter()); frame.setVisible(true); }
Example 9
Source File: MissingDragExitEventTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
private static void initAndShowUI() { frame = new JFrame("Test frame"); frame.setSize(SIZE, SIZE); frame.setLocationRelativeTo(null); final JTextArea jta = new JTextArea(); jta.setBackground(Color.RED); frame.add(jta); jta.setText("1234567890"); jta.setFont(jta.getFont().deriveFont(150f)); jta.setDragEnabled(true); jta.selectAll(); jta.setDropTarget(new DropTarget(jta, DnDConstants.ACTION_COPY, new TestdropTargetListener())); jta.addMouseListener(new TestMouseAdapter()); frame.setVisible(true); }
Example 10
Source File: TwainAppletExample.java From mmscomputing with GNU Lesser General Public License v3.0 | 6 votes |
public TwainAppletExample(String title, String[] argv){ JFrame.setDefaultLookAndFeelDecorated(true); JFrame frame=new JFrame(title); // frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent ev) { stop();System.exit(0); } }); init(); frame.getContentPane().add(this); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); start(); }
Example 11
Source File: TextViewOOM.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
private static void createAndShowGUI() { frame = new JFrame(); final JScrollPane jScrollPane1 = new JScrollPane(); ta = new JTextArea(); ta.setEditable(false); ta.setColumns(20); ta.setRows(5); jScrollPane1.setViewportView(ta); frame.add(ta); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); }
Example 12
Source File: MisplacedBorder.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Override public void run() { final JMenuBar menubar = new JMenuBar(); menubar.add(new JMenu("")); menubar.add(new JMenu("")); final JFrame frame = new JFrame(); frame.setUndecorated(true); frame.setJMenuBar(menubar); frame.setSize(W / 3, H / 3); frame.setLocationRelativeTo(null); frame.setVisible(true); // draw menu bar using standard order. final BufferedImage bi1 = step1(menubar); // draw menu border on top of the menu bar, nothing should be changed. final BufferedImage bi2 = step2(menubar); frame.dispose(); for (int x = 0; x < W; ++x) { for (int y = 0; y < H; ++y) { if (bi1.getRGB(x, y) != bi2.getRGB(x, y)) { try { ImageIO.write(bi1, "png", new File("image1.png")); ImageIO.write(bi2, "png", new File("image2.png")); } catch (IOException e) { e.printStackTrace(); } throw new RuntimeException("Failed: wrong color"); } } } }
Example 13
Source File: MissingGlyphTest.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private static void glyphTest() { frame = new JFrame("Test"); frame.add(new MyComponent()); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.setSize(200, 200); frame.setLocationRelativeTo(null); frame.setVisible(true); }
Example 14
Source File: ResizedFontLabel.java From mars-sim with GNU General Public License v3.0 | 5 votes |
private static void display() { JFrame f = new JFrame("LayoutTest"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.add(new ResizedFontLabel("Sample")); f.pack(); f.setLocationRelativeTo(null); f.setVisible(true); }
Example 15
Source File: HorizontalMouseWheelOnShiftPressed.java From hottub with GNU General Public License v2.0 | 5 votes |
static void createAndShowGUI() { frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(300, 300); frame.setLocationRelativeTo(null); textArea = new JTextArea("Hello World!"); scrollPane = new JScrollPane(textArea); JPanel panel = new JPanel(new BorderLayout()); panel.add(scrollPane, BorderLayout.CENTER); frame.getContentPane().add(panel); frame.setVisible(true); }
Example 16
Source File: PasteWindow.java From tmc-intellij with MIT License | 5 votes |
public void showResult(URI uri) { logger.info("Showing paste results window. @PasteWindow"); close(); frame = new JFrame(); JPanel panel = new ResultPanel(uri, this).getPanel(); frame.add(panel); frame.setTitle("TMC Pastebin result"); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); frame.setResizable(true); }
Example 17
Source File: TextViewOOM.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private static void createAndShowGUI() { frame = new JFrame(); final JScrollPane jScrollPane1 = new JScrollPane(); ta = new JTextArea(); ta.setEditable(false); ta.setColumns(20); ta.setRows(5); jScrollPane1.setViewportView(ta); frame.add(ta); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); }
Example 18
Source File: CoBrowser.java From Spark with Apache License 2.0 | 5 votes |
public void showDialog() { JFrame frame = new JFrame(FpRes.getString("title.cobrowsing.for", sessionID)); frame.setIconImage(SparkManager.getMainWindow().getIconImage()); frame.getContentPane().setLayout(new BorderLayout()); frame.getContentPane().add(this); frame.pack(); frame.setSize(600, 400); frame.setLocationRelativeTo(SparkManager.getChatManager().getChatContainer().getChatFrame()); frame.setVisible(true); }
Example 19
Source File: MultiGradientTest.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) { final JFrame frame = new JFrame("Multistop Gradient Demo"); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { frame.dispose(); } }); frame.add(new MultiGradientTest()); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); }
Example 20
Source File: BBoxDBGui.java From bboxdb with Apache License 2.0 | 4 votes |
/** * Build the BBoxDB dialog, init GUI components * and assemble the dialog */ public void run() { mainframe = new JFrame("BBoxDB - GUI Client"); setupMenu(); mainPanel = buildSplitPane(); updateMainPanel(); tableModel = getTableModel(); final JTable table = new JTable(tableModel); table.getColumnModel().getColumn(0).setMaxWidth(40); table.getColumnModel().getColumn(2).setMinWidth(100); table.getColumnModel().getColumn(2).setMaxWidth(100); table.setDefaultRenderer(Object.class, new InstanceTableRenderer()); final JScrollPane tableScrollPane = new JScrollPane(table); final Dimension dimension = table.getPreferredSize(); if(dimension != null) { tableScrollPane.setPreferredSize( new Dimension(dimension.width, table.getRowHeight() * 7)); } mainframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); mainframe.setLayout(new BorderLayout()); mainframe.add(mainPanel, BorderLayout.CENTER); final JPanel southPanel = new JPanel(); southPanel.setLayout(new BorderLayout()); southPanel.add(tableScrollPane, BorderLayout.CENTER); final JPanel statusPanel = new JPanel(); statusPanel.setBorder(new BevelBorder(BevelBorder.LOWERED)); statusPanel.setPreferredSize(new Dimension(southPanel.getWidth(), 20)); statusPanel.setLayout(new BoxLayout(statusPanel, BoxLayout.X_AXIS)); statusLabel = new JLabel(""); statusLabel.setHorizontalAlignment(SwingConstants.LEFT); statusPanel.add(statusLabel); southPanel.add(statusPanel, BorderLayout.SOUTH); mainframe.add(southPanel, BorderLayout.SOUTH); mainframe.pack(); mainframe.setLocationRelativeTo(null); mainframe.setVisible(true); }