/** * 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); }
// Main init private void init() { fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); fenetre.setBounds( LARG_ECRAN / 2 - LARG_FENETRE / 2, HAUT_ECRAN / 2 - HAUT_FENETRE / 2, LARG_FENETRE, HAUT_FENETRE); fenetre.setResizable(false); fenetre.setLayout(null); // ajout d'un ecouteur a la fenetre fenetre.addWindowListener(this); initPanneauHaut(); initPanneauMillieu(); initPanneauBas(); initLabels(); initPanneauHautComponents(); initPanneauMillieuComponents(); initPanneauBasComponents(); ajouterAFenetre(); modeConsultation(); ajouterActionListener(); // derniere instruction fenetre.setVisible(true); }
/** Displays the character window */ public void characterWindow() { if (characterWindow != null) { characterWindow.dispose(); } characterWindow = new JFrame("Character"); characterWindow.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); JTextField health = new JTextField(player.health()); health.setEditable(false); JButton weapon = new JButton(player.weapon().split(" ")[1]); if (player.weapon().split(" ")[1].equals("none")) { weapon.setEnabled(false); } weapon.addActionListener(this); JButton armor = new JButton(player.armor().split(" ")[1]); if (player.armor().split(" ")[1].equals("none")) { armor.setEnabled(false); } armor.addActionListener(this); characterWindow.setBounds( mainWindow.getX() + mainWindow.getWidth(), mainWindow.getY(), 200, 150); characterWindow.setResizable(false); characterWindow.setLayout(new GridLayout(3, 1)); characterWindow.add(health); characterWindow.add(weapon); characterWindow.add(armor); characterWindow.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[]) { 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); }
/** 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"); }
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 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
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); }
/** 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
/** EdiDialog constructor comment. */ public static void test() { JFrame frame = new JFrame(); frame.addWindowListener(new CloseSaveWindowsListener()); frame.setBackground(ConfigurableSystemSettings.backgroundColor.getAWTColor()); frame.getContentPane().setLayout(new java.awt.BorderLayout()); frame.setBounds(50, 50, 400, 400); frame.show(); DialogNewElement dialog = new DialogNewElement(frame); dialog.show(); }
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) throws IOException { JFrame f = new JFrame("Packet Sender"); f.add(new Sender(), BorderLayout.CENTER); f.setBounds( (d.width - (((rez == 1) ? 550 : 450))) / 2, (d.height - (((rez == 1) ? 400 : 300))) / 2, (((rez == 1) ? 550 : 450)), (((rez == 1) ? 400 : 300))); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setResizable(false); f.setVisible(true); }
public static void main(String[] args) { final JFrame frame = new JFrame(); frame.setBounds(100, 100, 1200, 800); frame.setLayout(null); final VirtualFrame subFrame = new VirtualFrame(20, 20, 1160, 740); subFrame.setTitle("Scrolling test"); frame.add(subFrame); frame.setVisible(true); final TextScroller scroller = new TextScroller(25, VirtualFrame.DEFAULT_BAR_THICKNESS + 25, 400, 650); subFrame.add(scroller); scroller.addLabel("A________________", "Arial", 1, 25); scroller.addLabel("B________________", "Arial", 1, 15); scroller.addLabel("C________________", "Arial", 1, 20); scroller.addLabel("D________________", "Arial", 1, 25); scroller.addLabel("E________________", "Arial", 1, 15); scroller.addLabel("F________________", "Arial", 1, 20); scroller.addLabel("G________________", "Arial", 1, 25); scroller.addLabel("H________________", "Arial", 1, 15); scroller.addLabel("I________________", "Arial", 1, 20); scroller.addLabel("J________________", "Arial", 1, 25); scroller.addLabel("K________________", "Arial", 1, 15); scroller.addLabel("L________________", "Arial", 1, 20); scroller.addLabel("M________________", "Arial", 1, 25); scroller.addLabel("N________________", "Arial", 1, 15); scroller.addLabel("O________________", "Arial", 1, 20); scroller.addLabel("P________________", "Arial", 1, 25); scroller.addLabel("Q________________", "Arial", 1, 15); scroller.addLabel("R________________", "Arial", 1, 20); scroller.addLabel("S________________", "Arial", 1, 25); scroller.addLabel("T________________", "Arial", 1, 15); scroller.addLabel("U________________", "Arial", 1, 20); scroller.addLabel("V________________", "Arial", 1, 25); scroller.addLabel("W________________", "Arial", 1, 15); scroller.addLabel("X________________", "Arial", 1, 20); scroller.addLabel("Y________________", "Arial", 1, 25); scroller.addLabel("Z________________", "Arial", 1, 15); scroller.addLabel("AA_______________", "Arial", 1, 25); scroller.addLabel("BB_______________", "Arial", 1, 15); scroller.addLabel("CC_______________", "Arial", 1, 20); scroller.addLabel("DD_______________", "Arial", 1, 25); scroller.addLabel("EE_______________", "Arial", 1, 15); scroller.addLabel("FF_______________", "Arial", 1, 20); scroller.addLabel("GG_______________", "Arial", 1, 25); scroller.addLabel("HH_______________", "Arial", 1, 15); scroller.addLabel("II_______________", "Arial", 1, 20); scroller.initialize(); }
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); }
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(); } }
/** 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 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 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) { 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 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 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); }
/** 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})); }