public void init(Controller c) { super.init(c); // Make the Display2D. We'll have it display stuff later. display = new Display2D(500, 500, this, 1); // at 400x400, we've got 4x4 per array position displayFrame = display.createFrame(); c.registerFrame(displayFrame); // register the frame so it appears in the "Display" list displayFrame.setVisible(true); // attach the portrayals from bottom to top display.attach(foodPortrayal, "Food"); display.attach(agentPortrayal, "Agents"); displayFrame.setTitle("Agents"); // specify the backdrop color -- what gets painted behind the displays display.setBackdrop(Color.yellow); // Make the Display2D. We'll have it display stuff later. display2 = new Display2D(400, 400, this, 1); // at 400x400, we've got 4x4 per array position displayFrame2 = display2.createFrame(); displayFrame2.setTitle("Statistic"); c.registerFrame(displayFrame2); // register the frame so it appears in the "Display" list displayFrame2.setVisible(false); // specify the backdrop color -- what gets painted behind the displays display2.setBackdrop(Color.GRAY); // attach the portrayals from bottom to top display2.attach(summaryPortrayal, "Summary"); }
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 void actionPerformed(ActionEvent ae) { if (ae.getSource() == b1) { try { Class.forName("oracle.jdbc.driver.OracleDriver"); Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe", "system", "123"); PreparedStatement ps = con.prepareStatement("select * from LoginForm where username=? and password=?"); String UserName = t1.getText(); String Password = jp1.getText(); ps.setString(1, UserName); ps.setString(2, Password); ResultSet rs = ps.executeQuery(); boolean flag = rs.next(); if (flag) { new Main(); f.setVisible(false); } else { JOptionPane.showMessageDialog(null, "Please Enter valid Name And Password"); } } catch (Exception e) { System.out.println("Error:" + e); } } else if (ae.getSource() == b2) { t1.setText(""); jp1.setText(""); } else if (ae.getSource() == b3) { f.setVisible(false); } }
private void startAction(boolean export) { optionsFrame.setVisible(false); progressBar.setValue(0); progressBar.setIndeterminate(true); textArea.setText(""); progressFrame.setVisible(true); new Thread(new ImportExportRunnable(export)).start(); }
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JBubblePanel bubblePanel = new JBubblePanel(); JTextPane textPane = new JTextPane(); bubblePanel.setLayout(new BorderLayout()); bubblePanel.add(textPane, BorderLayout.CENTER); Font normalFont = new Font("Arial", Font.PLAIN, 12); Font boldFont = new Font("Arial", Font.BOLD, 12); SimpleAttributeSet normal = new SimpleAttributeSet(); SimpleAttributeSet bold = new SimpleAttributeSet(); StyleConstants.setBold(bold, true); try { textPane .getDocument() .insertString(textPane.getDocument().getLength(), "Your connection to ", normal); textPane .getDocument() .insertString(textPane.getDocument().getLength(), "cvs.dev.java.net ", bold); textPane .getDocument() .insertString( textPane.getDocument().getLength(), "failed. Here are a few possible reasons.\n\n", normal); textPane .getDocument() .insertString( textPane.getDocument().getLength(), " Your computer is may not be connected to the network.\n" + "* The CVS server name may be entered incorrectly.\n\n", normal); textPane .getDocument() .insertString( textPane.getDocument().getLength(), "If you still can not connect, please contact support at ", normal); textPane .getDocument() .insertString(textPane.getDocument().getLength(), "*****@*****.**", bold); textPane.getDocument().insertString(textPane.getDocument().getLength(), ".", normal); } catch (BadLocationException ex) { ex.printStackTrace(); } frame.getContentPane().setLayout(new BorderLayout()); frame.getContentPane().add(bubblePanel, BorderLayout.CENTER); frame.setBounds(200, 300, 400, 360); frame.setVisible(true); }
// Test routine. public static void main(String[] args) { // Create a button with the label "Jackpot". JButton button = new RoundButton("Jackpot"); button.setBackground(Color.green); // Create a frame in which to show the button. JFrame frame = new JFrame(); frame.getContentPane().setBackground(Color.yellow); frame.getContentPane().add(button); frame.getContentPane().setLayout(new FlowLayout()); frame.setSize(150, 150); frame.setVisible(true); }
/* (non-Javadoc) * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) */ public void actionPerformed(ActionEvent e) { PopUp popup; if ("Add".equals(e.getActionCommand())) { popup = new PopUp(1, 0); if (popup.text != null && popup.text.length() != 0) { try { if (!control.create_user(popup.text, popup.secondText)) { popup = new PopUp("User Already Exists"); } } catch (IOException e1) { // TODO Auto-generated catch block } } populateUsers(); } else if ("Logout".equals(e.getActionCommand())) { try { JFrame topFrame = (JFrame) SwingUtilities.getWindowAncestor(this); topFrame.setVisible(false); popup = new PopUp(4, 0); if (popup.response == 0) { padre.logout(); } else { topFrame.setVisible(true); } } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } else { popup = new PopUp(3, 0); if (popup.response == 0) { if (userList.getSelectedValue() == null) // checks to see if the list is empty { } else // deletes the user { try { System.out.println(control.delete_user(userList.getSelectedValue())); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } } populateUsers(); } }
public void go() { picture(); ActionListener listener = new BtListener(); go.addActionListener(listener); btn_update_manual.addActionListener(listener); go.setForeground(Color.black); // rights.setFont((new Font("Arial", Font.PLAIN, 12))); title.setFont((new Font("Arial", Font.BOLD, 36))); title.setForeground(new Color(238, 253, 253)); today.setFont((new Font("Arial", Font.BOLD, 16))); today.setForeground(new Color(163, 184, 204)); frame.setLayout(new BorderLayout()); from.setBackground(Color.white); to.setBackground(Color.white); converted.setFont(new Font("Arial", Font.BOLD, 24)); converted.setForeground(new Color(238, 253, 253)); Lfrom.setForeground(new Color(238, 253, 253)); Lto.setForeground(new Color(238, 253, 253)); quantity.setForeground(new Color(238, 253, 253)); Lfrom.setFont(new Font("Arial", Font.BOLD, 24)); Lto.setFont(new Font("Arial", Font.BOLD, 24)); quantity.setFont(new Font("Arial", Font.BOLD, 24)); north.setLayout(new FlowLayout()); north.add(title); north.setBackground(new Color(59, 62, 71)); frame.add(BorderLayout.NORTH, north); inner.setLayout(new BorderLayout()); inner.add(BorderLayout.NORTH, today); inner.add(BorderLayout.WEST, picPanel); center.setLayout(new GridLayout(2, 4, 5, 5)); center.add(Lfrom); center.add(from); center.add(Lto); center.add(to); center.add(quantity); center.add(amount); center.add(go); inner.setBackground(new Color(59, 62, 71)); inner.add(BorderLayout.SOUTH, center); center.setBackground(new Color(59, 62, 71)); frame.add(BorderLayout.CENTER, inner); south.setBackground(new Color(59, 62, 71)); south.setLayout(new FlowLayout()); south.add(converted); south.add(answer); south.add(btn_update_manual); // south.add(rights); frame.add(BorderLayout.SOUTH, south); frame.setSize(850, 700); frame.setVisible(true); frame.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent event) { frame.setVisible(false); frame.dispose(); System.exit(0); } }); }
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); }
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 void newframe() { JFrame frame = new JFrame("Cab Service "); frame.setSize(800, 600); frame.setVisible(true); // frame.setBackground(Color.CYAN); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JButton jb = new JButton("Set Name of Places "); jb.setBounds(100, 100, 20, 50); JPanel jp = new JPanel(); jp.setBackground(Color.gray); jp.add(jb); frame.add(jp); JPanel jp1 = new JPanel(); jp1.setBackground(Color.gray); frame.add(jp1); frame.add(jp); jb.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { try { CreateFrame(); } catch (IOException ex) { Logger.getLogger(SetMap.class.getName()).log(Level.SEVERE, null, ex); } } }); }
public static void main(String[] args) { Example4 ef = new Example4(); try { final String molS = "C1C2=CC=CC=C2C3=C4CC5=CC=CC=C5C4=C6CC7=CC=CC=C7C6=C13"; Molecule mol = MolImporter.importMol(molS); PolarizabilityPlugin plugin = new PolarizabilityPlugin(); plugin.setMolecule(mol); plugin.run(); ArrayList values = new ArrayList(); java.text.NumberFormat nf = java.text.NumberFormat.getInstance(); nf.setMaximumFractionDigits(3); for (int i = 0; i < mol.getAtomCount(); i++) { values.add(Float.valueOf(nf.format(((Double) plugin.getResult(i)).floatValue()))); } mol.hydrogenize(true); for (int i = 0; i < mol.getExplicitHcount(); i++) { values.add(new Double(0)); } ef.setPlugin(plugin); JFrame frame = ef.createSpaceFrame(mol, values); frame.setTitle("Polarizability"); java.net.URL u = ef.getClass().getResource("/chemaxon/marvin/space/gui/mspace16.gif"); frame.setIconImage( Toolkit.getDefaultToolkit().createImage((java.awt.image.ImageProducer) u.getContent())); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } }
public static void main(String[] args) { Browser browser = new Browser(); BrowserView browserView = new BrowserView(browser); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.add(browserView, BorderLayout.CENTER); frame.setSize(800, 600); frame.setLocationRelativeTo(null); frame.setVisible(true); browser.setDownloadHandler( new DownloadHandler() { public boolean allowDownload(DownloadItem download) { download.addDownloadListener( new DownloadListener() { public void onDownloadUpdated(DownloadEvent event) { DownloadItem download = event.getDownloadItem(); if (download.isCompleted()) { System.out.println("Download is completed!"); } } }); System.out.println( "Destination file: " + download.getDestinationFile().getAbsolutePath()); return true; } }); browser.loadURL("ftp://ftp.teamdev.com/updates/jxbrowser-4.0-beta.zip"); }
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(); }
void printButton_actionPerformed(ActionEvent e) { DetailSaleDocVO vo = (DetailSaleDocVO) headerFormPanel.getVOModel().getValueObject(); HashMap params = new HashMap(); params.put("COMPANY_CODE", vo.getCompanyCodeSys01DOC01()); params.put("DOC_TYPE", vo.getDocTypeDOC01()); params.put("DOC_YEAR", vo.getDocYearDOC01()); params.put("DOC_NUMBER", vo.getDocNumberDOC01()); HashMap map = new HashMap(); map.put(ApplicationConsts.COMPANY_CODE_SYS01, vo.getCompanyCodeSys01DOC01()); map.put(ApplicationConsts.FUNCTION_CODE_SYS06, headerFormPanel.getFunctionId()); map.put(ApplicationConsts.EXPORT_PARAMS, params); Response res = ClientUtils.getData("getJasperReport", map); if (!res.isError()) { JasperPrint print = (JasperPrint) ((VOResponse) res).getVo(); JRViewer viewer = new JRViewer(print); JFrame frame = new JFrame(); frame.setSize(MDIFrame.getInstance().getSize()); frame.setContentPane(viewer); frame.setTitle(this.getTitle()); frame.setIconImage(MDIFrame.getInstance().getIconImage()); frame.setVisible(true); } else JOptionPane.showMessageDialog( ClientUtils.getParentFrame(this), res.getErrorMessage(), ClientSettings.getInstance().getResources().getResource("print document"), JOptionPane.ERROR_MESSAGE); }
@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 Processing(Box root) { super(null); Log.log("startup.processing", " processing plugin is starting up "); frame = new JFrame("Field/Processing"); __applet = new FieldProcessingApplet( sizeX, sizeY, queue, this, s -> { if (getLastErrorOutput() != null) getLastErrorOutput().accept(new Pair<>(-1, s)); }); __applet.init(); __applet.loop(); frame.add(__applet, BorderLayout.CENTER); frame.setSize(sizeX, sizeY); frame.setVisible(true); frame.validate(); applet = new FieldProcessingAppletDelgate(__applet); this.properties.put(P, applet); Log.log("startup.processing", " searching for boxes that need processing support "); Log.log("startup.processing", " processing plugin has finished starting up "); }
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 static void createAndShowGUI() { JFrame.setDefaultLookAndFeelDecorated(true); // give JFrame nice decorations JFrame frame = new JFrame("Java GUI"); // create the JFrame frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE); // set up the JFrame to end the program when it closes Container c = frame.getContentPane(); c.setLayout(new BorderLayout()); ColorBars drawingPanel = new ColorBars(); // set up the panel to draw in drawingPanel.setBackground(Color.BLACK); // the the background to black drawingPanel.btnDraw = new JButton("Click me"); // instantiate a swing button drawingPanel.btnDraw.addActionListener(drawingPanel); // register the panel with the button drawingPanel.btnClear = new JButton("Clear Screen"); drawingPanel.btnClear.addActionListener(drawingPanel); Panel buttonPanel = new Panel(); // instantiate the panel for buttons buttonPanel.add(drawingPanel.btnDraw); // add the swing button the the button panel buttonPanel.add(drawingPanel.btnClear); c.add( drawingPanel, BorderLayout.CENTER); // add the drawing panel to the frame (take up the entire frame) c.add(buttonPanel, BorderLayout.SOUTH); // add the button panel to the bottom of the frame frame.setExtendedState(JFrame.MAXIMIZED_BOTH); // set the window to maximized frame.setSize(600, 400); // set the frame size (in case user un-maximizes frame.setVisible(true); // display the frame }
ChartGenerator createNewChart(final GUIState simulation) { generator = createNewGenerator(); globalAttributes = new GlobalAttributes(); generator.addGlobalAttribute(globalAttributes); // it'll be added last // set up the simulation -- need a new name other than guiObjects: and it should be // a HashMap rather than a Bag. if (simulation.guiObjects == null) simulation.guiObjects = new Bag(); simulation.guiObjects.add(generator); final JFrame f = generator.createFrame(simulation); WindowListener wl = new WindowListener() { public void windowActivated(WindowEvent e) {} public void windowClosed(WindowEvent e) {} public void windowClosing(WindowEvent e) { generator.quit(); } public void windowDeactivated(WindowEvent e) {} public void windowDeiconified(WindowEvent e) {} public void windowIconified(WindowEvent e) {} public void windowOpened(WindowEvent e) {} }; f.addWindowListener(wl); f.setVisible(true); return generator; }
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 main(String[] args) { JFrame frame = new JFrame("Maze View"); Random random = new Random(); long startTime = System.nanoTime(); MazeNode maze = MazeNode.generate(random, 100, 100); System.out.println("Gen : " + elapsedMs(startTime) + "ms"); startTime = System.nanoTime(); int sx = 0; // random.nextInt(maze.width); int sy = 0; // random.nextInt(maze.height); int dx = maze.width - 1; // random.nextInt(maze.width); int dy = maze.height - 1; // random.nextInt(maze.height); Path path = PathSolver.solve(maze, sx, sy, dx, dy); System.out.println("Solve : " + elapsedMs(startTime) + "ms"); int pathSize = 0; PathCell pathIt = path.first; while (pathIt != null) { pathSize++; pathIt = pathIt.next; } System.out.println("Path Size: " + pathSize); frame.add(new JScrollPane(new MazeView(maze, sx, sy, dx, dy, path))); frame.setSize(500, 500); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); SwingUtilities.invokeLater(() -> 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); }
/** 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 static void main(String[] args) { JFrame win = new JFrame("MouseMotionEvents"); win.setSize(1024, 768); win.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); win.add(new MouseMotionEvents()); win.setVisible(true); }
public static void main(String[] args) { final Browser browser = new Browser(); BrowserView browserView = new BrowserView(browser); final JTextField addressBar = new JTextField("http://www.teamdev.com/jxbrowser"); addressBar.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { browser.loadURL(addressBar.getText()); } }); JPanel addressPane = new JPanel(new BorderLayout()); addressPane.add(new JLabel(" URL: "), BorderLayout.WEST); addressPane.add(addressBar, BorderLayout.CENTER); JFrame frame = new JFrame("JxBrowser - Hello World"); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.add(addressPane, BorderLayout.NORTH); frame.add(browserView, BorderLayout.CENTER); frame.setSize(800, 500); frame.setLocationRelativeTo(null); frame.setVisible(true); browser.loadURL(addressBar.getText()); }
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 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 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); }