public void testEmptyHeader() { fFrame = new JFrame("Test Window"); // Create a panel to hold all other components JPanel topPanel = new JPanel(); topPanel.setLayout(new BorderLayout()); // Create a new table instance MyTableModel myModel = new MyTableModel(); fTable = new JTable(myModel); // Add the table to a scrolling pane JScrollPane scrollPane = new JScrollPane(fTable); topPanel.add(scrollPane, BorderLayout.CENTER); fFrame.getContentPane().setLayout(new BorderLayout()); fFrame.getContentPane().add(BorderLayout.CENTER, topPanel); fFrame.setSize(400, 450); fFrame.setLocation(20, 20); fFrame.setVisible(true); try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } JTableHeader header = fTable.getTableHeader(); assertTrue( "JTableHeader greater than 5 pixels tall with empty string first element.", header.getSize().height > 5); fFrame.setVisible(false); fFrame.dispose(); }
public static void main(String[] args) { JFrame frame = new JFrame("Add"); frame.setLocation(500, 400); // frame.setPreferredSize(new Dimension(250, 100)); Container contentPane = frame.getContentPane(); FlowLayout layout = new FlowLayout(); contentPane.setLayout(layout); JPanel panel = new JPanel(); panel.add(new JTextField(6)); panel.add(new JLabel("+")); panel.add(new JTextField(6)); panel.add(new JLabel("=")); panel.add(new JTextField(6)); contentPane.add(panel, BorderLayout.CENTER); JPanel panel2 = new JPanel(); panel2.add(new JButton("확인")); panel2.add(new JButton("취소")); contentPane.add(panel2, BorderLayout.SOUTH); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); }
private Game() { // Top-level frame final JFrame frame = new JFrame("Falling Blocks"); frame.setLocation(200, 50); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Main playing area final TetrisCourt court = new TetrisCourt(); frame.add(court, BorderLayout.CENTER); // Reset button final JPanel panel = new JPanel(); frame.add(panel, BorderLayout.NORTH); final JButton reset = new JButton("Reset"); reset.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { court.reset(); } }); panel.add(reset); // Put the frame on the screen frame.pack(); frame.setVisible(true); // Start the game running court.reset(); }
/** GUIコンポーネントを初期化する。 */ public void initComponent() { frame = new JFrame(ClientContext.getFrameTitle(title)); frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); frame.addWindowListener( new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { stop(); } }); JPanel contentPane = createBrowsePane(); contentPane.setBorder(BorderFactory.createEmptyBorder(12, 12, 11, 11)); contentPane.setOpaque(true); frame.setContentPane(contentPane); frame.pack(); Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); int n = ClientContext.isMac() ? 3 : 2; int x = (screen.width - frame.getPreferredSize().width) / 2; int y = (screen.height - frame.getPreferredSize().height) / n; frame.setLocation(x, y); blockGlass = new BlockGlass(); frame.setGlassPane(blockGlass); frame.setVisible(true); }
public TabSpawnable spawn() { JFrame f = new JFrame(); f.getContentPane().setLayout(new BorderLayout()); f.setTitle(_title); TabSpawnable newPanel = (TabSpawnable) clone(); if (newPanel == null) return null; // failed to clone newPanel.setTitle(_title); if (newPanel instanceof TabToDoTarget) { TabToDoTarget me = (TabToDoTarget) this; TabToDoTarget it = (TabToDoTarget) newPanel; it.setTarget(me.getTarget()); } else if (newPanel instanceof TabModelTarget) { TabModelTarget me = (TabModelTarget) this; TabModelTarget it = (TabModelTarget) newPanel; it.setTarget(me.getTarget()); } f.getContentPane().add(newPanel, BorderLayout.CENTER); Rectangle bounds = getBounds(); bounds.height += OVERLAPP * 2; f.setBounds(bounds); Point loc = new Point(0, 0); SwingUtilities.convertPointToScreen(loc, this); loc.y -= OVERLAPP; f.setLocation(loc); f.setVisible(true); if (_tear && (getParent() instanceof JTabbedPane)) ((JTabbedPane) getParent()).remove(this); return newPanel; }
public void actionPerformed(ActionEvent e) { if (e.getSource() == creer) { this.setVisible(false); JFrame fenetremilieu = new FenetreMilieu(this); fenetremilieu.setVisible(true); fenetremilieu.setLocation(500, 500); } if (e.getSource() == quitter) { this.dispose(); } if (e.getSource() == options) { String message = "Choisissez le port"; numport = Integer.parseInt(JOptionPane.showInputDialog(this, message)); // JFrame fenetreoptions = new FenetreOptions(); // fenetreoptions.setVisible(true); } }
/** * Init JWhiteBoard interface * * @throws Exception */ public void go() throws Exception { if (!noChannel && !useState) channel.connect(groupName); mainFrame = new JFrame(); mainFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); drawPanel = new DrawPanel(useState); drawPanel.setBackground(backgroundColor); subPanel = new JPanel(); mainFrame.getContentPane().add("Center", drawPanel); clearButton = new JButton("Clean"); clearButton.setFont(defaultFont); clearButton.addActionListener(this); leaveButton = new JButton("Exit"); leaveButton.setFont(defaultFont); leaveButton.addActionListener(this); subPanel.add("South", clearButton); subPanel.add("South", leaveButton); mainFrame.getContentPane().add("South", subPanel); mainFrame.setBackground(backgroundColor); clearButton.setForeground(Color.blue); leaveButton.setForeground(Color.blue); mainFrame.pack(); mainFrame.setLocation(15, 25); mainFrame.setBounds(new Rectangle(250, 250)); if (!noChannel && useState) { channel.connect(groupName, null, stateTimeout); } mainFrame.setVisible(true); }
@Override public void display(HashBasedTable<String, String, Double> data) { roomToCodeMapping = generateNewRoomToCodeMapping(); dataSet = createDataSet(data); final JFreeChart chart = createChart(dataSet); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new Dimension(1000, 540)); createNewFrameAndSetLocation(); currentFrame.setTitle(this.getTitle()); currentFrame.setContentPane(chartPanel); currentFrame.setVisible(true); currentFrame.setSize(new Dimension(1020, 560)); currentFrame.addWindowListener(this); if (type == MarkovDataDialog.HeatMapType.COMPARISON) { unscaledDifferenceSlider.setLabelTable(unscaledDifferenceSlider.createStandardLabels(5, 5)); differenceSelectorFrame = new JFrame("Choose Size of difference"); differenceSelectorFrame.setLayout(new BorderLayout()); differenceSelectorFrame.add(unscaledDifferenceSlider, BorderLayout.NORTH); statusLabel.setHorizontalAlignment(SwingConstants.CENTER); statusLabel.setText("Current difference size:" + this.unscaledDifference); differenceSelectorFrame.add(statusLabel, BorderLayout.CENTER); differenceSelectorFrame.add(regenerate, BorderLayout.SOUTH); regenerate.addActionListener(this); differenceSelectorFrame.setLocation(100, 10); differenceSelectorFrame.setSize(300, 200); differenceSelectorFrame.setVisible(true); } }
public static void main(String[] arg) { // init table with Random Random alea = new Random(System.currentTimeMillis()); for (int i = 0; i < table.length; i++) { table[i] = alea.nextInt(10); } System.out.println(Arrays.toString(table)); // pick median values 3 by 3 using Arrays.sort for (int i = 1; (i < table.length - 1); i++) { int[] sort3 = {table[i - 1], table[i], table[i + 1]}; Arrays.sort(sort3); median[i] = sort3[1]; System.out.printf("%d %d %d : %d\n", table[i - 1], table[i], table[i + 1], median[i]); } System.out.println(Arrays.toString(median)); // create Frame + Panel + Graphics JFrame cadre = new JFrame(); JPanel ardoise = new Graph(); cadre.setVisible(true); cadre.setContentPane(ardoise); cadre.pack(); cadre.setLocation(100, 100); }
public start() { MyModel lm = new MyModel(); JList<Integer> jl = new JList<>(lm); JButton b = new JButton("ADD"); b.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { lm.add(zahl++); } }); JFrame jf = new JFrame("List Test"); jf.setLayout(new BorderLayout()); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JScrollPane scrollen = new JScrollPane(jl); jf.add(b, BorderLayout.SOUTH); jf.add(scrollen, BorderLayout.NORTH); jf.setSize(300, 300); jf.setLocation(400, 500); jf.setVisible(true); }
// Initialize all the GUI components and display the frame private static void initGUI() { // Set up the status bar statusField = new JLabel(); statusField.setText(statusMessages[DISCONNECTED]); statusColor = new JTextField(1); statusColor.setBackground(Color.red); statusColor.setEditable(false); statusBar = new JPanel(new BorderLayout()); statusBar.add(statusColor, BorderLayout.WEST); statusBar.add(statusField, BorderLayout.CENTER); // Set up the options pane JPanel optionsPane = initOptionsPane(); // Set up the chat pane JPanel chatPane = new JPanel(new BorderLayout()); chatText = new JTextArea(10, 20); chatText.setLineWrap(true); chatText.setEditable(false); chatText.setForeground(Color.blue); JScrollPane chatTextPane = new JScrollPane( chatText, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); chatLine = new JTextField(); chatLine.setEnabled(false); chatLine.addActionListener( new ActionAdapter() { public void actionPerformed(ActionEvent e) { String s = chatLine.getText(); if (!s.equals("")) { appendToChatBox("OUTGOING: " + s + "\n"); chatLine.selectAll(); // Send the string sendString(s); } } }); chatPane.add(chatLine, BorderLayout.SOUTH); chatPane.add(chatTextPane, BorderLayout.CENTER); chatPane.setPreferredSize(new Dimension(200, 200)); // Set up the main pane JPanel mainPane = new JPanel(new BorderLayout()); mainPane.add(statusBar, BorderLayout.SOUTH); mainPane.add(optionsPane, BorderLayout.WEST); mainPane.add(chatPane, BorderLayout.CENTER); // Set up the main frame mainFrame = new JFrame("Simple TCP Chat"); mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); mainFrame.setContentPane(mainPane); mainFrame.setSize(mainFrame.getPreferredSize()); mainFrame.setLocation(200, 200); mainFrame.pack(); mainFrame.setVisible(true); }
public static void main(String[] args) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(new ArrowPanel()); f.setSize(500, 400); f.setLocation(200, 200); f.setVisible(true); }
public static void main(String[] args) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); f.add(new GraphingData()); f.setSize(515, 310); f.setLocation(0, 420); f.setVisible(true); }
public static void main(String[] args) { JFrame frame = new JFrame("GridBag1"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(225, 150); frame.setLocation(200, 200); frame.setContentPane(new GridBag1()); frame.setVisible(true); }
public static void setFrameCenter(JFrame jf) { // ЙМол Toolkit toolkit = Toolkit.getDefaultToolkit(); Dimension screen = toolkit.getScreenSize(); int x = (screen.width - jf.getWidth()) >> 1; int y = (screen.height - jf.getHeight() >> 1) - 32; jf.setLocation(x, y); }
public static void main(String[] args) throws Exception { JFrame frame = new JFrame("Magic Circle"); frame.setLocation(550, 150); frame.setMinimumSize(new Dimension(600, 400)); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.add(new Frame4()); frame.pack(); frame.setVisible(true); }
// function to center the frame public static void center(JFrame jfrm) { Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); int width = jfrm.getSize().width; int height = jfrm.getSize().height; int x = (dim.width - width) / 2; int y = (dim.height - height) / 2; jfrm.setLocation(x, y); }
public static void main(String[] args) { Plot2D test = new Plot2D(); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.add(test.getContent()); f.add(test.getUIPanel(), "Last"); f.setSize(400, 400); f.setLocation(50, 50); f.setVisible(true); }
public MainFrame() { JFrame frame = new JFrame("Tanks"); frame.setLocation(100, 100); frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); frame.setContentPane(new MainPanel()); // frame.add(new MainPanel()); frame.setMinimumSize(new Dimension(200, 200)); frame.setVisible(true); }
public static void BuildMainWindow() { mainWindow.setTitle("Chat"); mainWindow.setSize(450, 500); mainWindow.setLocation(220, 180); mainWindow.setResizable(false); ConfigureMainWindow(); MainWindow_Action(); sendAction(); disconnectAction(); mainWindow.setVisible(true); mainWindow.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); }
/** * Create a Canvas. * * @param title title to appear in Canvas Frame * @param width the desired width for the canvas * @param height the desired height for the canvas * @param bgColor the desired background color of the canvas */ private Canvas(String title, int width, int height, Color bgColor) { frame = new JFrame(); canvas = new CanvasPane(); frame.setContentPane(canvas); frame.setTitle(title); frame.setLocation(30, 30); canvas.setPreferredSize(new Dimension(width, height)); backgroundColor = bgColor; frame.pack(); objects = new ArrayList<Object>(); shapes = new HashMap<Object, ShapeDescription>(); }
public ShopWindow(Shop shop) { this.shop = shop; this.frame = new JFrame("Shop"); frame.setMinimumSize(new Dimension(700, 500)); frame.setLocation(300, 100); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.getContentPane().add(createShopPanel()); frame.pack(); frame.setVisible(true); }
public static void main(String[] args) { JFrame frame = new JFrame("Cwiczenie5_4"); Container cp = frame.getContentPane(); Cwiczenie5_4 Cwiczenie5_4 = new Cwiczenie5_4(); cp.add(Cwiczenie5_4); frame.addKeyListener(Cwiczenie5_4.bar); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setResizable(false); frame.setLocation(300, 300); frame.pack(); frame.show(); Cwiczenie5_4.startGame(); }
/** The main routine simply opens a window that shows a PaintWithOffScreenCanvas panel. */ public static void main(String[] args) { JFrame window = new JFrame("PaintWithOffScreenCanvas"); AdvancedGUIEX1 content = new AdvancedGUIEX1(); window.setContentPane(content); window.setJMenuBar(content.getMenuBar()); window.pack(); window.setResizable(false); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); window.setLocation( (screenSize.width - window.getWidth()) / 2, (screenSize.height - window.getHeight()) / 2); window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); window.setVisible(true); }
public static void main(String[] args) { JFrame frame = new JFrame("Clock by Volkman"); frame.setContentPane(new Clock().getForm()); frame.pack(); Toolkit tk = Toolkit.getDefaultToolkit(); Dimension dim = tk.getScreenSize(); AWTUtilities.setWindowOpacity(frame, (float) 0.25); frame.setLocation((int) dim.getWidth() - 400, 20); frame.removeNotify(); frame.setUndecorated(true); frame.setVisible(true); frame.setAlwaysOnTop(true); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }
public static void main(String[] args) { JFrame frame = new JFrame("Network Tables"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLocationRelativeTo(null); Display display = new Display(); frame.getContentPane().add(display); frame.setLocation(0, 0); frame.setSize(new Dimension(2000, 700)); frame.revalidate(); frame.repaint(); frame.setVisible(true); }
public static void main(String[] args) { TableModelDemo applet = new TableModelDemo(); JFrame frame = new JFrame(); // EXIT_ON_CLOSE == 3 frame.setDefaultCloseOperation(3); frame.setTitle("TableModelDemo"); frame.getContentPane().add(applet, BorderLayout.CENTER); applet.init(); applet.start(); frame.setSize(500, 220); Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); frame.setLocation( (d.width - frame.getSize().width) / 2, (d.height - frame.getSize().height) / 2); frame.setVisible(true); }
public void start() { menu.setMnemonic('f'); item.setMnemonic('i'); menu.add(item); bar.add(menu); frame.add(text); frame.setJMenuBar(bar); frame.pack(); frame.setLocation(800, 0); frame.setVisible(true); test(); }
protected SwingController commonWindowCreation() { SwingController controller = new SwingController(messageBundle); controller.setWindowManagementCallback(this); // assign properties manager. controller.setPropertiesManager(properties); // add interactive mouse link annotation support controller .getDocumentViewController() .setAnnotationCallback(new MyAnnotationCallback(controller.getDocumentViewController())); controllers.add(controller); // guild a new swing viewer with remembered view settings. int viewType = DocumentViewControllerImpl.ONE_PAGE_VIEW; int pageFit = DocumentViewController.PAGE_FIT_WINDOW_WIDTH; try { viewType = getProperties().getInt("document.viewtype", DocumentViewControllerImpl.ONE_PAGE_VIEW); pageFit = getProperties() .getInt( PropertiesManager.PROPERTY_DEFAULT_PAGEFIT, DocumentViewController.PAGE_FIT_WINDOW_WIDTH); } catch (NumberFormatException e) { // eating error, as we can continue with out alarm } SwingViewBuilder factory = new SwingViewBuilder(controller, viewType, pageFit); JFrame frame = factory.buildViewerFrame(); if (frame != null) { int width = getProperties().getInt("application.width", 800); int height = getProperties().getInt("application.height", 600); frame.setSize(width, height); int x = getProperties().getInt("application.x", 1); int y = getProperties().getInt("application.y", 1); frame.setLocation( (int) (x + (newWindowInvokationCounter * 10)), (int) (y + (newWindowInvokationCounter * 10))); ++newWindowInvokationCounter; frame.setVisible(true); } return controller; }
public ShapesTemplate(Shape[] shapes) { this.shapes = shapes; if (shapes == null || shapes.length < 1) { this.shapes = new Shape[0]; } JFrame frame = new JFrame("DAY 6, 2D Graphics"); frame.setLocation(750, 150); frame.setMinimumSize(new Dimension(600, 400)); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.getContentPane().add(this); frame.pack(); frame.setVisible(true); repaint(); }