void setupUI(LocalDisplay[] dpys) throws RemoteException, VisADException { JFrame jframe = new JFrame(getFrameTitle0() + getClientServerTitle()); jframe.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); jframe.setContentPane((JPanel) dpys[0].getComponent()); jframe.pack(); jframe.setVisible(true); if (!uneven) { ScalarMap map1contour = (ScalarMap) dpys[0].getMapVector().lastElement(); ContourWidget cw = new ContourWidget(map1contour); JPanel big_panel = new JPanel(); big_panel.setLayout(new BorderLayout()); big_panel.add("Center", cw); JFrame jframe2 = new JFrame(getFrameTitle1()); jframe2.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); jframe2.setContentPane(big_panel); jframe2.pack(); jframe2.setVisible(true); } }
/** initialize the simulation */ public void init(Controller controller) { super.init(controller); display = new Display2D(800, 600, this); display.attach(polyPortrayal, "Polys"); displayFrame = display.createFrame(); controller.registerFrame(displayFrame); displayFrame.setVisible(true); // the happiness chart setup happinessChart = new TimeSeriesChartGenerator(); happinessChart.setTitle("Percent of Happy Persons in Simulation"); happinessChart.setRangeAxisLabel("Percent Happy"); happinessChart.setDomainAxisLabel("Opportunities to Move"); JFrame chartFrame = happinessChart.createFrame(this); chartFrame.pack(); controller.registerFrame(chartFrame); // the # moves histogram setup numMovesHisto = new HistogramGenerator(); numMovesHisto.setTitle("Number of Moves People Have Made"); numMovesHisto.setDomainAxisLabel("Number of Moves"); numMovesHisto.setRangeAxisLabel("%"); JFrame histoFrame = numMovesHisto.createFrame(this); histoFrame.pack(); controller.registerFrame(histoFrame); }
private Thread ripAlbum(String urlString) { URL url = null; try { url = new URL(urlString); } catch (MalformedURLException e) { logger.error("[!] Could not generate URL for '" + urlString + "'", e); status("Error: " + e.getMessage()); return null; } ripButton.setEnabled(false); ripTextfield.setEnabled(false); statusProgress.setValue(100); openButton.setVisible(false); statusLabel.setVisible(true); mainFrame.pack(); try { AbstractRipper ripper = AbstractRipper.getRipper(url); ripTextfield.setText(ripper.getURL().toExternalForm()); ripper.setObserver((RipStatusHandler) this); Thread t = new Thread(ripper); t.start(); return t; } catch (Exception e) { logger.error("[!] Error while ripping: " + e.getMessage(), e); status("Error: " + e.getMessage()); ripButton.setEnabled(true); ripTextfield.setEnabled(true); statusProgress.setValue(0); mainFrame.pack(); return null; } }
public static void main(String[] args) throws IllegalArgumentException, IllegalAccessException { JFrame jf = new JFrame(); AttributesPanel colpal = new AttributesPanel(); colpal.setEntity(new FrameFact("hola")); colpal.setEntity(new FrameFact("hola")); jf.getContentPane().add(colpal); jf.pack(); jf.show(); jf.pack(); }
public static void main(String[] args) throws Exception { JFrame quizWindow = new JFrame(); quizWindow.setVisible(true); // 1. find an image on the internet, and put its URL in a String variable (from your browser, // right click on the image, and select “Copy Image URL”) String url1 = "http://cdn.v-harness.com/wp-content/uploads/2015/03/tree.png"; // 2. create a variable of type "Component" that will hold your image JLabel image1; // 3. use the "createImage()" method below to initialize your Component image1 = new JLabel(createImage(url1)); image1.setSize(new Dimension(500, 500)); // 4. add the image to the quiz window quizWindow.add(image1); // 5. call the pack() method on the quiz window quizWindow.pack(); // 6. ask a question that relates to the image String question1 = JOptionPane.showInputDialog( "How many trees are in the image? Use lowercase letters to spell out the number."); // 7. print "CORRECT" if the user gave the right answer if (question1.equals("one")) { System.out.println("CORRECT"); } // 8. print "INCORRECT" if the answer is wrong else { System.out.println("INCORRECT"); } // 9. remove the component from the quiz window (you may not see the effect of this until step // 12) quizWindow.remove(image1); // 10. find another image and create it (might take more than one line of code) String url2 = "https://upload.wikimedia.org/wikipedia/commons/6/67/Inside_the_Batad_rice_terraces.jpg"; JLabel image2 = new JLabel(createImage(url2)); // 11. add the second image to the quiz window quizWindow.add(image2); // 12. pack the quiz window quizWindow.pack(); // 13. ask another question String question2 = JOptionPane.showInputDialog( "What color is the image? Use lowercase letters to spell out the color."); // 14+ check answer, say if correct or incorrect, etc. if (question2.equals("green")) { System.out.println("CORRECT"); } else { System.out.println("INCORRECT"); } }
public void actionPerformed(ActionEvent e) { if (e.getSource() == b_salir) { JOptionPane.showMessageDialog( this, "Ya no estas logueado", "Fin de sesion", JOptionPane.INFORMATION_MESSAGE); actual = (JFrame) UtilidadesGUI.getContenedorPrincipal(estePanel); actual.getContentPane().remove(0); actual.getContentPane().add(new PantallaInicio(this.rmi)); actual.setPreferredSize(new Dimension(629, 359)); actual.pack(); actual.repaint(); actual.setLocationRelativeTo(null); } else if (e.getSource() == b_Baja) { try { ControllerTES.getInstance(rmi).darseBaja(this.nomUsuario); JOptionPane.showMessageDialog( this, "Te acabas de dar de baja de THE ELDER SCROLLS CHARACTER CREATOR", "Baja usuario", JOptionPane.INFORMATION_MESSAGE); actual = (JFrame) UtilidadesGUI.getContenedorPrincipal(estePanel); actual.getContentPane().remove(0); actual.getContentPane().add(new PantallaInicio(this.rmi)); actual.setPreferredSize(new Dimension(629, 359)); actual.pack(); actual.repaint(); actual.setLocationRelativeTo(null); } catch (RemoteException e1) { JOptionPane.showMessageDialog( this, "No te has podido dar de baja de THE ELDER SCROLLS CHARACTER CREATOR", "Error baja usuario", JOptionPane.ERROR_MESSAGE); e1.printStackTrace(); } } else if (e.getSource() == b_cargarPersonaje) { actual = (JFrame) UtilidadesGUI.getContenedorPrincipal(estePanel); actual.getContentPane().remove(0); actual.getContentPane().add(new PantallaTablaPersonaje(nomUsuario, this.rmi)); actual.setPreferredSize(new Dimension(629, 359)); actual.pack(); actual.repaint(); actual.setLocationRelativeTo(null); } else if (e.getSource() == b_nuevoPersonaje) { actual = (JFrame) UtilidadesGUI.getContenedorPrincipal(estePanel); actual.dispose(); MenuPersonaje mp = new MenuPersonaje("PantallaLogin", this.nomUsuario, "", this.rmi); } }
public static void main(String[] args) { final JPopupMenu menu = new JPopupMenu(); menu.setLayout(new GridLayout(0, 3, 5, 5)); final MenuedButton button = new MenuedButton("Icons", menu); for (int i = 0; i < 9; i++) { // replace "print.gif" with your own image final JLabel label = new JLabel("" + i); // new ImageIcon("resources/images/print.gif") ); label.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent e) { button.getMainButton().setIcon(label.getIcon()); menu.setVisible(false); } }); menu.add(label); } JFrame frame = new JFrame("Button Test"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(new JLabel("Click Arrow Button To Show Popup"), BorderLayout.NORTH); frame.getContentPane().add(button, BorderLayout.CENTER); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); }
public static void main(String[] args) { JFrame frame = new JFrame("MainForm"); frame.setContentPane(new MainForm().panel1); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); }
/** Displays the Spark error log. */ private void showErrorLog() { final File logDir = new File(Spark.getLogDirectory(), "errors.log"); // Read file and show final String errorLogs = URLFileSystem.getContents(logDir); final JFrame frame = new JFrame(Res.getString("title.client.logs")); frame.setLayout(new BorderLayout()); frame.setIconImage(SparkManager.getApplicationImage().getImage()); final JTextPane pane = new JTextPane(); pane.setBackground(Color.white); pane.setFont(new Font("Dialog", Font.PLAIN, 12)); pane.setEditable(false); pane.setText(errorLogs); frame.add(new JScrollPane(pane), BorderLayout.CENTER); final JButton copyButton = new JButton(Res.getString("button.copy.to.clipboard")); frame.add(copyButton, BorderLayout.SOUTH); copyButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { SparkManager.setClipboard(errorLogs); copyButton.setEnabled(false); } }); frame.pack(); frame.setSize(600, 400); GraphicUtils.centerWindowOnScreen(frame); frame.setVisible(true); }
public OrderDetailsWindow(Order theOrder) { DateFormat df = DateFormat.getDateTimeInstance(); JFrame frame = getJFrame1(); jFrame1.setTitle("Order Details"); jTextField1.setText(df.format(theOrder.OrderDate)); jTextField2.setText(theOrder.Customer.Name + " / " + theOrder.Customer.Email); jTextField3.setText(theOrder.Status); jTextField4.setText(theOrder.ShippingAddress); jTextField5.setText(theOrder.BillingAddress); jTextField6.setText(theOrder.BillingInfo); jTextField7.setText(Double.toString(theOrder.TotalCost)); if (theOrder.LineItems != null) { for (int i = 0; i < theOrder.LineItems.length; i++) { LineItem li = theOrder.LineItems[i]; jTable1Model.addRow( new Object[] { li.Product, li.Product.Description, Integer.toString(li.Quantity), Double.toString(li.PricePaid), Double.toString(li.PricePaid * li.Quantity) }); } } frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); }
/** * Cria a interface grafica para o teste * * @param jLayerPausable objeto para o teste */ public static void interfaceGrafica(JLayerPausableTest jLayerPausable) { JFrame frame = new JFrame("Test JlayerPlayerPausable"); JButton buttonPlay = new JButton("Play"); JButton buttonPause = new JButton("Pause"); JButton buttonStop = new JButton("Stop"); JPanel panel = new JPanel(new GridBagLayout()); panel.add(buttonPlay); panel.add(buttonPause); panel.add(buttonStop); buttonPlay.addActionListener(new ButtonListener(jLayerPausable)); buttonPause.addActionListener(new ButtonListener(jLayerPausable)); buttonStop.addActionListener(new ButtonListener(jLayerPausable)); frame.add(panel); frame.setPreferredSize(new Dimension(200, 100)); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); }
public static void showSpriteCutterDialog(File file) { JFrame frame = new JFrame(); SpriteDetailsPanel sdp = new SpriteDetailsPanel(); SpriteCutterPanel scp = new SpriteCutterPanel( (int) (GUI.getInstance().getWidth() * 0.8), (int) (GUI.getInstance().getHeight() * 0.8)); scp.setPreferredSize( new Dimension( (int) (GUI.getInstance().getWidth() * 0.6), (int) (GUI.getInstance().getHeight() * 0.8))); try { scp.loadSpritesheet(file); } catch (IOException ignored) { } JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(scp), sdp); frame.add(splitPane); frame.setPreferredSize( new Dimension( (int) (GUI.getInstance().getWidth() * 0.8), (int) (GUI.getInstance().getHeight() * 0.8))); frame.setResizable(false); frame.pack(); frame.setVisible(true); }
Main() { f = new JFrame("Wiki Seach"); JPanel p = new JPanel(); JPanel p1 = new JPanel(); b = new JButton("Search"); b1 = new JButton("Exit"); t = new JTextField(30); b.addActionListener(this); b1.addActionListener(this); p1.add(b); p1.add(b1); p.add(t); f.setLayout(new GridLayout(2, 1)); f.add(p); f.add(p1); f.pack(); f.setLocationRelativeTo(null); f.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); f.setVisible(true); }
public void draw() { JFrame frame = new JFrame("Depth Chart"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTabbedPane tabs = new JTabbedPane(); JPanel offense = new JPanel(); String[] qbs = {"12 Brady", "10 Garoppolo", "8 Flynn"}; JComboBox qb = new JComboBox(qbs); qb.add(new JLabel("Quarterbacks")); offense.add(qb); tabs.add("Offense", offense); JPanel defense = new JPanel(); String[] des = {"95 Jones", "50 Ninkovich", "93 Sheard"}; JComboBox de = new JComboBox(des); de.add(new JLabel("Defensive ends")); defense.add(de); tabs.add("Defense", defense); JPanel st = new JPanel(); String[] ks = {"3 Gostkowski"}; JComboBox k = new JComboBox(ks); k.add(new JLabel("Kickers")); st.add(k); tabs.add("Special teams", st); frame.add(tabs); frame.pack(); frame.setVisible(true); }
public EventDemo3() { JFrame f = new JFrame("EventDemo3"); Container contentPane = f.getContentPane(); JButton b = new JButton("按我有声音"); b.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Toolkit.getDefaultToolkit().beep(); } }); contentPane.add(b); f.pack(); f.setVisible(true); f.addWindowListener( new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { System.exit(0); } }); }
private void create() { JFrame f = new JFrame("JSplitPane"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); MyPanel p1 = new MyPanel(Color.red); MyPanel p2 = new MyPanel(Color.blue); final JSplitPane jsp = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, p1, p2); Timer timer = new Timer( 200, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ratio += delta; if (ratio >= 1.0) { ratio = 1.0; delta = -delta; } else if (ratio <= 0) { delta = -delta; ratio = 0; } jsp.setDividerLocation(ratio); } }); f.add(jsp); f.pack(); f.setLocationRelativeTo(null); f.setVisible(true); timer.start(); }
public void launchTrajectoryRenderer() { Visualizer tv = this.getTrajectoryRenderLayerBase(); List<EpisodeAnalysis> trajectories = EpisodeAnalysis.parseFilesIntoEAList(this.expertDir, this.domain, this.sp); TrajectoryRenderer tr = new TrajectoryRenderer( trajectories, GridWorldDomain.CLASSAGENT, GridWorldDomain.ATTX, GridWorldDomain.ATTY, new double[] {0, 30, .5}, new double[] {0, 30, .5}, 3.f, 10.f); tv.addRenderLayer(tr); tv.updateState(trajectories.get(0).getState(0)); JFrame frame = new JFrame(); frame.setPreferredSize(new Dimension(800, 800)); frame.getContentPane().add(tv); frame.pack(); frame.setVisible(true); }
public static void displayWindow( int space, int maxFields, ArrayList<ArrayList<Field>> map, Boolean grid, int miniscale) { JFrame frame = new JFrame(); JPanel container = new JPanel(); container.setLayout(new BoxLayout(container, BoxLayout.X_AXIS)); JPanel mapPanel = new JPanel(); Dimension normalMap = new Dimension(space * 2, space * 2); mapPanel.add(new IsoView(space, maxFields, map, grid, 0)).setPreferredSize(normalMap); container.add(mapPanel); // Draw minimap JPanel miniPanel = new JPanel(); Dimension miniMap = new Dimension((int) space / miniscale, (int) space / miniscale); miniPanel.add(new TwoDView(space, maxFields, map, grid, miniscale)).setPreferredSize(miniMap); container.add(miniPanel); frame.add(container); frame.pack(); frame.setTitle("Map Generator"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLocationRelativeTo(null); frame.setVisible(true); frame.setResizable(true); }
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ public void createAndShowQueryManager() { mainFrame.setPreferredSize(new Dimension(770, 500)); mainFrame.setLocation(400, 100); mainFrame.pack(); mainFrame.setVisible(true); mainFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); }
public RemoveFrame() { frame = new JFrame("Select Files you wish to Remove from Drive"); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.getRootPane().setDefaultButton(confirm); try { files = DriveList.list(); } catch (IOException e) { files = new ArrayList<File>(); } confirm = new JButton("Remove"); quit = new JButton("Cancel"); confirm.addActionListener(this); quit.addActionListener(this); frame.setLayout(new BorderLayout()); checkPanel = new JPanel(); control = new JPanel(); control.setLayout(new GridLayout(1, 2)); control.add(confirm); control.add(quit); frame.add(control, BorderLayout.SOUTH); drawCheckPanel(); frame.add(checkPanel, BorderLayout.CENTER); frame.pack(); frame.setVisible(true); }
/** Simple test program. */ public static void main(String[] args) { final JFrame frame = new JFrame("Testing AddPersonDialog"); JButton button = new JButton("Click me"); button.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { FamilyTree tree = new FamilyTree(); AddPersonDialog dialog = new AddPersonDialog(frame, tree); dialog.pack(); dialog.setLocationRelativeTo(frame); dialog.setVisible(true); Person newPerson = dialog.getPerson(); if (newPerson != null) { tree.addPerson(newPerson); PrettyPrinter pretty = new PrettyPrinter(new PrintWriter(System.out, true)); pretty.dump(tree); } } }); frame.getContentPane().add(button); frame.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(1); } }); frame.pack(); frame.setVisible(true); }
public static void main(String[] args) { JFrame gameWindow = new JFrame("Tic Tac Toe"); gameWindow.add(new TicTacToeGame()); gameWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); gameWindow.pack(); gameWindow.setVisible(true); }
/** * Simple test. * * @author nschuste * @version 1.0.0 * @throws InterruptedException * @since Feb 23, 2016 */ @Test(timeout = 10000) public void test() throws InterruptedException { final Map<String, Object> mp = new HashMap<>(); mp.put("abc", new TextDispatcher()); Mockito.when(this.context.getBeansWithAnnotation(Matchers.any())).thenReturn(mp); final JFrame frame = new JFrame(); final JTextField b = new JTextField(); b.setName("xyz"); final JButton c = new JButton(); c.setName("cc"); frame.getContentPane().add(b); frame.getContentPane().add(c); frame.pack(); frame.setVisible(true); final JTextComponentFixture fix = new JTextComponentFixture(this.r, "xyz"); final JButtonFixture fix2 = new JButtonFixture(this.r, "cc"); this.dispatcher.initialize(this.lstr); final ArgumentCaptor<TestCaseStep> captor = ArgumentCaptor.forClass(TestCaseStep.class); fix.enterText("hello"); fix2.focus(); try { SwingUtilities.invokeAndWait(() -> {}); } catch (final InvocationTargetException e) { e.printStackTrace(); } Mockito.verify(this.lstr, Mockito.times(1)).event(captor.capture()); final TestCaseStep capt = captor.getValue(); Assert.assertEquals(capt.getMethodName(), "text.enter"); Assert.assertEquals(capt.getArgs().length, 2); Assert.assertEquals(capt.getArgs()[0], "xyz"); Assert.assertEquals(capt.getArgs()[1], "hello"); }
/** * Tries the MidiDeviceListModel. * * @param args Command line arguments (ignored). */ public static void main(final String... args) { final JFrame f = new JFrame("foo"); final JList list = new JList(new MidiDeviceListModel()); f.add(new JScrollPane(list)); f.pack(); f.setVisible(true); }
public static void main(String[] args) { JFrame frame = new JFrame(); GameScreen gameScreen = new GameScreen(); frame.setPreferredSize(new Dimension(1366, 768)); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // frame.setUndecorated(true); // frame.setExtendedState(JFrame.MAXIMIZED_BOTH); frame.setResizable(false); frame.add(gameScreen); frame.pack(); frame.setVisible(true); gameScreen.updateScreenSize(); InputFlag.reset(); while (true) { try { Thread.sleep((long) (1000f / GameScreen.FRAMERATE)); } catch (InterruptedException e) { } gameScreen.update(); gameScreen.repaint(); InputFlag.clearTrigger(); } }
public static void main(String[] args) { ArrayList<Pattern> patterns = new ArrayList<Pattern>(); ArrayList<Cut> cuts; ArrayList<Garment> garments; patterns.add(new Pattern(2, 2, 1, "Tie")); patterns.add(new Pattern(2, 6, 4, "Skirt")); patterns.add(new Pattern(4, 2, 3, "Blouse")); patterns.add(new Pattern(5, 3, 5, "Dress")); int width = 30; int height = 15; ClothCutter cutter = new ClothCutter(width, height, patterns); System.out.println("Optimized value: " + cutter.optimize()); cuts = cutter.getCuts(); garments = cutter.getGarments(); ClothPanel panel = new ClothPanel(width, height); JFrame frame = new JFrame("A luxurious bolt of fabric"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(panel); frame.pack(); frame.setVisible(true); sleep(1000); for (int i = 0; i < cuts.size(); i++) { panel.drawCut(cuts.get(i)); sleep(100); } for (int i = 0; i < garments.size(); i++) { System.out.println(garments.get(i)); panel.drawGarment(garments.get(i)); sleep(100); } }
public void setupFrame() { JFrame.setDefaultLookAndFeelDecorated(true); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new GridLayout(3, 2)); frame.pack(); frame.setVisible(true); }
public static void panelInit() { JFrame frame = new JFrame("Test"); frame.setContentPane(new Test().mainPanel); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); }
public static void main(final String[] args) { JFrame frame = new JFrame("Credit calculator"); frame.setContentPane(new HypothecCalculator().mainPanel); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); }
public void createUI() { frame.add(panel); panel.add(button); frame.setVisible(true); button.addActionListener(this); frame.pack(); }