List of usage examples for java.awt GridLayout GridLayout
public GridLayout(int rows, int cols)
From source file:MainClass.java
public MainClass() { super("Focus Example"); setDefaultCloseOperation(EXIT_ON_CLOSE); MyPanel mypanel = new MyPanel(); JButton button1 = new JButton("One"); JButton button2 = new JButton("Two"); JButton button3 = new JButton("Three"); JButton button4 = new JButton("Four"); JButton button5 = new MyButton("Five*"); JButton button6 = new MyButton("Six*"); JButton button7 = new JButton("Seven"); mypanel.add(button2);/* w w w. j av a 2 s . c o m*/ mypanel.add(button3); JInternalFrame frame1 = new JInternalFrame("Internal Frame 1", true, true, true, true); frame1.setBackground(Color.lightGray); frame1.getContentPane().setLayout(new GridLayout(2, 3)); frame1.setSize(300, 200); frame1.getContentPane().add(button1); frame1.getContentPane().add(mypanel); frame1.getContentPane().add(button4); frame1.getContentPane().add(button5); frame1.getContentPane().add(button6); frame1.getContentPane().add(button7); JDesktopPane desktop = new JDesktopPane(); desktop.add(frame1, new Integer(1)); desktop.setOpaque(true); // Now set up the user interface window. Container contentPane = getContentPane(); contentPane.add(desktop, BorderLayout.CENTER); setSize(new Dimension(400, 300)); frame1.setVisible(true); setVisible(true); }
From source file:com.vrane.metaGlacier.gui.MetaDataSignUpDialog.java
MetaDataSignUpDialog() { super(Main.frame, true); JPanel signUpPanel = new JPanel(new GridLayout(4, 2)); final JTextField nameJT = new JTextField(10); final JTextField emailJT = new JTextField(10); final JTextField emailJT1 = new JTextField(10); final JButton signUpButton = new JButton("Sign up"); signUpPanel.setBorder(BorderFactory.createEmptyBorder(10, 5, 5, 5)); signUpPanel.add(new JLabel("name (optional)")); signUpPanel.add(nameJT);//from ww w .ja v a 2 s. c om signUpPanel.add(new JLabel("email")); signUpPanel.add(emailJT); signUpPanel.add(new JLabel("email again")); signUpPanel.add(emailJT1); signUpPanel.add(new JLabel()); signUpPanel.add(signUpButton); signUpButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { final String email = emailJT.getText(); final String email1 = emailJT1.getText(); final String name = nameJT.getText(); boolean success = false; if (!email.equals(email1)) { JOptionPane.showMessageDialog(null, "Email addresses do not match"); return; } if (!EmailValidator.getInstance().isValid(email)) { JOptionPane.showMessageDialog(null, "Invalid email address"); return; } try { success = new SignUp().signup(email, name); } catch (SDKException ex) { LGR.log(Level.SEVERE, null, ex); } if (success) { JOptionPane.showMessageDialog(null, "Please check your email to confirm"); dispose(); return; } JOptionPane.showMessageDialog(null, "Error signing up"); } }); add(signUpPanel); pack(); setLocationRelativeTo(Main.frame); setVisible(true); }
From source file:FocusExample.java
public FocusExample() { super("Focus Example"); setDefaultCloseOperation(EXIT_ON_CLOSE); MyPanel mypanel = new MyPanel(); JButton button1 = new JButton("One"); JButton button2 = new JButton("Two"); JButton button3 = new JButton("Three"); JButton button4 = new JButton("Four"); JButton button5 = new MyButton("Five*"); JButton button6 = new MyButton("Six*"); JButton button7 = new JButton("Seven"); mypanel.add(button2);/*from www .j av a 2 s. co m*/ mypanel.add(button3); JInternalFrame frame1 = new JInternalFrame("Internal Frame 1", true, true, true, true); frame1.setBackground(Color.lightGray); frame1.getContentPane().setLayout(new GridLayout(2, 3)); frame1.setSize(300, 200); frame1.getContentPane().add(button1); frame1.getContentPane().add(mypanel); frame1.getContentPane().add(button4); frame1.getContentPane().add(button5); frame1.getContentPane().add(button6); frame1.getContentPane().add(button7); JDesktopPane desktop = new JDesktopPane(); desktop.add(frame1, new Integer(1)); desktop.setOpaque(true); // Now set up the user interface window. Container contentPane = getContentPane(); contentPane.add(desktop, BorderLayout.CENTER); setSize(new Dimension(400, 300)); frame1.setVisible(true); setVisible(true); }
From source file:InternalFrameListenerDemo.java
public InternalFrameListenerDemo() { setTitle("Animated InternalFrameListener"); m_count = m_tencount = 0;/*from w ww . jav a2 s . c om*/ JPanel innerListenerPanel = new JPanel(new GridLayout(7, 1)); JPanel listenerPanel = new JPanel(new BorderLayout()); m_ifEventCanvas = new IFEventCanvas(); m_lOpened = new JLabel("internalFrameOpened"); m_lClosing = new JLabel("internalFrameClosing"); m_lClosed = new JLabel("internalFrameClosed"); m_lIconified = new JLabel("internalFrameIconified"); m_lDeiconified = new JLabel("internalFrameDeiconified"); m_lActivated = new JLabel("internalFrameActivated"); m_lDeactivated = new JLabel("internalFrameDeactivated"); innerListenerPanel.add(m_lOpened); innerListenerPanel.add(m_lClosing); innerListenerPanel.add(m_lClosed); innerListenerPanel.add(m_lIconified); innerListenerPanel.add(m_lDeiconified); innerListenerPanel.add(m_lActivated); innerListenerPanel.add(m_lDeactivated); listenerPanel.add("Center", m_ifEventCanvas); listenerPanel.add("West", innerListenerPanel); listenerPanel.setOpaque(true); listenerPanel.setBackground(Color.white); m_desktop = new JDesktopPane(); m_desktop.setBorder(new SoftBevelBorder(BevelBorder.LOWERED)); m_newFrame = new JButton("New Frame"); m_newFrame.addActionListener(this); m_infos = UIManager.getInstalledLookAndFeels(); String[] LAFNames = new String[m_infos.length]; for (int i = 0; i < m_infos.length; i++) { LAFNames[i] = m_infos[i].getName(); } m_UIBox = new JComboBox(LAFNames); m_UIBox.addActionListener(this); JPanel topPanel = new JPanel(true); topPanel.setLayout(new FlowLayout()); topPanel.setBorder(new CompoundBorder(new SoftBevelBorder(BevelBorder.LOWERED), new CompoundBorder(new EmptyBorder(2, 2, 2, 2), new SoftBevelBorder(BevelBorder.RAISED)))); getContentPane().setLayout(new BorderLayout()); getContentPane().add("North", topPanel); getContentPane().add("Center", m_desktop); getContentPane().add("South", listenerPanel); ((JPanel) getContentPane()).setBorder(new CompoundBorder(new SoftBevelBorder(BevelBorder.LOWERED), new CompoundBorder(new EmptyBorder(1, 1, 1, 1), new SoftBevelBorder(BevelBorder.RAISED)))); topPanel.add(m_newFrame); topPanel.add(new JLabel("Look & Feel:", SwingConstants.RIGHT)); topPanel.add(m_UIBox); setSize(645, 500); Dimension dim = getToolkit().getScreenSize(); setLocation(dim.width / 2 - getWidth() / 2, dim.height / 2 - getHeight() / 2); setVisible(true); WindowListener l = new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }; addWindowListener(l); m_eventTimer = new Timer(1000, this); m_eventTimer.setRepeats(true); m_eventTimer.start(); }
From source file:org.jfree.chart.demo.GradientPaintTransformerDemo1.java
public static JPanel createDemoPanel() { JPanel jpanel = new JPanel(new GridLayout(2, 2)); jpanel.setPreferredSize(new Dimension(800, 600)); CategoryDataset categorydataset = createDataset(); JFreeChart jfreechart = createChart("Type: VERTICAL", categorydataset); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); BarRenderer barrenderer = (BarRenderer) categoryplot.getRenderer(); barrenderer.setDrawBarOutline(false); barrenderer.setSeriesPaint(0, new GradientPaint(0.0F, 0.0F, Color.red, 0.0F, 0.0F, Color.yellow)); barrenderer.setSeriesPaint(1, new GradientPaint(0.0F, 0.0F, Color.blue, 0.0F, 0.0F, Color.green)); barrenderer.setGradientPaintTransformer( new StandardGradientPaintTransformer(GradientPaintTransformType.VERTICAL)); ChartPanel chartpanel = new ChartPanel(jfreechart); jpanel.add(chartpanel);/*from www . ja v a 2s . c om*/ JFreeChart jfreechart1 = createChart("Type: HORIZONTAL", categorydataset); CategoryPlot categoryplot1 = (CategoryPlot) jfreechart1.getPlot(); BarRenderer barrenderer1 = (BarRenderer) categoryplot1.getRenderer(); barrenderer1.setDrawBarOutline(false); barrenderer1.setSeriesPaint(0, new GradientPaint(0.0F, 0.0F, Color.red, 0.0F, 0.0F, Color.yellow)); barrenderer1.setSeriesPaint(1, new GradientPaint(0.0F, 0.0F, Color.blue, 0.0F, 0.0F, Color.green)); barrenderer1.setGradientPaintTransformer( new StandardGradientPaintTransformer(GradientPaintTransformType.HORIZONTAL)); ChartPanel chartpanel1 = new ChartPanel(jfreechart1); jpanel.add(chartpanel1); JFreeChart jfreechart2 = createChart("Type: CENTER_VERTICAL", categorydataset); CategoryPlot categoryplot2 = (CategoryPlot) jfreechart2.getPlot(); BarRenderer barrenderer2 = (BarRenderer) categoryplot2.getRenderer(); barrenderer2.setDrawBarOutline(false); barrenderer2.setSeriesPaint(0, new GradientPaint(0.0F, 0.0F, Color.red, 0.0F, 0.0F, Color.yellow)); barrenderer2.setSeriesPaint(1, new GradientPaint(0.0F, 0.0F, Color.blue, 0.0F, 0.0F, Color.green)); barrenderer2.setGradientPaintTransformer( new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_VERTICAL)); ChartPanel chartpanel2 = new ChartPanel(jfreechart2); jpanel.add(chartpanel2); JFreeChart jfreechart3 = createChart("Type: CENTER_HORIZONTAL", categorydataset); CategoryPlot categoryplot3 = (CategoryPlot) jfreechart3.getPlot(); BarRenderer barrenderer3 = (BarRenderer) categoryplot3.getRenderer(); barrenderer3.setDrawBarOutline(false); barrenderer3.setSeriesPaint(0, new GradientPaint(0.0F, 0.0F, Color.red, 0.0F, 0.0F, Color.yellow)); barrenderer3.setSeriesPaint(1, new GradientPaint(0.0F, 0.0F, Color.blue, 0.0F, 0.0F, Color.green)); barrenderer3.setGradientPaintTransformer( new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_HORIZONTAL)); ChartPanel chartpanel3 = new ChartPanel(jfreechart3); jpanel.add(chartpanel3); return jpanel; }
From source file:mysynopsis.FTPUploader.java
public static void display() throws IOException { JTextField address = new JTextField(server); JTextField username = new JTextField(user); JPasswordField password = new JPasswordField(pass); JTextField directory = new JTextField(dir); JPanel panel = new JPanel(new GridLayout(10, 1)); panel.add(new JLabel("Server Address:")); panel.add(address);/*from w ww. j av a2 s. c o m*/ panel.add(new JLabel("Username:")); panel.add(username); panel.add(new JLabel("Password:")); panel.add(password); panel.add(new JLabel("Upload Directory:")); panel.add(directory); int result; /*JOptionPane pane = new JOptionPane(panel,JOptionPane.PLAIN_MESSAGE, JOptionPane.YES_NO_CANCEL_OPTION); JDialog dialog = pane.createDialog(MotherFrame.mframe, "FTP Upload Wizard - My Synopsis"); dialog.setSize(new Dimension(300,300)); dialog.setVisible(true);*/ result = JOptionPane.showConfirmDialog(MotherFrame.mframe, panel, "FTP Upload Wizard", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); if (result == JOptionPane.OK_OPTION) { server = address.getText(); user = username.getText(); pass = new String(password.getPassword()); // System.out.println(pass); dir = directory.getText(); JOptionPane.showMessageDialog(MotherFrame.mframe, "Press OK to start FTP Upload"); HTMLWriter.writeHTML(); JOptionPane.showMessageDialog(MotherFrame.mframe, uploadWizard()); } else { // System.out.println("Cancelled"); } }
From source file:DesktopManagerDemo.java
public DesktopManagerDemo() { setTitle("Animated DesktopManager"); m_count = m_tencount = 0;/* ww w . java2 s .c o m*/ JPanel innerListenerPanel = new JPanel(new GridLayout(15, 1)); JPanel listenerPanel = new JPanel(new BorderLayout()); m_dmEventCanvas = new DMEventCanvas(); m_lActivates = new JLabel("activateFrame"); m_lBegindrags = new JLabel("beginDraggingFrame"); m_lBeginresizes = new JLabel("beginResizingFrame"); m_lCloses = new JLabel("closeFrame"); m_lDeactivates = new JLabel("deactivateFrame"); m_lDeiconifies = new JLabel("deiconifyFrame"); m_lDrags = new JLabel("dragFrame"); m_lEnddrags = new JLabel("endDraggingFrame"); m_lEndresizes = new JLabel("endResizingFrame"); m_lIconifies = new JLabel("iconifyFrame"); m_lMaximizes = new JLabel("maximizeFrame"); m_lMinimizes = new JLabel("minimizeFrame"); m_lOpens = new JLabel("openFrame"); m_lResizes = new JLabel("resizeFrame"); m_lSetbounds = new JLabel("setBoundsForFrame"); innerListenerPanel.add(m_lActivates); innerListenerPanel.add(m_lBegindrags); innerListenerPanel.add(m_lBeginresizes); innerListenerPanel.add(m_lCloses); innerListenerPanel.add(m_lDeactivates); innerListenerPanel.add(m_lDeiconifies); innerListenerPanel.add(m_lDrags); innerListenerPanel.add(m_lEnddrags); innerListenerPanel.add(m_lEndresizes); innerListenerPanel.add(m_lIconifies); innerListenerPanel.add(m_lMaximizes); innerListenerPanel.add(m_lMinimizes); innerListenerPanel.add(m_lOpens); innerListenerPanel.add(m_lResizes); innerListenerPanel.add(m_lSetbounds); listenerPanel.add("Center", m_dmEventCanvas); listenerPanel.add("West", innerListenerPanel); listenerPanel.setOpaque(true); listenerPanel.setBackground(Color.white); m_myDesktopManager = new MyDesktopManager(); m_desktop = new JDesktopPane(); m_desktop.setDesktopManager(m_myDesktopManager); m_desktop.setBorder(new SoftBevelBorder(BevelBorder.LOWERED)); m_newFrame = new JButton("New Frame"); m_newFrame.addActionListener(this); m_infos = UIManager.getInstalledLookAndFeels(); String[] LAFNames = new String[m_infos.length]; for (int i = 0; i < m_infos.length; i++) { LAFNames[i] = m_infos[i].getName(); } m_UIBox = new JComboBox(LAFNames); m_UIBox.addActionListener(this); JPanel topPanel = new JPanel(true); topPanel.setLayout(new FlowLayout()); topPanel.setBorder(new CompoundBorder(new SoftBevelBorder(BevelBorder.LOWERED), new CompoundBorder(new EmptyBorder(2, 2, 2, 2), new SoftBevelBorder(BevelBorder.RAISED)))); getContentPane().setLayout(new BorderLayout()); getContentPane().add("North", topPanel); getContentPane().add("Center", m_desktop); getContentPane().add("South", listenerPanel); ((JPanel) getContentPane()).setBorder(new CompoundBorder(new SoftBevelBorder(BevelBorder.LOWERED), new CompoundBorder(new EmptyBorder(1, 1, 1, 1), new SoftBevelBorder(BevelBorder.RAISED)))); topPanel.add(m_newFrame); topPanel.add(new JLabel("Look & Feel:", SwingConstants.RIGHT)); topPanel.add(m_UIBox); setSize(645, 600); Dimension dim = getToolkit().getScreenSize(); setLocation(dim.width / 2 - getWidth() / 2, dim.height / 2 - getHeight() / 2); setVisible(true); WindowListener l = new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }; addWindowListener(l); m_eventTimer = new Timer(1000, this); m_eventTimer.setRepeats(true); m_eventTimer.start(); }
From source file:com.os.util.PasswordDecoderEncoder.java
public PasswordDecoderEncoder() { encryptBtn.addActionListener(this); decryptBtn.addActionListener(this); passText.setColumns(20);/*from w w w .java 2s. c o m*/ GridLayout grid = new GridLayout(0, 2); textPanel.add(passText); textPanel.add(outputPassword); contentPanel.setLayout(grid); contentPanel.add(encryptBtn); contentPanel.add(decryptBtn); mainPanel.add(textPanel); mainPanel.add(contentPanel); frame.add(mainPanel); frame.setVisible(true); frame.setSize(300, 150); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }
From source file:TArea.java
public void init() { Container container = getContentPane(); JPanel panel = new JPanel(); panel.setLayout(new GridLayout(2, 2)); resetButton = new JRadioButton("Reset", true); addButton = new JRadioButton("Add"); subtractButton = new JRadioButton("Subtract"); intersectButton = new JRadioButton("Intersect"); exclusiveORButton = new JRadioButton("ExclusiveOR"); ButtonGroup group = new ButtonGroup(); group.add(resetButton);// w w w . j a v a2 s. c o m group.add(addButton); group.add(subtractButton); group.add(intersectButton); group.add(exclusiveORButton); group.add(resetButton); resetButton.addActionListener(this); addButton.addActionListener(this); subtractButton.addActionListener(this); intersectButton.addActionListener(this); exclusiveORButton.addActionListener(this); panel.add(addButton); panel.add(subtractButton); panel.add(intersectButton); panel.add(exclusiveORButton); container.add(panel, BorderLayout.NORTH); container.add(resetButton, BorderLayout.SOUTH); canvas = new DrawingCanvas(); container.add(canvas); }
From source file:CombineApp.java
public CombineApp() { super("TBandCombineOp"); Container container = getContentPane(); displayPanel = new CombinePanel(); container.add(displayPanel);/* w w w.j av a2s. c o m*/ JPanel panel = new JPanel(); panel.setLayout(new GridLayout(3, 2)); panel.setBorder(new TitledBorder("Click a Button to Perform the Associated Operation and Reset...")); redBandButton = new JButton("Show Red Band"); redBandButton.addActionListener(new ButtonListener()); greenBandButton = new JButton("Show Green Band"); greenBandButton.addActionListener(new ButtonListener()); blueBandButton = new JButton("Show Blue Band"); blueBandButton.addActionListener(new ButtonListener()); inverseBandButton = new JButton("Invert All Bands"); inverseBandButton.addActionListener(new ButtonListener()); middleBandButton = new JButton("Average Each Band"); middleBandButton.addActionListener(new ButtonListener()); resetButton = new JButton("Reset"); resetButton.addActionListener(new ButtonListener()); panel.add(redBandButton); panel.add(blueBandButton); panel.add(greenBandButton); panel.add(inverseBandButton); panel.add(middleBandButton); panel.add(resetButton); container.add(BorderLayout.SOUTH, panel); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); setSize(displayPanel.getWidth(), displayPanel.getHeight()); setVisible(true); }