List of usage examples for javax.swing JFrame setLocationRelativeTo
public void setLocationRelativeTo(Component c)
From source file:Main.java
public static void main(String[] argv) { JTextComponent textcomp = new JTextArea(); final UndoManager undo = new UndoManager(); Document doc = textcomp.getDocument(); doc.addUndoableEditListener(new UndoableEditListener() { public void undoableEditHappened(UndoableEditEvent evt) { undo.addEdit(evt.getEdit()); }//from w w w . j av a 2 s .c o m }); textcomp.getActionMap().put("Undo", new AbstractAction("Undo") { public void actionPerformed(ActionEvent evt) { try { if (undo.canUndo()) { undo.undo(); } } catch (CannotUndoException e) { } } }); textcomp.getInputMap().put(KeyStroke.getKeyStroke("control Z"), "Undo"); textcomp.getActionMap().put("Redo", new AbstractAction("Redo") { public void actionPerformed(ActionEvent evt) { try { if (undo.canRedo()) { undo.redo(); } } catch (CannotRedoException e) { } } }); textcomp.getInputMap().put(KeyStroke.getKeyStroke("control Y"), "Redo"); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new JScrollPane(textcomp)); frame.setSize(380, 320); frame.setLocationRelativeTo(null); frame.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { UIManager.put("ProgressBar.repaintInterval", 100); UIManager.put("ProgressBar.border", BorderFactory.createLineBorder(Color.blue, 2)); JFrame f = new JFrame(); f.setLayout(new GridLayout(0, 1, 5, 5)); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.add(createBar());/*w w w .ja va 2s. c o m*/ f.add(createBar()); f.add(createBar()); f.pack(); f.setLocationRelativeTo(null); f.setVisible(true); }
From source file:TimerBasedAnimation.java
public static void main(String[] args) { JFrame frame = new JFrame("TimerBasedAnimation"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new TimerBasedAnimation()); frame.setSize(350, 250);//from w w w .j ava2s . co m frame.setLocationRelativeTo(null); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { @Override//from ww w . j a va 2 s .com public void run() { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); Panel panel = new Panel(); frame.setContentPane(panel); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); } }); }
From source file:de.codesourcery.planning.DateAxisTestTool.java
public static void main(String[] args) { axis.setStartDate(DateUtils.round(new Date(), Calendar.DAY_OF_MONTH)); axis.setRange(Duration.weeks(1)); axis.setTickDuration(Duration.oneDay()); JFrame frame = new JFrame(); frame.getContentPane().add(new DateCanvas()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLocationRelativeTo(null); frame.pack();/*from ww w . j a v a 2s . com*/ frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { DefaultListModel<String> model = new DefaultListModel<>(); JList<String> sList = new JList<>(model); for (int i = 0; i < 100; i++) { model.addElement("String " + i); }//from www. ja va 2s. c o m sList.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); sList.setVisibleRowCount(-1); sList.setLayoutOrientation(JList.HORIZONTAL_WRAP); JFrame frame = new JFrame("Foo001"); frame.getContentPane().add(new JScrollPane(sList)); frame.getContentPane().setPreferredSize(new Dimension(400, 300)); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); }
From source file:com.moss.appprocs.swing.ProgressDialog.java
public static void main(String[] args) { final JButton button = new JButton("Go"); final JFrame f = new JFrame("Test Frame"); f.getContentPane().add(button);/*from w ww . ja v a 2 s.c om*/ f.setLocationRelativeTo(null); f.setSize(800, 600); f.setVisible(true); final ProgressDialog reporter = new ProgressDialog(button); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { reporter.report(new TestProcess(), true); } }); }
From source file:Main.java
public static void main(String[] args) throws Exception { String[] items = new String[] { "", "Apple", "Banana", "Carrot" }; Color bgColor = UIManager.getColor("TextField.background"); UIManager.put("ComboBox.selectionBackground", new ColorUIResource(bgColor)); JComboBox<String> combo1 = new JComboBox<>(items); combo1.setPrototypeDisplayValue("XXXXXXXXXXXXXXX"); combo1.setEditable(true);/*from w ww . ja v a 2 s . co m*/ combo1.setSelectedIndex(-1); JComboBox<String> combo2 = new JComboBox<>(items); combo2.setPrototypeDisplayValue("XXXXXXXXXXXXXXX"); combo2.setEditable(false); combo2.setSelectedIndex(-1); combo2.setBackground(bgColor); JFrame frame = new JFrame(); Container c = frame.getContentPane(); c.setLayout(new FlowLayout()); c.add(combo1); c.add(combo2); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(200, 100); frame.setLocationRelativeTo(null); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); tabbedPane.add("Cab #1", new Main()); tabbedPane.add("Cab #2", new Main()); tabbedPane.add("Cab #3", new Main()); f.add(tabbedPane);// w w w. j a v a2 s. c o m f.pack(); f.setLocationRelativeTo(null); f.setVisible(true); }
From source file:org.excalibur.fm.configuration.Main.java
@SuppressWarnings("resource") public static void main(String[] args) throws InterruptedException { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "classpath*:META-INF/applicationContext.xml"); final ProviderService providerService = context.getBean(ProviderService.class); configureLookAndFeel();/*from w ww .j a v a 2s. c om*/ final JFrame frame = new JFrame(); frame.getContentPane().add(new InstanceSelectionPanel(providerService)); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // frame.pack(); frame.setSize(1118, 470); frame.setLocationRelativeTo(null); java.awt.EventQueue.invokeLater(new Runnable() { public void run() { frame.setVisible(true); } }); // Thread.currentThread().join(); // context.close(); }