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); }
public void setUpGui() { m1 = new MyDrawPanel(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setContentPane(m1); f.setBounds(30, 30, 300, 300); f.setVisible(true); } // quit meth
/** * 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); }
public static void main(String[] args) { Toolkit theKit = aWindow.getToolkit(); // Get the window Toolkit Dimension wndSize = theKit.getScreenSize(); // Get the screen size // Set the position to screen center & size to half screen size aWindow.setBounds( wndSize.width / 4, wndSize.height / 4, // Position wndSize.width / 2, wndSize.height / 2); // Size aWindow.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); GridLayout grid = new GridLayout(5, 2, 30, 20); // Create a layout manager Container content = aWindow.getContentPane(); content.setLayout(grid); EtchedBorder edge = new EtchedBorder(EtchedBorder.RAISED); // Button border // Now add ten Button compenents JButton button; for (int i = 1; i <= 10; i++) { content.add(button = new JButton("Press " + i)); button.setBorder(edge); } aWindow.getContentPane().setBackground(new Color(238, 233, 233)); aWindow.setVisible(true); }
public static void main(String args[]) { File[] IFCFiles = new File("D:\\Data\\Emiel\\CreateTable\\IFC").listFiles(); File[] XMLFiles = new File("D:\\Data\\Emiel\\CreateTable\\XML").listFiles(); Object[] col = new Object[IFCFiles.length + 1]; Object[][] dat = new Object[XMLFiles.length][IFCFiles.length + 1]; col[0] = " "; for (int j = 0; j < IFCFiles.length; j++) { col[j + 1] = IFCFiles[j].getName(); for (int i = 0; i < XMLFiles.length; i++) { File[] BCFFiles = new File( "D:\\Data\\Emiel\\CreateTable\\Results\\" + IFCFiles[j].getName() + "\\" + XMLFiles[i].getName()) .listFiles(); System.out.println(BCFFiles.length); dat[i][0] = XMLFiles[i].getName(); dat[i][j + 1] = BCFFiles.length; } } JFrame frame = new JFrame("MVD Checker"); JTable table = new JTable(dat, col); frame.setVisible(true); frame.setBounds(0, 0, 500, 500); frame.add(table.getTableHeader(), BorderLayout.PAGE_START); frame.add(table); }
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; }
/** Initialize the contents of the frame. */ private void initialize() { frame = new JFrame(); frame.setBounds(100, 100, 450, 300); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame .getContentPane() .setLayout( new FormLayout( new ColumnSpec[] { FormFactory.LABEL_COMPONENT_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, }, new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), FormFactory.LINE_GAP_ROWSPEC, RowSpec.decode("default:grow"), FormFactory.LINE_GAP_ROWSPEC, })); JPanel panel = new JPanel(); frame.getContentPane().add(panel, "2, 2, fill, fill"); openDialog = new FileDialog(this, "Open File", FileDialog.LOAD); JButton btnCharger = new JButton("Charger une partie"); btnCharger.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { openDialog.setVisible(true); try { String dir = openDialog.getDirectory() + openDialog.getFile(); Utilitaire.writeln(dir, textArea); jeu = new Kakuro(frame, dir); jeu.setVisible(true); } catch (NullPointerException point) { } } }); panel.add(btnCharger); JButton btnNvlPartie = new JButton("Nouvelle Partie"); panel.add(btnNvlPartie); btnNvlPartie.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { Random list = new Random(); int seed = list.nextInt(); new Utilitaire(Utilitaire.x, Utilitaire.y, seed); jeu = new Kakuro(frame); jeu.setVisible(true); } }); textArea = new JTextArea(); JScrollPane scrollPane = new JScrollPane(textArea); frame.getContentPane().add(scrollPane, "2, 4, fill, fill"); }
/** Initialize the contents of the frame. */ private void initialize() { frame = new JFrame(); frame.setBounds(100, 100, 450, 300); frame.setVisible(true); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().setLayout(null); JButton btnCustomer = new JButton("Customer"); btnCustomer.setFont(new Font("Tahoma", Font.BOLD, 16)); btnCustomer.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { JOptionPane.showMessageDialog(null, "Welcome to Coffee Kiosk "); // Coffee1 nw = new Coffee1(); // nw.NewScreen(); cust = cust + 1; Customer cs = new Customer(); cs.CustomerScreen(); } }); btnCustomer.setBounds(83, 94, 117, 86); frame.getContentPane().add(btnCustomer); JButton btnAdmin = new JButton("Admin"); btnAdmin.setFont(new Font("Tahoma", Font.BOLD, 16)); btnAdmin.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog(null, "Welcome Admin "); Login ls = new Login(); ls.LoginScreen(); } }); btnAdmin.setBounds(229, 94, 117, 86); frame.getContentPane().add(btnAdmin); JButton btnExit = new JButton("EXIT"); btnExit.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { JOptionPane.showMessageDialog(null, "Thank You for using Coffee Kiosk"); System.exit(0); } }); btnExit.setBounds(168, 207, 89, 23); frame.getContentPane().add(btnExit); JLabel lblLeedsCoffeeKiosk = new JLabel("LEEDS COFFEE KIOSK"); lblLeedsCoffeeKiosk.setHorizontalAlignment(SwingConstants.CENTER); lblLeedsCoffeeKiosk.setFont(new Font("Times New Roman", Font.BOLD | Font.ITALIC, 30)); lblLeedsCoffeeKiosk.setForeground(new Color(148, 0, 211)); lblLeedsCoffeeKiosk.setBounds(36, 11, 366, 72); frame.getContentPane().add(lblLeedsCoffeeKiosk); }
public static void main(String[] args) { JFrame win = new JFrame("JIRC Server"); win.setBounds(200, 200, 250, 75); win.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JIRCServerGUI gui = new JIRCServerGUI(); win.add(gui); win.setVisible(true); }
public void buildGUI() { theFrame = new JFrame("Cyber BeatBox"); theFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); BorderLayout layout = new BorderLayout(); JPanel background = new JPanel(layout); background.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); checkboxList = new ArrayList<JCheckBox>(); Box buttonBox = new Box(BoxLayout.Y_AXIS); JButton start = new JButton("Start"); start.addActionListener(new MyStartListener()); buttonBox.add(start); JButton stop = new JButton("Stop"); stop.addActionListener(new MyStopListener()); buttonBox.add(stop); JButton upTempo = new JButton("Tempo Up"); upTempo.addActionListener(new MyUpTempoListener()); buttonBox.add(upTempo); JButton downTempo = new JButton("Tempo Down"); downTempo.addActionListener(new MyDownTempoListener()); buttonBox.add(downTempo); Box nameBox = new Box(BoxLayout.Y_AXIS); for (int i = 0; i < 16; i++) { nameBox.add(new Label(instrumentNames[i])); } background.add(BorderLayout.EAST, buttonBox); background.add(BorderLayout.WEST, nameBox); theFrame.getContentPane().add(background); GridLayout grid = new GridLayout(16, 16); grid.setVgap(1); grid.setHgap(2); mainPanel = new JPanel(grid); background.add(BorderLayout.CENTER, mainPanel); for (int i = 0; i < 256; i++) { JCheckBox c = new JCheckBox(); c.setSelected(false); checkboxList.add(c); mainPanel.add(c); } // end loop setUpMidi(); theFrame.setBounds(50, 50, 300, 300); theFrame.pack(); theFrame.setVisible(true); } // close method
public void construirVentana() { jfrVentana = new JFrame("CARACETERES ESPECIALES EN EL TEXTO"); jfrVentana.setLayout(new BoxLayout(jfrVentana.getContentPane(), BoxLayout.Y_AXIS)); jfrVentana.add(pnlSuperior); jfrVentana.add(pnlInferior); jfrVentana.pack(); jfrVentana.setResizable(false); jfrVentana.setVisible(true); jfrVentana.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); jfrVentana.setBounds(4, 5, 500, 400); }
/** * Creates the chart. * * @param table the table * @param winSize the win size */ @Override protected void createChart(double[][] table, Dimension winSize) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setBounds(winSize.width, 0, winSize.width, winSize.height); frame.setSize(winSize); // Variables String[] axisLabels = {"DB", "Frequency (log2)"}; frame.getContentPane().add(new DCTGraph(table, winSize, axisLabels)); // frame.pack(); frame.setVisible(true); }
public static void main(String[] args) { TestTtsp ttsp = new TestTtsp(); JFrame jframe = new JFrame("TTSP - Time Precision Error"); ttsp.setPrecisionErrorChart(new PrecisionErrorChart()); jframe.getContentPane().add(ttsp.getPrecisionErrorChart(), "Center"); jframe.setBounds(200, 120, 600, 280); jframe.setVisible(true); jframe.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent windowevent) { System.exit(0); } }); JFrame jframe2 = new JFrame("TTSP - Synchronization Period"); ttsp.setSyncPeriodChart(new SyncPeriodChart()); jframe2.getContentPane().add(ttsp.getSyncPeriodChart(), "Center"); jframe2.setBounds(200, 120, 600, 280); jframe2.setVisible(true); jframe2.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent windowevent) { System.exit(0); } }); try { Thread.sleep(10000); } catch (InterruptedException e) { // TODO Auto-generated catch block // e.printStackTrace(); } }
public static void main(String args[]) throws HTTPException { // prefs storage try { String prefStore = ucar.util.prefs.XMLStore.makeStandardFilename(".unidata", "TdsMonitor.xml"); store = ucar.util.prefs.XMLStore.createFromFile(prefStore, null); prefs = store.getPreferences(); Debug.setStore(prefs.node("Debug")); } catch (IOException e) { System.out.println("XMLStore Creation failed " + e); } // initializations BAMutil.setResourcePath("/resources/nj22/ui/icons/"); // put UI in a JFrame frame = new JFrame("TDS Monitor"); ui = new TdsMonitor(prefs, frame); frame.setIconImage(BAMutil.getImage("netcdfUI")); frame.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { if (!done) ui.exit(); } }); frame.getContentPane().add(ui); Rectangle bounds = (Rectangle) prefs.getBean(FRAME_SIZE, new Rectangle(50, 50, 800, 450)); frame.setBounds(bounds); frame.pack(); frame.setBounds(bounds); frame.setVisible(true); }
private static void createAndShowGUI() { frame = new JFrame(" Fullscreen OSX Bug "); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); enableFullScreen(frame); frame.addMouseListener( new MouseAdapter() { @Override public void mouseEntered(MouseEvent e) { mouseEnterCount++; } }); frame.setBounds(100, 100, 100, 100); frame.pack(); frame.setVisible(true); }
/** Create the GUI and show it. */ public static void createFindProf() { // Create and set up the window. JFrame frame = new JFrame("Find Profesor"); frame.setBounds(600, 300, 80, 40); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); // Create and set up the content pane. JComponent newContentPane = new FindProf(); newContentPane.setOpaque(true); // content panes must be opaque frame.setContentPane(newContentPane); frame.setResizable(false); AutoCompletion.enable(patternList); // Display the window. frame.pack(); frame.setVisible(true); }
Jf() { j.setBounds(500, 40, 500, 500); j.setVisible(true); j.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); j.setLayout(null); ImageIcon image = new ImageIcon("im1.jpg"); JLabel l = new JLabel(image); int m = image.getIconWidth(); int m1 = image.getIconHeight(); j.setResizable(false); // frame resize nahi hoga l.setBounds(0, 0, m, m1); j.add(l); l.add(linfo); l.add(lid); l.add(fid); l.add(lpass); l.add(fpass); fpass.setEchoChar('*'); l.add(blogin); l.add(bnewaccount); l.add(bforget); ImageIcon image1 = new ImageIcon("logo1.png"); JLabel limage = new JLabel(image1); l.add(limage); limage.setBounds(10, 50, 190, 130); Font f = new Font("ALGERIAN", Font.BOLD, 20); linfo.setFont(f); linfo.setBounds(40, 10, 420, 30); lid.setBounds(210, 50, 70, 30); fid.setBounds(290, 50, 150, 30); lpass.setBounds(210, 90, 70, 30); fpass.setBounds(290, 90, 150, 30); blogin.setBounds(210, 130, 100, 50); bnewaccount.setBounds(320, 130, 160, 20); bforget.setBounds(320, 160, 160, 20); blogin.setBackground(Color.green); bnewaccount.setBackground(Color.cyan); bforget.setBackground(Color.pink); blogin.addActionListener(new Login()); bnewaccount.addActionListener(new Account()); bforget.addActionListener(new Forget()); }
public TestApp() { frame = new JFrame(); frame.setBounds(100, 100, 450, 300); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JButton btnRun = new JButton("run"); btnRun.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { JDialog dialog = getChildDialog(); dialog.setModalityType(Dialog.ModalityType.APPLICATION_MODAL); dialog.setVisible(true); } }); frame.getContentPane().add(btnRun, BorderLayout.CENTER); }
public static void main(String[] args) throws Exception { // construct a container JFrame MainFrame = new JFrame("hello"); MainFrame.setBounds(100, 200, 300, 400); // MainFrame.setLayout(new FlowLayout(10,10,10)); BorderLayout bl = new BorderLayout(40, 40); String[] str1 = new String[] {"Name", "Age", "Gender"}; String[][] str2 = new String[][] { new String[] {"Jim", "13", "male"}, new String[] {"Mary", "15", "female"}, new String[] {"Jack", "11", "male"} }; JTable jt = new JTable(str2, str1); JScrollPane jsp = new JScrollPane(jt); MainFrame.add(jsp); MainFrame.setVisible(true); }
public buyTicketFrame(String ticketinfo) { JFrame jf = new JFrame(); Container c = jf.getContentPane(); jf.setLayout(null); jf.setBounds(10, 10, 900, 700); JButton jb1 = new JButton("BUY"); System.out.println(ticketinfo + "\nPlease type in your ID number again "); JLabel jl1 = new JLabel(ticketinfo + "\nPlease type in your ID number again "); JTextField jt1 = new JTextField(""); jb1.setBounds(10, 10, 100, 30); jl1.setBounds(10, 70, 500, 200); jt1.setBounds(200, 10, 100, 30); c.add(jl1); c.add(jb1); c.add(jt1); jf.setVisible(true); }
public static void main(String[] args) { final JFrame jFrame = new JFrame(); jFrame.getContentPane().setLayout(new BorderLayout()); jFrame.getContentPane().setBackground(Color.white); final JPanel jPanel = new JPanel(new BorderLayout()); jPanel.setBackground(Color.white); jPanel.setOpaque(true); jPanel.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createEmptyBorder(10, 10, 10, 10), new BlockBorder(new Insets(5, 5, 5, 5), new Insets(5, 5, 5, 5)))); jFrame.getContentPane().add(jPanel); jFrame.setBounds(100, 100, 200, 200); jFrame.setVisible(true); }
public static void main(String[] args) { String propFileName = null; if (args.length > 0) { propFileName = args[0]; } OneBlockOperation application = new OneBlockOperation(propFileName); JFrame frame = new JFrame(); frame.setTitle(application.getClass().getName()); frame.getContentPane().add(application, BorderLayout.CENTER); application.init(); frame.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); frame.setBounds(50, 50, 400, 150); frame.setVisible(true); }
public void build() { JFrame mainFrame = new JFrame("TicTacToe"); mainFrame.setBounds(100, 100, 400, 400); mainFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); // mainFrame.setLayout(new GridLayout(3, 3)); JButton quitBtn = new JButton("Quit"); // Анонимные классы quitBtn.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { System.exit(0); } }); // FlowLayout по умолчанию JPanel battlefield = new JPanel(new GridLayout(3, 3)); JButton[] btns = new JButton[9]; StepListener listener = new StepListener(); for (int i = 0; i < btns.length; i++) { btns[i] = new JButton(""); btns[i].addActionListener(listener); battlefield.add(btns[i]); } // Создать JPanel // Установить GridLayout нужного размера в JPanel // Добавить в панель кнопки // Поместить панель на юг mainFrame.add(battlefield, BorderLayout.CENTER); mainFrame.add(quitBtn, BorderLayout.SOUTH); mainFrame.setVisible(true); }
public static void toFullScreen( JFrame window, GraphicsDevice gd, boolean tryAppleFullscreen, boolean tryExclusiveFullscreen) { if (appleEawtAvailable() && tryAppleFullscreen && appleOSVersion() >= 7 && // lion and above javaVersion() >= 7) { // java 7 and above System.out.println("trying to apple fullscreen"); enableAppleFullscreen(window); doAppleFullscreen(window); } else if (appleEawtAvailable() && // Snow Leopard and below OR apple java 6 and below TODO: test this on SL tryExclusiveFullscreen && gd.isFullScreenSupported()) { if (javaVersion() >= 7) setAutoRequestFocus(window, true); window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); window.setUndecorated(true); // window.setExtendedState(JFrame.MAXIMIZED_BOTH); gd.setFullScreenWindow(window); window.toFront(); Rectangle r = gd.getDefaultConfiguration().getBounds(); window.setBounds(r); // window.pack(); } else { // Windows and Linux TODO: test this window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); window.setUndecorated(true); window.setSize(gd.getDisplayMode().getWidth(), gd.getDisplayMode().getHeight()); window.setLocation(0, 0); window.setExtendedState(JFrame.MAXIMIZED_BOTH); window.toFront(); } window.pack(); window.setVisible(true); }
public void gold() throws Exception { frm = new JFrame(); frm.setTitle("Background Color for JFrame"); // frm.setSize(400, 400); frm.setLocationRelativeTo(null); // frm.setDefaultCloseOperation(EXIT_ON_CLOSE); frm.setVisible(true); frm.setLayout(new BorderLayout()); JLabel background = new JLabel(new ImageIcon("C:\\Users\\appy\\Desktop\\programs\\i_O\\Untitled.jpg")); frm.add(background); // background.setLayout(new FlowLayout()); background.setLayout(null); lh2 = (int) (((((Math.random()) * 5) * 5) * 5) * 7); lh3 = (int) (((((Math.random()) * 5) * 5) * 5) * 7); lh4 = (int) (((((Math.random()) * 5) * 5) * 5) * 5); lh5 = (int) (((((Math.random()) * 5) * 5) * 5) * 5); lh6 = (int) (((((Math.random()) * 5) * 5) * 5) * 5); lh7 = (int) (((((Math.random()) * 5) * 5) * 5) * 5); lh8 = (int) (((((Math.random()) * 5) * 5) * 5) * 5); lh9 = (int) (((((Math.random()) * 5) * 5) * 5) * 5); lh0 = (int) (((((Math.random()) * 5) * 5) * 5) * 5); // JLabel l1=new JLabel(new ImageIcon("C:\\Users\\appy\\Desktop\\programs\\i_O\\images.gif")); JLabel l1 = new JLabel(new ImageIcon("C:\\Users\\appy\\Desktop\\programs\\i_O\\images.gif")); JLabel l2 = new JLabel(new ImageIcon("C:\\Users\\appy\\Desktop\\programs\\i_O\\car_top_view.gif")); JLabel l3 = new JLabel(new ImageIcon("C:\\Users\\appy\\Desktop\\programs\\i_O\\car_top_view.gif")); JLabel l4 = new JLabel(new ImageIcon("C:\\Users\\appy\\Desktop\\programs\\i_O\\car_top_view.gif")); JLabel l5 = new JLabel(new ImageIcon("C:\\Users\\appy\\Desktop\\programs\\i_O\\car_top_view.gif")); JLabel l6 = new JLabel(new ImageIcon("C:\\Users\\appy\\Desktop\\programs\\i_O\\car_top_view.gif")); JLabel l7 = new JLabel(new ImageIcon("C:\\Users\\appy\\Desktop\\programs\\i_O\\car_top_view.gif")); JLabel l8 = new JLabel(new ImageIcon("C:\\Users\\appy\\Desktop\\programs\\i_O\\car_top_view.gif")); JLabel l9 = new JLabel(new ImageIcon("C:\\Users\\appy\\Desktop\\programs\\i_O\\car_top_view.gif")); JLabel l0 = new JLabel(new ImageIcon("C:\\Users\\appy\\Desktop\\programs\\i_O\\car_top_view.gif")); txter = new JTextField(100); txter.setBounds(3, 4, 0, 35); txter.addKeyListener(this); txter.getCursor(); txter.setText(strgr); row += 10; for (int it = 1; it > 0; it += 7) { // Rectangle r=compu l1.setBounds(300 + my_car.row, 400 + my_car.col, 90, 190); l2.setBounds(lh2, -250 + chg, 90, 190); l3.setBounds(lh3, -750 + chg, 90, 190); l4.setBounds(lh4, -1200 + chg, 90, 190); l5.setBounds(lh5, -1750 + chg, 90, 190); l6.setBounds(lh6, -2250 + chg, 90, 190); l7.setBounds(lh7, -2700 + chg, 90, 190); l8.setBounds(lh8, -3250 + chg, 90, 190); l9.setBounds(lh9, -3800 + chg, 90, 190); l0.setBounds(lh0, -4250 + chg, 90, 190); chg += 20; if (chg >= (5000)) { chg = 0; lh2 = (int) (((((Math.random()) * 5) * 5) * 5) * 5); Thread.sleep(7); lh3 = (int) (((((Math.random()) * 5) * 5) * 5) * 5); Thread.sleep(7); lh4 = (int) (((((Math.random()) * 5) * 5) * 5) * 5); Thread.sleep(7); lh5 = (int) (((((Math.random()) * 5) * 5) * 5) * 5); Thread.sleep(7); lh6 = (int) (((((Math.random()) * 5) * 5) * 5) * 5); Thread.sleep(7); lh7 = (int) (((((Math.random()) * 5) * 5) * 5) * 5); Thread.sleep(7); lh8 = (int) (((((Math.random()) * 5) * 5) * 5) * 5); Thread.sleep(7); lh9 = (int) (((((Math.random()) * 5) * 5) * 5) * 5); Thread.sleep(7); lh0 = (int) (((((Math.random()) * 5) * 5) * 5) * 5); } txter.requestDefaultFocus(); { } Thread.sleep(50); System.out.println(my_car.row); l1.repaint(); l2.repaint(); // b1=new JButton("I am a button"); background.add(l1); background.add(l2); background.add(l3); background.add(l4); background.add(l5); background.add(l6); background.add(l7); background.add(l8); background.add(l9); background.add(l0); background.add(txter); // background.add(b1); // frm.setSize(799, 699); frm.setBounds(0, 0, 800, 700); frm.setResizable(false); } }
/** Initialize the contents of the frame. */ private void initialize() { frame = new JFrame(); frame.setBounds(100, 100, 616, 451); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar menuBar = new JMenuBar(); frame.setJMenuBar(menuBar); JMenu MenuScegli = new JMenu("Scegli"); menuBar.add(MenuScegli); MenuScegliCampionato = new JMenu("Campionato"); MenuScegli.add(MenuScegliCampionato); MenuScegliSquadra = new JMenu("Squadra"); MenuScegli.add(MenuScegliSquadra); JMenu MenuCrea = new JMenu("Crea"); menuBar.add(MenuCrea); JMenuItem MenuCreaCampionato = new JMenuItem("Campionato"); MenuCreaCampionato.addMouseListener( new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { CreaCampionato creaCampionato = new CreaCampionato(); creaCampionato.setVisible(true); } }); MenuCrea.add(MenuCreaCampionato); JMenuItem MenuCreaSquadra = new JMenuItem("Squadra"); MenuCreaSquadra.addMouseListener( new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { CreaSquadra creaSquadra = new CreaSquadra(); creaSquadra.setVisible(true); } }); MenuCrea.add(MenuCreaSquadra); JMenu MenuAltro = new JMenu("Altro"); menuBar.add(MenuAltro); JMenuItem MenuAltroInfo = new JMenuItem("Info"); MenuAltroInfo.addMouseListener( new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { JOptionPane.showMessageDialog(frame, "Per ora niente"); } }); MenuAltro.add(MenuAltroInfo); JMenuItem MenuAltroEsci = new JMenuItem("Esci"); MenuAltroEsci.addMouseListener( new MouseAdapter() { @Override public void mouseReleased(MouseEvent arg0) { if (JOptionPane.showConfirmDialog( frame, "Vuoi veramente uscire?", "Uscire", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) { System.exit(0); } } }); MenuAltro.add(MenuAltroEsci); }
public void launchChess() { mainWindow = new JFrame("网络黑白棋 作者:张炀"); jpWest = new JPanel(); jpEast = new JPanel(); jpNorth = new JPanel(); jpSouth = new JPanel(); jpCenter = new JPanel(); turnLabel = new JLabel(); blackNumberLabel = new JLabel("黑棋:\n" + black + " "); whiteNumberLabel = new JLabel("白棋:\n" + white + " "); timeLabel = new JLabel("时间: " + time + " s"); noticeLabel = new JLabel(); noticeLabel = new JLabel("请选择:"); numberPane = new JPanel(); readyPane = new JPanel(); jt1 = new JTextField(18); // 发送信息框 jt2 = new JTextArea(3, 30); // 显示信息框 js = new JScrollPane(jt2); jt2.setLineWrap(true); jt2.setEditable(false); // jt1.setLineWrap(true); send = new JButton("发送"); cancel = new JButton("取消"); regret = new JButton("悔棋"); submit = new JButton("退出"); begin = new JButton("开始"); save = new JButton("存盘"); save.setEnabled(true); begin.setEnabled(true); fighter = new JRadioButton("下棋"); audience = new JRadioButton("观看"); group = new ButtonGroup(); group.add(audience); group.add(fighter); group.add(AIPlayer); submit.addActionListener(this); begin.addActionListener(this); save.addActionListener(this); send.addActionListener(this); cancel.addActionListener(this); regret.addActionListener(this); fighter.addActionListener(this); audience.addActionListener(this); jpNorth.setLayout(new BorderLayout()); jpNorth.add(turnLabel, BorderLayout.NORTH); jpNorth.add(jpCenter, BorderLayout.CENTER); jpSouth.add(js); jpSouth.add(jt1); jpSouth.add(send); jpSouth.add(cancel); jpEast.setLayout(new GridLayout(3, 1)); submit.setBackground(new Color(130, 251, 241)); panel x = new panel(); jpEast.add(x); jpEast.add(numberPane); jpEast.add(readyPane); numberPane.add(blackNumberLabel); numberPane.add(whiteNumberLabel); numberPane.add(timeLabel); numberPane.add(submit); numberPane.add(begin); numberPane.add(save); numberPane.add(regret); readyPane.add(noticeLabel); readyPane.add(fighter); readyPane.add(audience); // readyPane.add(save); // readyPane.add(regret); jpCenter.setSize(400, 400); jmb = new JMenuBar(); document = new JMenu("游戏 "); edit = new JMenu("设置 "); insert = new JMenu("棋盘 "); help = new JMenu("帮助 "); jmb.add(document); jmb.add(edit); jmb.add(insert); jmb.add(help); // mainWindow.setJMenuBar(jmb); mainWindow.setBounds(80, 80, 600, 600); mainWindow.setResizable(false); jsLeft = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true, jpNorth, jpSouth); jsBase = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, jsLeft, jpEast); mainWindow.add(jsBase); mainWindow.setVisible(true); mainWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jsBase.setDividerLocation(0.7); jsLeft.setDividerLocation(0.78); jpCenter.setLayout(new GridLayout(8, 8, 0, 0)); ImageIcon key = new ImageIcon("chess1.jpg"); for (int i = 0; i < cell.length; i++) for (int j = 0; j < cell.length; j++) { cell[i][j] = new ChessBoard(i, j); cell[i][j].addMouseListener(this); jpCenter.add(cell[i][j]); } cell[3][3].state = cell[4][4].state = '黑'; cell[4][3].state = cell[3][4].state = '白'; cell[3][3].taken = cell[4][4].taken = true; cell[4][3].taken = cell[3][4].taken = true; RememberState(); new Thread(new TurnLabel(this)).start(); file = new File("D:/" + myRole); try { fout = new FileOutputStream(file); out = new ObjectOutputStream(fout); } catch (IOException e1) { e1.printStackTrace(); } Connect(); try { out99 = new ObjectOutputStream(socket99.getOutputStream()); in99 = new ObjectInputStream(socket99.getInputStream()); out66 = new ObjectOutputStream(socket66.getOutputStream()); in66 = new ObjectInputStream(socket66.getInputStream()); out88 = new DataOutputStream(socket88.getOutputStream()); } catch (IOException e) { e.printStackTrace(); } new Thread(new Client9999(this)).start(); new Thread(new Client6666(this)).start(); }
// Action - vad som händer om man klickar på de olika knapparna public void actionPerformed(ActionEvent e) { // Om man trycker på startknappen if (e.getSource() == go) { for (int i = 0; i < 4; i++) { // Skapar spelare och AI, beroende på om textfälten och checkboxarna är ifyllda if (textfields.get(i).getText().length() > 0) { // Om checkboxen är itryckt, skapa ett AI if (boxes.get(i).isSelected()) { try { if (Integer.parseInt(intfields.get(i).getText()) >= 0) { players.add( new AI( textfields.get(i).getText(), Integer.parseInt(intfields.get(i).getText()))); } // Om intellegensen är angivet negativt använder vi ett minne av storleken 0. else { players.add(new AI(textfields.get(i).getText(), 0)); } } // Om intellegensen inte är angiven i siffror, använd standardintellegensen på 20 korts // minne catch (NumberFormatException ex) { players.add(new AI(textfields.get(i).getText(), 20)); } } // Om spelaren inte är ett AI, lägg till en vanlig spelare else { players.add(new Player(textfields.get(i).getText())); } } } // Stänger ner menyn och startar spelet, skickar med spelarinfon if (players.size() >= 1) { this.dispose(); f.dispose(); new Memory(players); } } // Om man trycker på hjälpknappen visas en ruta med lite instruktioner if (e.getSource() == help) { f.setVisible(true); f.setBounds(300, 200, 500, 200); f.setResizable(false); String text = "<html>Om inställningar:<br>Skriv in spelarnas namn för att lägga till dem.<br>" + "Om AI önskas: Klicka i rutan och ange intellegens. (Antal kort AIn kommer ihåg.)<br>" + "Tryck på 'Starta' för att starta spelet.<br><br>" + "Hur man spelar:<br>Spelaren vars tur det är får sitt namn markerat med grön färg längst ner.<br>" + "För att göra ditt drag, tryck på korten. Du kan inte välja samma kort två gånger<br><br>" + "Det är ett vanligt memory, lets go!</html>"; f.add(new JLabel(text), BorderLayout.NORTH); } for (int i = 0; i < boxes.size(); i++) { // Om checkboxarna är ikryssade lägger den till ett eget namn för AIn som ska skapas och visar // rutan för intellegensbestämning if (boxes.get(i).isSelected()) { textfields.get(i).setText("AI " + (i + 1)); textfields.get(i).setEnabled(false); intfields.get(i).setText("" + 20); intfields.get(i).setVisible(true); } // Om checkboxarna blir urklickade igen, nollställ textfälten, och ta bort rutan för // intellegensbestämning else if (!boxes.get(i).isSelected()) { if (textfields.get(i).getText().indexOf("AI") != -1) { textfields.get(i).setText(""); intfields.get(i).setVisible(false); } textfields.get(i).setEnabled(true); } } }
/** Initialize the contents of the frame. */ private void initialize() { frmSignIn = new JFrame("Login"); frmSignIn.setTitle("Sign in"); frmSignIn.setResizable(false); frmSignIn.setBounds(100, 100, 450, 357); frmSignIn.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frmSignIn.setLocationRelativeTo(null); JLabel lblEmail = new JLabel("Email:"); lblEmail.setBounds(73, 108, 56, 18); JLabel lblPassword = new JLabel("Password:"******"Show Password"); chckbxShowPassword.setBounds(130, 176, 128, 23); frmSignIn.getContentPane().add(chckbxShowPassword); chckbxShowPassword.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { passwordField.setEchoChar((char) 0); } else { passwordField.setEchoChar(a); } } }); JButton btnNewButton = new JButton("Sign in"); btnNewButton.setBounds(325, 106, 72, 62); btnNewButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { username = textField.getText(); String password = String.valueOf(passwordField.getPassword()); // getText() // is // deprecated; // changed // to // getPassword() // password.toLowerCase(); Do we want case sensitive email? /* * SHA implementation to validate password */ VaultController v = new VaultController(); int result = 0; try { result = v.loginCheck(username, password); } catch (NoSuchAlgorithmException e1) { e1.printStackTrace(); } if (result == 1) { failedattempt = 0; frmSignIn.dispose(); } else { txtWarning.setText("The Email and/or Password is incorrect. Please try again."); failedattempt++; } // TODO migrate failcheck to Vault controller! if (failedattempt > 1 && failedattempt < 5) { try { VaultController.Send( "sentineldatavault", "SENTINELDATA", username, "Security Warning", "Dear user,\n\nYou have multiple failed login attempts for your account.\n" + "If it is not you, please change your password immediately.\n\n" + "Sincerely,\nSentinel Data Vault Team"); } catch (AddressException e1) { e1.printStackTrace(); } catch (MessagingException e1) { e1.printStackTrace(); } } else if (failedattempt == 5) { DatabaseManager d = new DatabaseManager("vault_database"); User u = d.retrieveUserFromDatabase(username); d.deleteAllEntriesFromDatabase(u); d.deleteUserFromDatabase(u); try { JOptionPane.showMessageDialog( null, "Your account data has been deleted due to multiple failed login attempts"); VaultController.Send( "sentineldatavault", "SENTINELDATA", username, "Security Warning", "Dear user,\n\nWe have deleted your account.\n" + "Have a nice day.\n\n" + "Sincerely,\nSentinel Data Vault Team"); } catch (AddressException e1) { e1.printStackTrace(); } catch (MessagingException e1) { e1.printStackTrace(); } } } }); frmSignIn.getContentPane().setLayout(null); btnSignUp = new JButton("Create new account"); btnSignUp.setToolTipText("Click here to create a new Sentinel Data Vault account!"); btnSignUp.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { SignupView signup = new SignupView(); signup.setVisible(true); } }); btnSignUp.setBounds(57, 264, 158, 27); frmSignIn.getContentPane().add(btnSignUp); frmSignIn.getContentPane().add(btnNewButton); frmSignIn.getContentPane().add(lblPassword); frmSignIn.getContentPane().add(lblEmail); frmSignIn.getContentPane().add(textField); frmSignIn.getContentPane().add(passwordField); btnForgotPassword = new JButton("I forgot my password"); btnForgotPassword.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { frmSignIn.setVisible(false); PasswordRecoveryView p = new PasswordRecoveryView(frmSignIn); } }); btnForgotPassword.setToolTipText("Click here to reset your account password"); btnForgotPassword.setBounds(227, 264, 170, 27); frmSignIn.getContentPane().add(btnForgotPassword); lblSentinelDataVault = new JLabel("Sentinel Data Vault"); lblSentinelDataVault.setFont(new Font("Dialog", Font.PLAIN, 22)); lblSentinelDataVault.setBounds(119, 33, 206, 27); frmSignIn.getContentPane().add(lblSentinelDataVault); txtWarning = new JTextField(); txtWarning.setForeground(new Color(220, 20, 60)); txtWarning.setBorder(null); txtWarning.setOpaque(false); txtWarning.setFocusable(false); txtWarning.setEditable(false); txtWarning.setFont(new Font("Tahoma", Font.ITALIC, 12)); txtWarning.setBackground(SystemColor.window); txtWarning.setBounds(57, 196, 340, 26); frmSignIn.getContentPane().add(txtWarning); txtWarning.setColumns(10); frmSignIn .getContentPane() .setFocusTraversalPolicy( new FocusTraversalOnArray(new Component[] {textField, passwordField, btnNewButton})); frmSignIn.setFocusTraversalPolicy( new FocusTraversalOnArray(new Component[] {textField, passwordField, btnNewButton})); }
public void actionPerformed(ActionEvent e) { String t = fid.getText(); // char[] t2=fpass.getPassword(); String t2 = fpass.getText(); try { DriverManager.registerDriver(new oracle.jdbc.OracleDriver()); Connection con = DriverManager.getConnection( "jdbc:oracle:thin:@localhost:1521:xe", "system", "9696030257"); Statement st = con.createStatement(); ResultSet rs = st.executeQuery( "select * from database where userid='" + t + "' AND password='******'"); rs.next(); String g = rs.getString("userid"); String h = rs.getString("password"); String i = rs.getString("mob"); String j = rs.getString("dob"); if (g.equals(t) && h.equals(t2)) { // JOptionPane.showMessageDialog(null,"WoW !! You Are a Valid User"); JFrame jf1 = new JFrame("About Saras"); jf1.setBounds(500, 40, 500, 500); jf1.setVisible(true); jf1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jf1.setLayout(null); String ab = "\n\nHis Name is Saraswatendra Singh.\nHe is pursuing B.Tech from ABES Engineering College(032) Ghaziabad U.P.\nHe is belong from VARANASI which is also called BANARAS.\nHis Email and Facebook id is <*****@*****.**>\n\n\n \t\t\tTHANK YOU"; String bc = "\n\n\nABOUT YOU:-\n\n\t UserId is < " + g + " >\n\t Password is <" + h + " > \n\t Mobile No is < " + i + " >\n\t Date Of Birth(dd/mm/yyyy) is < " + j + " >\n \n\nABOUT DEVELOPER:-" + ab; JTextArea about = new JTextArea(bc); jf1.add(about); about.setBounds(0, 0, 500, 500); JButton rest = new JButton("ResetPassword"); about.add(rest); rest.setBounds(30, 400, 150, 20); Cursor k1 = new Cursor(Cursor.HAND_CURSOR); rest.setCursor(k1); rest.addActionListener(new ResetPassword()); JButton restmob = new JButton("ResetMobileNo"); about.add(restmob); restmob.setBounds(230, 400, 150, 20); Cursor k2 = new Cursor(Cursor.HAND_CURSOR); restmob.setCursor(k2); restmob.addActionListener(new ResetMob()); } } catch (Exception ex) { System.out.print(ex); JOptionPane.showMessageDialog( null, "UserId or Password MissMatched !!! please Enter Valid UserId and Password"); } }