public Step2Panel(WizardData wzd) { super(wzd); contentPanel = getContentPanel(wzd); contentPanel.setBorder(new EmptyBorder(new Insets(10, 10, 10, 10))); ImageIcon icon = getImageIcon(); titlePanel = new javax.swing.JPanel(); textLabel = new javax.swing.JLabel(); iconLabel = new javax.swing.JLabel(); separator = new javax.swing.JSeparator(); setLayout(new java.awt.BorderLayout()); titlePanel.setLayout(new java.awt.BorderLayout()); titlePanel.setBackground(Color.gray); textLabel.setBackground(Color.gray); textLabel.setFont(new Font("MS Sans Serif", Font.BOLD, 14)); textLabel.setText("Project Language Files"); textLabel.setBorder(new EmptyBorder(new Insets(10, 10, 10, 10))); textLabel.setOpaque(true); iconLabel.setBackground(Color.gray); if (icon != null) { iconLabel.setIcon(icon); } titlePanel.add(textLabel, BorderLayout.CENTER); titlePanel.add(iconLabel, BorderLayout.EAST); titlePanel.add(separator, BorderLayout.SOUTH); add(titlePanel, BorderLayout.NORTH); JPanel secondaryPanel = new JPanel(); secondaryPanel.add(contentPanel, BorderLayout.NORTH); add(secondaryPanel, BorderLayout.WEST); }
static void buildGUI() { // Need this size to balance axes. frame.setSize(520, 690); frame.setTitle("DrawTool"); frame.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); Container cPane = frame.getContentPane(); // Status label on top. Unused for now. statusLabel.setOpaque(true); statusLabel.setBackground(Color.white); cPane.add(statusLabel, BorderLayout.NORTH); // Build the input/output elements at the bottom. JPanel panel = new JPanel(); panel.setBorder(BorderFactory.createLineBorder(Color.black)); panel.setBackground(inputPanelColor); panel.setLayout(new GridLayout(2, 1)); panel.add(outputLabel); JPanel bottomPanel = new JPanel(); bottomPanel.setBackground(inputPanelColor); bottomPanel.add(inputField); bottomPanel.add(new JLabel(" ")); JButton enterButton = new JButton("Enter"); enterButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent a) { hasEntered = true; } }); bottomPanel.add(enterButton); panel.add(bottomPanel); if (!sequencingOn) { cPane.add(panel, BorderLayout.SOUTH); } // Drawing in the center. drawArea = new DrawTool(); if (sequencingOn) { frame.addKeyListener( new KeyAdapter() { public void keyTyped(KeyEvent e) { handleKeyTyped(e); } }); } cPane.add(drawArea, BorderLayout.CENTER); drawArea.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent e) { handleMouseClick(e); } public void mouseReleased(MouseEvent e) { handleMouseReleased(e); } }); drawArea.addMouseMotionListener( new MouseMotionAdapter() { public void mouseDragged(MouseEvent e) { handleMouseDragged(e); } }); }
/** This method is called from within the constructor to initialize the form. */ public void initComponents() { /** *************** The main frame ************************************** */ // width, height this.setSize(560, 370); Container container = this.getContentPane(); container.setLayout(new BoxLayout(getContentPane(), 1)); container.setBackground(containerBackGroundColor); this.setLocation(0, 0); this.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { new AlertInstantMessaging( "Your changes will not be checked: use the Submit button!!!", JOptionPane.WARNING_MESSAGE); hideFrame(); } }); /** **************** The components ********************************* */ firstPanel = new JPanel(); firstPanel.setBorder(BorderFactory.createEmptyBorder(15, 4, 15, 4)); // If put to False: we see the container's background firstPanel.setOpaque(false); // rows, columns, horizontalGap, verticalGap firstPanel.setLayout(new GridLayout(11, 2, 2, 2)); container.add(firstPanel); outboundProxyAddressLabel = new JLabel("Outbound proxy IP address:"); outboundProxyAddressLabel.setForeground(Color.black); outboundProxyAddressTextField = new JTextField(20); outboundProxyAddressLabel.setBorder(labelBorder); outboundProxyAddressLabel.setOpaque(true); outboundProxyAddressLabel.setBackground(labelBackGroundColor); firstPanel.add(outboundProxyAddressLabel); firstPanel.add(outboundProxyAddressTextField); outboundProxyPortLabel = new JLabel("Outbound proxy port:"); outboundProxyPortLabel.setForeground(Color.black); outboundProxyPortTextField = new JTextField(20); outboundProxyPortLabel.setBorder(labelBorder); outboundProxyPortLabel.setOpaque(true); outboundProxyPortLabel.setBackground(labelBackGroundColor); firstPanel.add(outboundProxyPortLabel); firstPanel.add(outboundProxyPortTextField); registrarAddressLabel = new JLabel("Registrar IP address:"); registrarAddressLabel.setForeground(Color.black); registrarAddressTextField = new JTextField(20); registrarAddressLabel.setBorder(labelBorder); registrarAddressLabel.setOpaque(true); registrarAddressLabel.setBackground(labelBackGroundColor); firstPanel.add(registrarAddressLabel); firstPanel.add(registrarAddressTextField); registrarPortLabel = new JLabel("Registrar port:"); registrarPortLabel.setForeground(Color.black); registrarPortTextField = new JTextField(20); registrarPortLabel.setBorder(labelBorder); registrarPortLabel.setOpaque(true); registrarPortLabel.setBackground(labelBackGroundColor); firstPanel.add(registrarPortLabel); firstPanel.add(registrarPortTextField); imAddressLabel = new JLabel("Contact IP address:"); imAddressLabel.setForeground(Color.black); imAddressTextField = new JTextField(20); imAddressLabel.setBorder(labelBorder); imAddressLabel.setOpaque(true); imAddressLabel.setBackground(labelBackGroundColor); firstPanel.add(imAddressLabel); firstPanel.add(imAddressTextField); imPortLabel = new JLabel("Contact port:"); imPortLabel.setForeground(Color.black); imPortTextField = new JTextField(20); imPortLabel.setBorder(labelBorder); imPortLabel.setOpaque(true); imPortLabel.setBackground(labelBackGroundColor); firstPanel.add(imPortLabel); firstPanel.add(imPortTextField); imProtocolLabel = new JLabel("Contact transport:"); imProtocolLabel.setForeground(Color.black); imProtocolTextField = new JTextField(20); imProtocolLabel.setBorder(labelBorder); imProtocolLabel.setOpaque(true); imProtocolLabel.setBackground(labelBackGroundColor); firstPanel.add(imProtocolLabel); firstPanel.add(imProtocolTextField); outputFileLabel = new JLabel("Output file:"); outputFileLabel.setForeground(Color.black); outputFileTextField = new JTextField(20); outputFileLabel.setBorder(labelBorder); outputFileLabel.setOpaque(true); outputFileLabel.setBackground(labelBackGroundColor); firstPanel.add(outputFileLabel); firstPanel.add(outputFileTextField); buddiesFileLabel = new JLabel("Buddies file:"); buddiesFileLabel.setForeground(Color.black); buddiesFileTextField = new JTextField(20); buddiesFileLabel.setBorder(labelBorder); buddiesFileLabel.setOpaque(true); buddiesFileLabel.setBackground(labelBackGroundColor); firstPanel.add(buddiesFileLabel); firstPanel.add(buddiesFileTextField); authenticationFileLabel = new JLabel("Authentication file:"); authenticationFileLabel.setForeground(Color.black); authenticationFileTextField = new JTextField(20); authenticationFileLabel.setBorder(labelBorder); authenticationFileLabel.setOpaque(true); authenticationFileLabel.setBackground(labelBackGroundColor); firstPanel.add(authenticationFileLabel); firstPanel.add(authenticationFileTextField); defaultRouterLabel = new JLabel("Default router class name:"); defaultRouterLabel.setForeground(Color.black); defaultRouterTextField = new JTextField(20); defaultRouterLabel.setBorder(labelBorder); defaultRouterLabel.setOpaque(true); defaultRouterLabel.setBackground(labelBackGroundColor); firstPanel.add(defaultRouterLabel); firstPanel.add(defaultRouterTextField); thirdPanel = new JPanel(); thirdPanel.setOpaque(false); // top, left, bottom, right thirdPanel.setLayout(new FlowLayout(FlowLayout.CENTER)); submitButton = new JButton(" Submit "); submitButton.setToolTipText("Submit your changes!"); submitButton.setFocusPainted(false); submitButton.setFont(new Font("Dialog", 1, 16)); submitButton.setBackground(buttonBackGroundColor); submitButton.setBorder(buttonBorder); submitButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent evt) { submitButtonActionPerformed(evt); } }); thirdPanel.add(submitButton); container.add(thirdPanel); }
public MancalaPanel(LetsPlayMancala game) { // ------------------------------------------------------------------------------ // Import font "Belta Regular" // ----------------------------------------------------------------------------- try { InputStream in = MancalaPanel.class.getResourceAsStream("belta-regular.ttf"); Font font = Font.createFont(Font.TRUETYPE_FONT, in); } catch (Exception ex) { System.out.println("Font couldn't be loaded."); } // ---------------------------------------------------------------------------- // Set background image // ---------------------------------------------------------------------------- imageFile = "/Images/GameBackground.png"; this.game = game; SMALL_PIT_COUNT = 12; setLayout(new BorderLayout()); add(northWindowPanel(), BorderLayout.NORTH); add(westWindowPanel(), BorderLayout.WEST); add(makeBoardPanel(), BorderLayout.CENTER); add(eastWindowPanel(), BorderLayout.EAST); add(southWindowPanel(), BorderLayout.SOUTH); winners = new LinkedStack<String>(); winnersLabel = new JLabel(); resultFrame = new JFrame(); boardResultPanel = new BkImagePanel("/Images/board2.png"); resultNorth = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 50)); resultNorth.setOpaque(false); resultCenter = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0)); resultCenter.setOpaque(false); resultSouth = new JPanel(new FlowLayout(FlowLayout.CENTER, 20, 20)); resultSouth.setOpaque(false); playAgainBtn.setPreferredSize(new Dimension(240, 80)); playAgainBtn.setBackground(new Color(135, 17, 76)); playAgainBtn.setForeground(Color.white); playAgainBtn.setBorder(BorderFactory.createLineBorder(Color.white, 6)); playAgainBtn.setFont(new Font("Belta Regular", Font.BOLD, 40)); playAgainBtn.addActionListener(new ButtonListener()); scoresBtn.setPreferredSize(new Dimension(340, 80)); scoresBtn.setBorder(BorderFactory.createLineBorder(Color.white, 6)); scoresBtn.addActionListener(new ButtonListener()); quitBtn.setPreferredSize(new Dimension(150, 80)); quitBtn.setBorder(BorderFactory.createLineBorder(Color.white, 6)); quitBtn.addActionListener(new ButtonListener()); result = new JLabel(); result.setFont(new Font("Belta Regular", Font.BOLD, 40)); result.setForeground(Color.white); result.setBackground(new Color(0, 158, 121)); result.setBorder(BorderFactory.createLineBorder(Color.white, 6)); result.setOpaque(true); result.setPreferredSize(new Dimension(380, 80)); winnersLabel = new JLabel(); winnersLabel.setFont(new Font("Belta Regular", Font.BOLD, 40)); winnersLabel.setForeground(Color.white); winnersLabel.setPreferredSize(new Dimension(420, 200)); boardResultPanel.setLayout(new BorderLayout(50, 50)); boardResultPanel.setPreferredSize(new Dimension(800, 700)); boardResultPanel.setBackground(Color.yellow); boardResultPanel.add(resultNorth, BorderLayout.NORTH); boardResultPanel.add(resultCenter, BorderLayout.CENTER); boardResultPanel.add(resultSouth, BorderLayout.SOUTH); resultCenter.add(winnersLabel); resultSouth.add(scoresBtn); resultSouth.add(playAgainBtn); resultSouth.add(quitBtn); resultFrame.add(boardResultPanel); }
// // Build installer window // public static void showInstallerWindow() { _installerFrame = new JFrame(Config.getWindowTitle()); Container cont = _installerFrame.getContentPane(); cont.setLayout(new BorderLayout()); // North pane Box topPane = new Box(BoxLayout.X_AXIS); JLabel title = new JLabel(Config.getWindowHeading()); Font titleFont = new Font("SansSerif", Font.BOLD, 22); title.setFont(titleFont); title.setForeground(Color.black); // Create Sun logo URL urlLogo = Main.class.getResource(Config.getWindowLogo()); Image img = Toolkit.getDefaultToolkit().getImage(urlLogo); MediaTracker md = new MediaTracker(_installerFrame); md.addImage(img, 0); try { md.waitForAll(); } catch (Exception ioe) { Config.trace(ioe.toString()); } if (md.isErrorID(0)) Config.trace("Error loading image"); Icon sunLogo = new ImageIcon(img); JLabel logoLabel = new JLabel(sunLogo); logoLabel.setOpaque(true); topPane.add(topPane.createHorizontalStrut(5)); topPane.add(title); topPane.add(topPane.createHorizontalGlue()); topPane.add(logoLabel); topPane.add(topPane.createHorizontalStrut(5)); // West Pane Box westPane = new Box(BoxLayout.X_AXIS); westPane.add(westPane.createHorizontalStrut(10)); // South Pane Box bottomPane = new Box(BoxLayout.X_AXIS); bottomPane.add(bottomPane.createHorizontalGlue()); JButton abortButton = new JButton(Config.getWindowAbortButton()); abortButton.setMnemonic(Config.getWindowAbortMnemonic()); bottomPane.add(abortButton); bottomPane.add(bottomPane.createHorizontalGlue()); bottomPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0)); // Center Pane Box centerPane = new Box(BoxLayout.Y_AXIS); JLabel hidden = new JLabel(Config.getWindowHiddenLabel()); hidden.setVisible(false); centerPane.add(hidden); _stepLabels = new JLabel[5]; for (int i = 0; i < _stepLabels.length; i++) { _stepLabels[i] = new JLabel(Config.getWindowStep(i)); _stepLabels[i].setEnabled(false); centerPane.add(_stepLabels[i]); // install label's length will expand,so set a longer size. if (i == STEP_INSTALL) { Dimension dim = new JLabel(Config.getWindowStepWait(STEP_INSTALL)).getPreferredSize(); _stepLabels[i].setPreferredSize(dim); } } hidden = new JLabel(Config.getWindowHiddenLabel()); hidden.setVisible(false); centerPane.add(hidden); // Setup box layout cont.add(topPane, "North"); cont.add(westPane, "West"); cont.add(bottomPane, "South"); cont.add(centerPane, "Center"); _installerFrame.pack(); Dimension dim = _installerFrame.getSize(); // hard code to ensure title is completely visible on Sol/lin. if (dim.width < 400) { dim.width = 400; _installerFrame.setSize(dim); } Rectangle size = _installerFrame.getBounds(); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); size.width = Math.min(screenSize.width, size.width); size.height = Math.min(screenSize.height, size.height); // Put window at 1/4, 1/4 of screen resoluion _installerFrame.setBounds( (screenSize.width - size.width) / 4, (screenSize.height - size.height) / 4, size.width, size.height); // Setup event listners _installerFrame.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent we) { installFailed("Window closed", null); } }); abortButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ae) { installFailed("Abort pressed", null); } }); // Show window _installerFrame.show(); }