/** Create the frame */ public DateTimer() { super(); setTitle("v14 CountDown"); getContentPane().setLayout(null); setBounds(100, 100, 500, 375); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final JLabel finishtimeLabel = new JLabel(); finishtimeLabel.setText("CountDown Time"); finishtimeLabel.setBounds(10, 36, 119, 15); getContentPane().add(finishtimeLabel); finishtime = new JFormattedTextField( new DateFormatter(new SimpleDateFormat("MM/dd/yyyy hh:mm:ss aa", Locale.ENGLISH))); finishtime.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent e) {} }); finishtime.setValue(new Date()); finishtime.setBounds(135, 34, 187, 19); getContentPane().add(finishtime); final JButton startButton = new JButton(); startButton.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent e) { startCount(); } }); startButton.setText("Start!!!"); startButton.setBounds(334, 31, 111, 25); getContentPane().add(startButton); countLabel = new JLabel(); countLabel.setHorizontalAlignment(SwingConstants.CENTER); countLabel.setHorizontalTextPosition(SwingConstants.CENTER); countLabel.setFont(new Font("Lucida Grande", Font.PLAIN, 14)); countLabel.setBorder(new LineBorder(Color.black, 1, false)); countLabel.setText("Countdown not Started"); countLabel.setBounds(10, 162, 435, 47); getContentPane().add(countLabel); final JLabel credits = new JLabel(); credits.setHorizontalAlignment(SwingConstants.RIGHT); credits.setText(""); credits.setBounds(253, 328, 237, 15); getContentPane().add(credits); }
@NotNull @Override public Component getTableCellRendererComponent( @NotNull JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { final RegistryValue v = ((MyTableModel) table.getModel()).getRegistryValue(row); myLabel.setIcon(null); myLabel.setText(null); myLabel.setHorizontalAlignment(SwingConstants.LEFT); Color fg = isSelected ? table.getSelectionForeground() : table.getForeground(); Color bg = isSelected ? table.getSelectionBackground() : table.getBackground(); if (v != null) { switch (column) { case 0: myLabel.setIcon(v.isRestartRequired() ? RESTART_ICON : null); myLabel.setHorizontalAlignment(SwingConstants.CENTER); break; case 1: myLabel.setText(v.getKey()); break; case 2: if (v.asColor(null) != null) { myLabel.setIcon(createColoredIcon(v.asColor(null))); } else if (v.isBoolean()) { final JCheckBox box = new JCheckBox(); box.setSelected(v.asBoolean()); box.setBackground(bg); return box; } else { myLabel.setText(v.asString()); } } myLabel.setOpaque(true); myLabel.setFont( myLabel.getFont().deriveFont(v.isChangedFromDefault() ? Font.BOLD : Font.PLAIN)); myLabel.setForeground(fg); myLabel.setBackground(bg); } return myLabel; }
public InjectionsSettingsUI(final Project project, final Configuration configuration) { myProject = project; myConfiguration = configuration; final CfgInfo currentInfo = new CfgInfo(configuration, "Project"); myInfos = configuration instanceof Configuration.Prj ? new CfgInfo[] { new CfgInfo(((Configuration.Prj) configuration).getParentConfiguration(), "IDE"), currentInfo } : new CfgInfo[] {currentInfo}; myRoot = new JPanel(new BorderLayout()); myInjectionsTable = new InjectionsTable(getInjInfoList(myInfos)); myInjectionsTable.getEmptyText().setText("No injections configured"); ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myInjectionsTable); createActions(decorator); // myRoot.add(new TitledSeparator("Languages injection places"), BorderLayout.NORTH); myRoot.add(decorator.createPanel(), BorderLayout.CENTER); myCountLabel = new JLabel(); myCountLabel.setHorizontalAlignment(SwingConstants.RIGHT); myCountLabel.setForeground(SimpleTextAttributes.GRAY_ITALIC_ATTRIBUTES.getFgColor()); myRoot.add(myCountLabel, BorderLayout.SOUTH); updateCountLabel(); }
public SplitPaneDemo() { // Create the list of images and put it in a scroll pane. list = new JList(imageNames); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list.setSelectedIndex(0); list.addListSelectionListener(this); JScrollPane listScrollPane = new JScrollPane(list); picture = new JLabel(); picture.setFont(picture.getFont().deriveFont(Font.ITALIC)); picture.setHorizontalAlignment(JLabel.CENTER); JScrollPane pictureScrollPane = new JScrollPane(picture); // Create a split pane with the two scroll panes in it. splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, listScrollPane, pictureScrollPane); splitPane.setOneTouchExpandable(true); splitPane.setDividerLocation(150); // Provide minimum sizes for the two components in the split pane. Dimension minimumSize = new Dimension(100, 50); listScrollPane.setMinimumSize(minimumSize); pictureScrollPane.setMinimumSize(minimumSize); // Provide a preferred size for the split pane. splitPane.setPreferredSize(new Dimension(400, 200)); updateLabel(imageNames[list.getSelectedIndex()]); }
// Initializes this component private void jbInit() { partNameLbl.setFont(Utilities.bigLabelsFont); partNameLbl.setHorizontalAlignment(SwingConstants.CENTER); partNameLbl.setText("keyboard"); partNameLbl.setForeground(Color.black); partNameLbl.setBounds(new Rectangle(62, 10, 102, 21)); this.add(partNameLbl, null); }
private void myDoubleClick(int row, TreePath path) { if (path != null) { JFrame infoFrame = new JFrame("Object Info for: " + path); JLabel objectLabel; JLabel parentPathLabel; // Display Selected Object Name; objectLabel = new JLabel("Object: " + path.getLastPathComponent().toString()); objectLabel.setHorizontalAlignment(SwingConstants.CENTER); // Display specific object information parentPathLabel = new JLabel("Parent Path: " + path.getParentPath()); parentPathLabel.setHorizontalAlignment(SwingConstants.CENTER); // Construct infoFrame infoFrame.getContentPane().add(objectLabel, BorderLayout.CENTER); infoFrame.getContentPane().add(parentPathLabel, BorderLayout.SOUTH); infoFrame.pack(); infoFrame.setVisible(true); } }
// Constructor public Ballot(int index, int ID, int numCandidates, String title, ArrayList<String> candidates) throws IOException { _index = index; _ID = ID; _numCandidates = numCandidates; _votes = new int[_numCandidates]; _title = title; _candidates = candidates; _usrVotes = new String[numCandidates]; // if the ballot file already exists, read in the votes for that ballot // otherwise the number of votes for each candidate will default to 0 file = new File(_ID + ".txt"); if (file.exists()) { Scanner reader = new Scanner(file); int i = 0; while (reader.hasNextLine()) { String strLine = reader.nextLine(); String arrLine[] = strLine.split(":"); int vote = Integer.parseInt(arrLine[1]); _votes[i] = vote; i++; } reader.close(); } _ballotPanel = new JPanel(); _ballotPanel.setLayout(new GridLayout(_candidates.size() + 1, 1)); _titleLabel = new JLabel(_title); _titleLabel.setHorizontalAlignment(JLabel.CENTER); _titleLabel.setFont(new Font("CourierNew", Font.PLAIN, 15)); _ballotPanel.add(_titleLabel); for (int i = 0; i < _candidates.size(); i++) { // Make a JButton for each candidate in the ballot // Disable it by default. Will enable when the user logs in String cText = _candidates.get(i); JButton candidate = new JButton(cText); candidate.setEnabled(false); candidate.addActionListener(_buttonListener); _candidateButtons.add(candidate); _ballotPanel.add(candidate); } }
private void jbInit() throws Exception { titledBorder1 = new TitledBorder(""); this.setLayout(baseLayout); double[][] lower_size = { {TableLayout.PREFERRED, TableLayout.FILL, 25}, {25, 25, TableLayout.FILL} }; mLowerPanelLayout = new TableLayout(lower_size); mLowerPanel.setLayout(mLowerPanelLayout); double[][] dir_size = { {TableLayout.FILL, TableLayout.PREFERRED}, {TableLayout.PREFERRED, TableLayout.FILL} }; mDirectionsPanelLayout = new TableLayout(dir_size); mDirectionsPanel.setLayout(mDirectionsPanelLayout); // Try to get icons for the toolbar buttons try { ClassLoader loader = getClass().getClassLoader(); mAddIcon = new ImageIcon(loader.getResource(COMMON_IMG_ROOT + "/add.gif")); mRemoveIcon = new ImageIcon(loader.getResource(COMMON_IMG_ROOT + "/remove.gif")); mDisabledRemoveIcon = new ImageIcon(loader.getResource(COMMON_IMG_ROOT + "/remove_disabled.gif")); mAddNodeBtn.setIcon(mAddIcon); mRemoveNodeBtn.setIcon(mRemoveIcon); mRemoveNodeBtn.setDisabledIcon(mDisabledRemoveIcon); } catch (Exception e) { // Ack! No icons. Use text labels instead mAddNodeBtn.setText("Add"); mRemoveNodeBtn.setText("Remove"); } /* mAddNodeBtn.setMaximumSize(new Dimension(130, 33)); mAddNodeBtn.setMinimumSize(new Dimension(130, 33)); mAddNodeBtn.setPreferredSize(new Dimension(130, 33)); mAddNodeBtn.setText("Add Node"); */ mAddNodeBtn.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { mAddNodeBtn_actionPerformed(e); } }); /* mRemoveNodeBtn.setMaximumSize(new Dimension(130, 33)); mRemoveNodeBtn.setMinimumSize(new Dimension(130, 33)); mRemoveNodeBtn.setPreferredSize(new Dimension(130, 33)); mRemoveNodeBtn.setText("Remove Node"); */ mRemoveNodeBtn.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { mRemoveNode(); } }); mHostnameLabel.setHorizontalAlignment(SwingConstants.TRAILING); mHostnameLabel.setLabelFor(mHostnameField); mHostnameLabel.setText("Hostname:"); mHostnameField.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { mAddNodeBtn_actionPerformed(e); } }); mDirectionsPanel.setBorder(BorderFactory.createEtchedBorder()); mTitleLabel.setFont(new java.awt.Font("Serif", 1, 20)); mTitleLabel.setHorizontalAlignment(SwingConstants.CENTER); mTitleLabel.setText("Add Cluster Nodes"); mDirectionsLabel.setText("Click on the add button to add nodes to your cluster configuration."); mDirectionsLabel.setLineWrap(true); mDirectionsLabel.setEditable(false); mDirectionsLabel.setBackground(mTitleLabel.getBackground()); baseLayout.setHgap(5); baseLayout.setVgap(5); mLowerPanel.add( mHostnameLabel, new TableLayoutConstraints(0, 0, 0, 0, TableLayout.FULL, TableLayout.FULL)); mLowerPanel.add( mHostnameField, new TableLayoutConstraints(1, 0, 1, 0, TableLayout.FULL, TableLayout.FULL)); mLowerPanel.add( mListScrollPane1, new TableLayoutConstraints(0, 1, 1, 2, TableLayout.FULL, TableLayout.FULL)); mLowerPanel.add( mAddNodeBtn, new TableLayoutConstraints(2, 0, 2, 0, TableLayout.FULL, TableLayout.FULL)); mLowerPanel.add( mRemoveNodeBtn, new TableLayoutConstraints(2, 1, 2, 1, TableLayout.FULL, TableLayout.FULL)); this.add(mLowerPanel, BorderLayout.CENTER); mListScrollPane1.getViewport().add(lstNodes, null); mDirectionsPanel.add( mTitleLabel, new TableLayoutConstraints(0, 0, 0, 0, TableLayout.FULL, TableLayout.FULL)); mDirectionsPanel.add( mDirectionsLabel, new TableLayoutConstraints(0, 1, 0, 1, TableLayout.FULL, TableLayout.FULL)); mDirectionsPanel.add( mIconLabel, new TableLayoutConstraints(1, 0, 1, 1, TableLayout.FULL, TableLayout.FULL)); this.add(mDirectionsPanel, BorderLayout.NORTH); }
/** This method is called from within the constructor to initialize the form. */ public void initComponents() { /** **************** The components ********************************* */ firstPanel = new JPanel(); firstPanel.setBorder(BorderFactory.createEmptyBorder(10, 5, 5, 2)); // If put to False: we see the container's background firstPanel.setOpaque(false); // rows, columns, horizontalGap, verticalGap firstPanel.setLayout(new GridLayout(4, 2, 3, 3)); this.setLayout(new GridLayout(2, 1, 3, 3)); this.add(firstPanel); proxyStackNameLabel = new JLabel("Proxy stack name:"); proxyStackNameLabel.setToolTipText("The name of the stack to set"); // Alignment of the text proxyStackNameLabel.setHorizontalAlignment(AbstractButton.CENTER); // Color of the text proxyStackNameLabel.setForeground(Color.black); // Size of the text proxyStackNameLabel.setFont(new Font("Dialog", 1, 12)); // If put to true: we see the label's background proxyStackNameLabel.setOpaque(true); proxyStackNameLabel.setBackground(ProxyLauncher.labelBackGroundColor); proxyStackNameLabel.setBorder(ProxyLauncher.labelBorder); proxyStackNameTextField = new JTextField(20); proxyStackNameTextField.setHorizontalAlignment(AbstractButton.CENTER); proxyStackNameTextField.setFont(new Font("Dialog", 0, 14)); proxyStackNameTextField.setBackground(ProxyLauncher.textBackGroundColor); proxyStackNameTextField.setForeground(Color.black); proxyStackNameTextField.setBorder(BorderFactory.createLoweredBevelBorder()); firstPanel.add(proxyStackNameLabel); firstPanel.add(proxyStackNameTextField); proxyIPAddressLabel = new JLabel("Proxy IP address:"); proxyIPAddressLabel.setToolTipText("The address of the proxy to set"); // Alignment of the text proxyIPAddressLabel.setHorizontalAlignment(AbstractButton.CENTER); // Color of the text proxyIPAddressLabel.setForeground(Color.black); // Size of the text proxyIPAddressLabel.setFont(new Font("Dialog", 1, 12)); // If put to true: we see the label's background proxyIPAddressLabel.setOpaque(true); proxyIPAddressLabel.setBackground(ProxyLauncher.labelBackGroundColor); proxyIPAddressLabel.setBorder(ProxyLauncher.labelBorder); proxyIPAddressTextField = new JTextField(20); proxyIPAddressTextField.setHorizontalAlignment(AbstractButton.CENTER); proxyIPAddressTextField.setFont(new Font("Dialog", 0, 14)); proxyIPAddressTextField.setBackground(ProxyLauncher.textBackGroundColor); proxyIPAddressTextField.setForeground(Color.black); proxyIPAddressTextField.setBorder(BorderFactory.createLoweredBevelBorder()); firstPanel.add(proxyIPAddressLabel); firstPanel.add(proxyIPAddressTextField); outboundProxyLabel = new JLabel("Next hop (IP:port/protocol):"); outboundProxyLabel.setToolTipText( "Location where the message will be sent " + "if all the resolutions (DNS, router,...) fail. If not set: 404 will be replied"); // Alignment of the text outboundProxyLabel.setHorizontalAlignment(AbstractButton.CENTER); // Color of the text outboundProxyLabel.setForeground(Color.black); // Size of the text outboundProxyLabel.setFont(new Font("Dialog", 1, 12)); // If put to true: we see the label's background outboundProxyLabel.setOpaque(true); outboundProxyLabel.setBackground(ProxyLauncher.labelBackGroundColor); outboundProxyLabel.setBorder(ProxyLauncher.labelBorder); outboundProxyTextField = new JTextField(20); outboundProxyTextField.setHorizontalAlignment(AbstractButton.CENTER); outboundProxyTextField.setFont(new Font("Dialog", 0, 14)); outboundProxyTextField.setBackground(ProxyLauncher.textBackGroundColor); outboundProxyTextField.setForeground(Color.black); outboundProxyTextField.setBorder(BorderFactory.createLoweredBevelBorder()); firstPanel.add(outboundProxyLabel); firstPanel.add(outboundProxyTextField); routerClassLabel = new JLabel("The Router class name:"); routerClassLabel.setToolTipText( "The class name (full java package name) of the router" + " used to forward the messages"); // Alignment of the text routerClassLabel.setHorizontalAlignment(AbstractButton.CENTER); // Color of the text routerClassLabel.setForeground(Color.black); // Size of the text routerClassLabel.setFont(new Font("Dialog", 1, 12)); // If put to true: we see the label's background routerClassLabel.setOpaque(true); routerClassLabel.setBackground(ProxyLauncher.labelBackGroundColor); routerClassLabel.setBorder(ProxyLauncher.labelBorder); routerClassTextField = new JTextField(20); routerClassTextField.setHorizontalAlignment(AbstractButton.CENTER); routerClassTextField.setFont(new Font("Dialog", 0, 12)); routerClassTextField.setBackground(ProxyLauncher.textBackGroundColor); routerClassTextField.setForeground(Color.black); routerClassTextField.setBorder(BorderFactory.createLoweredBevelBorder()); firstPanel.add(routerClassLabel); firstPanel.add(routerClassTextField); JPanel panel = new JPanel(); // top, left, bottom, right panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 2)); // If put to False: we see the container's background panel.setOpaque(false); // rows, columns, horizontalGap, verticalGap panel.setLayout(new BorderLayout()); this.add(panel); JLabel lpLabel = new JLabel("Listening points list:"); lpLabel.setVisible(true); lpLabel.setToolTipText("The listening points of the proxy"); lpLabel.setHorizontalAlignment(AbstractButton.CENTER); lpLabel.setForeground(Color.black); lpLabel.setFont(new Font("Dialog", 1, 12)); lpLabel.setOpaque(true); lpLabel.setBackground(ProxyLauncher.labelBackGroundColor); lpLabel.setBorder(ProxyLauncher.labelBorder); panel.add(lpLabel, BorderLayout.NORTH); // this.add(listeningPointsList); JScrollPane scrollPane = new JScrollPane( listeningPointsList, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); panel.add(scrollPane, BorderLayout.CENTER); thirdPanel = new JPanel(); thirdPanel.setOpaque(false); // top, left, bottom, right thirdPanel.setBorder(BorderFactory.createEmptyBorder(3, 0, 5, 0)); thirdPanel.setLayout(new GridLayout(1, 2, 3, 3)); JButton addLPButton = new JButton(" Add "); addLPButton.setToolTipText("Add a listening point"); addLPButton.setFocusPainted(false); addLPButton.setFont(new Font("Dialog", 1, 16)); addLPButton.setBackground(ProxyLauncher.buttonBackGroundColor); addLPButton.setBorder(ProxyLauncher.buttonBorder); addLPButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent evt) { addLPButtonActionPerformed(evt); } }); thirdPanel.add(addLPButton); JButton removeLPButton = new JButton(" Remove "); removeLPButton.setToolTipText("Remove a listening point"); removeLPButton.setFocusPainted(false); removeLPButton.setFont(new Font("Dialog", 1, 16)); removeLPButton.setBackground(ProxyLauncher.buttonBackGroundColor); removeLPButton.setBorder(ProxyLauncher.buttonBorder); removeLPButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent evt) { removeLPButtonActionPerformed(evt); } }); thirdPanel.add(removeLPButton); panel.add(thirdPanel, BorderLayout.SOUTH); }
public void init() { // <Begin_init> if (getParameter("RESOURCE_PROPERTIES") != null) { localePropertiesFileName = getParameter("RESOURCE_PROPERTIES"); } resourceBundle = com.adventnet.apiutils.Utility.getBundle( localePropertiesFileName, getParameter("RESOURCE_LOCALE"), applet); if (initialized) return; this.setSize(getPreferredSize().width + 495, getPreferredSize().height + 480); setTitle(resourceBundle.getString("ViewConfig")); Container container = getContentPane(); container.setLayout(new BorderLayout()); try { initVariables(); setUpGUI(container); setUpProperties(); setUpConnections(); } catch (Exception ex) { showStatus(resourceBundle.getString("Error in init method"), ex); } // let us set the initialized variable to true so // we dont initialize again even if init is called initialized = true; // <End_init> setTitle(resourceBundle.getString("View Configuration")); setIconImage(AuthMain.getBuilderUiIfInstance().getFrameIcon()); JLabel1.setIcon(AuthMain.getBuilderUiIfInstance().getImage("viewconfig.png")); com.adventnet.security.ui.ViewListCellRenderer ViewListCellRenderer1 = new com.adventnet.security.ui.ViewListCellRenderer(); JTable1.setDefaultRenderer(JTable1.getColumnClass(0), ViewListCellRenderer1); JLabel2.setIcon(AuthMain.getBuilderUiIfInstance().getImage("addview1.png")); JTable1.getCellEditor(0, 0) .getTableCellEditorComponent(JTable1, null, true, 0, 0) .setEnabled(false); DefaultCellEditor te = (DefaultCellEditor) JTable1.getCellEditor(0, 0); te.setClickCountToStart(10); JTable1.setCellEditor(te); JViewport vp = new JViewport(); JLabel lab = new JLabel(resourceBundle.getString("List of available views")); lab.setHorizontalAlignment((int) JLabel.CENTER_ALIGNMENT); lab.setForeground(Color.black); vp.setView(lab); AuthMain.getBuilderUiIfInstance().centerWindow(this); setData(); viewc = this; addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent we) { close(); } }); /* TableColumn col2 = JTable1.getColumnModel().getColumn(1); DefaultTableCellRenderer ren = new DefaultTableCellRenderer(); ren.setIcon(AuthMain.getBuilderUiIfInstance().getImage("task1.png")); col2.setCellRenderer(ren); col2.setMaxWidth(30); */ DefaultListSelectionModel selModel = new DefaultListSelectionModel(); selModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); JTable1.setSelectionModel(selModel); }
private void jbInit() throws Exception { setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); this.setIconImage(icon.getImage()); this.addComponentListener( new java.awt.event.ComponentAdapter() { public void componentShown(ComponentEvent e) { this_componentShown(e); } }); this.getContentPane().setLayout(borderLayout1); this.addWindowListener( new java.awt.event.WindowAdapter() { public void windowClosing(WindowEvent e) { this_windowClosing(e); } }); this.setJMenuBar(menuBar); // This size is chosen so that when the user hits the Info tool, the // window // fits between the lower edge of the TaskFrame and the lower edge of // the // WorkbenchFrame. See the call to #setSize in InfoFrame. [Jon Aquino] setSize(900, 665); // OUTLINE_DRAG_MODE is excruciatingly slow in JDK 1.4.1, so don't use // it. // (although it's supposed to be fixed in 1.4.2, which has not yet been // released). (see Sun Java Bug ID 4665237). [Jon Aquino] // desktopPane.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE); messageLabel.setOpaque(true); memoryLabel.setText("jLabel1"); wmsLabel.setHorizontalAlignment(SwingConstants.LEFT); wmsLabel.setText(" "); this.getContentPane().add(statusPanel, BorderLayout.SOUTH); exitMenuItem.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { exitMenuItem_actionPerformed(e); } }); windowMenu.addMenuListener( new javax.swing.event.MenuListener() { public void menuCanceled(MenuEvent e) {} public void menuDeselected(MenuEvent e) {} public void menuSelected(MenuEvent e) { windowMenu_menuSelected(e); } }); coordinateLabel.setBorder(BorderFactory.createLoweredBevelBorder()); wmsLabel.setBorder(BorderFactory.createLoweredBevelBorder()); coordinateLabel.setText(" "); statusPanel.setLayout(gridBagLayout1); statusPanel.setBorder(BorderFactory.createRaisedBevelBorder()); messageLabel.setBorder(BorderFactory.createLoweredBevelBorder()); messageLabel.setText(" "); timeLabel.setBorder(BorderFactory.createLoweredBevelBorder()); timeLabel.setText(" "); memoryLabel.setBorder(BorderFactory.createLoweredBevelBorder()); memoryLabel.setText(" "); menuBar.add(fileMenu); menuBar.add(windowMenu); getContentPane().add(toolBar, BorderLayout.NORTH); getContentPane().add(desktopPane, BorderLayout.CENTER); fileMenu.addSeparator(); fileMenu.add(exitMenuItem); statusPanel.add( coordinateLabel, new GridBagConstraints( 5, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); statusPanel.add( timeLabel, new GridBagConstraints( 2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); statusPanel.add( messageLabel, new GridBagConstraints( 1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); // Give memoryLabel the 1.0 weight. All the rest should have their // sizes // configured using #configureStatusLabel. [Jon Aquino] statusPanel.add( memoryLabel, new GridBagConstraints( 3, 1, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); statusPanel.add( wmsLabel, new GridBagConstraints( 4, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); }
public IUmenu(String host) { setTitle("GUUERRA_NAVAL"); efectos = new Efectos(); try { cliente = new Cliente(host); } catch (Exception ex) { } /* Titulo */ titulo = new JLabel(" JHONMAN "); titulo.setForeground(Color.BLACK); titulo.setFont(new Font("Algerian", Font.BOLD, 24)); titulo.setBounds(120, 40, 560, 40); titulo.setHorizontalAlignment(JLabel.CENTER); /* MeEnu de Opciones */ mEnU = new JLabel("MENU DE OPCIONES"); mEnU.setForeground(Color.BLACK); mEnU.setFont(new Font("Algerian", Font.BOLD, 24)); mEnU.setBounds(40, 135, 390, 40); mEnU.setHorizontalAlignment(JLabel.LEFT); ImageIcon i = new ImageIcon("imagenes/apariencia/fondo_def.jpg"); fondo = new JLabel(new ImageIcon(i.getImage().getScaledInstance(800, 600, Image.SCALE_SMOOTH))); fondo.setBounds(0, 0, 800, 600); ImageIcon i1 = new ImageIcon("imagenes/apariencia/botRegistrar.jpg"); ImageIcon i2 = new ImageIcon("imagenes/apariencia/botPrincipiante.jpg"); ImageIcon i3 = new ImageIcon("imagenes/apariencia/botDificil.jpg"); ImageIcon i4 = new ImageIcon("imagenes/apariencia/botSalir.jpg"); ImageIcon i5 = new ImageIcon("imagenes/apariencia/botRaking.jpg"); ImageIcon i6 = new ImageIcon("imagenes/apariencia/brJuegoRed2.jpg"); ImageIcon i11 = new ImageIcon("imagenes/apariencia/botRegistrar2.jpg"); ImageIcon i22 = new ImageIcon("imagenes/apariencia/botPrincipiante2.jpg"); ImageIcon i33 = new ImageIcon("imagenes/apariencia/botDificil2.jpg"); ImageIcon i44 = new ImageIcon("imagenes/apariencia/botSalir2.jpg"); ImageIcon i55 = new ImageIcon("imagenes/apariencia/botRaking2.jpg"); ImageIcon i66 = new ImageIcon("imagenes/apariencia/brJuegoRed.jpg"); /* Boton Puntajes */ estad = new JButton(new ImageIcon(i5.getImage().getScaledInstance(170, 40, Image.SCALE_SMOOTH))); estad.setBounds(98, 148, 170, 40); estad.setRolloverIcon( new ImageIcon( i55.getImage() .getScaledInstance( 170, 40, Image .SCALE_SMOOTH))); // cuando el mouse esta sobre el boton cambia a esta // imagen estad.setBorderPainted(false); // elimino los bordes de el boton estad.addActionListener(this); estad.setMnemonic(KeyEvent.VK_P); estad.setToolTipText("ver Raking ALT + P"); /* Boton Registrar */ registrar = new JButton(new ImageIcon(i1.getImage().getScaledInstance(170, 40, Image.SCALE_SMOOTH))); registrar.setBounds(98, 205, 170, 40); registrar.setRolloverIcon( new ImageIcon(i11.getImage().getScaledInstance(170, 40, Image.SCALE_SMOOTH))); registrar.setBorderPainted(false); registrar.addActionListener(this); registrar.setMnemonic(KeyEvent.VK_Q); registrar.setToolTipText("Registrarse ALT + Q"); /* Boton TipoFacil */ facil = new JButton(new ImageIcon(i2.getImage().getScaledInstance(170, 40, Image.SCALE_SMOOTH))); facil.setBounds(97, 262, 170, 40); facil.setRolloverIcon( new ImageIcon(i22.getImage().getScaledInstance(170, 40, Image.SCALE_SMOOTH))); facil.setBorderPainted(false); facil.addActionListener(this); facil.setMnemonic(KeyEvent.VK_F); facil.setToolTipText("jugar en modo principiante ALT + F"); /* Boton TipoDificil */ dific = new JButton(new ImageIcon(i3.getImage().getScaledInstance(170, 40, Image.SCALE_SMOOTH))); dific.setBounds(97, 317, 170, 40); dific.setRolloverIcon( new ImageIcon(i33.getImage().getScaledInstance(170, 40, Image.SCALE_SMOOTH))); dific.setBorderPainted(false); dific.addActionListener(this); dific.setMnemonic(KeyEvent.VK_D); dific.setToolTipText("jugar en modo dificil ALT + D"); /* Boton Salir */ salir = new JButton(new ImageIcon(i4.getImage().getScaledInstance(170, 40, Image.SCALE_SMOOTH))); salir.setBounds(97, 430, 170, 40); salir.setRolloverIcon( new ImageIcon(i44.getImage().getScaledInstance(170, 40, Image.SCALE_SMOOTH))); salir.setBorderPainted(false); salir.addActionListener(this); salir.setMnemonic(KeyEvent.VK_S); salir.setToolTipText("Salir ALT + S"); /* Boton Red */ red = new JButton(new ImageIcon(i6.getImage().getScaledInstance(170, 40, Image.SCALE_SMOOTH))); red.setBounds(97, 374, 170, 40); red.setRolloverIcon( new ImageIcon(i66.getImage().getScaledInstance(170, 40, Image.SCALE_SMOOTH))); red.setBorderPainted(false); red.addActionListener(this); red.setMnemonic(KeyEvent.VK_C); red.setToolTipText("Jugar con varios jugadores ALT + C"); c = getContentPane(); c.setLayout(null); c.add(titulo); c.add(estad); c.add(facil); c.add(registrar); c.add(dific); c.add(salir); c.add(red); c.add(fondo); }
public CellarGUI(Cellar model) { this.model = model; setTitle("Cellar"); setSize(new Dimension(1000, 600)); setResizable(false); setDefaultCloseOperation(EXIT_ON_CLOSE); setLayout(new BorderLayout()); health.setPreferredSize(new Dimension(200, 10)); exp.setPreferredSize(new Dimension(200, 10)); currentRoom.setPreferredSize(new Dimension(200, 10)); spacer.setPreferredSize(new Dimension(200, 115)); magicLabel.setPreferredSize(new Dimension(200, 10)); magicLabel.setHorizontalAlignment(JLabel.CENTER); playerItemLabel.setText("Player's Items (Max 1)"); setLabels(); JScrollPane playerItemsPane = new JScrollPane(); playerItemsList.setListData(model.getPlayer().getItemList().toArray()); playerItemsPane.setViewportView(playerItemsList); playerItemsPane.setPreferredSize(new Dimension(200, 125)); JButton drop = new JButton("Drop Item"); drop.addActionListener(this); drop.setPreferredSize(new Dimension(200, 25)); JScrollPane roomItemsPane = new JScrollPane(); roomItemsList = new JList(getRoomItems()); roomItemsPane.setViewportView(roomItemsList); roomItemsPane.setPreferredSize(new Dimension(200, 125)); JButton pickUp = new JButton("Pick Up"); pickUp.addActionListener(this); pickUp.setPreferredSize(new Dimension(200, 25)); JScrollPane hallsPane = new JScrollPane(); hallList = new JList(getHalls()); hallsPane.setViewportView(hallList); hallsPane.setPreferredSize(new Dimension(200, 200)); JButton enterHall = new JButton("Enter Hallway"); enterHall.setPreferredSize(new Dimension(200, 25)); enterHall.addActionListener(this); JScrollPane outputPane = new JScrollPane(); output = new JTextArea(); outputPane.setPreferredSize(new Dimension(550, 550)); output.setEditable(false); output.setBorder(BorderFactory.createLineBorder(Color.black)); outputPane.setViewportView(output); JLabel roomItemLabel = new JLabel("Items in the Room"); JLabel hallsLabel = new JLabel("Hallways"); JPanel rightPanel = new JPanel(); JPanel leftPanel = new JPanel(); rightPanel.add(playerItemLabel); rightPanel.add(playerItemsPane); rightPanel.add(drop); rightPanel.add(roomItemLabel); rightPanel.add(roomItemsPane); rightPanel.add(pickUp); rightPanel.add(magicLabel); rightPanel.add(magic); rightPanel.add(spacer); rightPanel.add(health); rightPanel.add(exp); rightPanel.add(currentRoom); rightPanel.setPreferredSize(new Dimension(200, 600)); rightPanel.setBackground(Color.WHITE); leftPanel.add(hallsLabel); leftPanel.add(hallsPane); leftPanel.add(enterHall); leftPanel.setPreferredSize(new Dimension(200, 600)); leftPanel.setBackground(Color.WHITE); add(outputPane, BorderLayout.CENTER); add(rightPanel, BorderLayout.WEST); add(leftPanel, BorderLayout.EAST); }
private void initComponents() { dialogPane = new JPanel(); contentPanel = new JPanel(); scrollPane1 = new JScrollPane(); table = new JTable(); filterPanel = new JPanel(); filterLabel = new JLabel(); filterTextField = new JTextField(); rowCountLabel = new JLabel(); buttonBar = new JPanel(); okButton = new JButton(); cancelButton = new JButton(); getRootPane().setDefaultButton(okButton); final String filterToolTip = "Enter multiple filter strings separated by commas. e.g. GM12878, ChipSeq"; filterLabel.setToolTipText(filterToolTip); filterTextField.setToolTipText(filterToolTip); // ======== this ======== Container contentPane = getContentPane(); contentPane.setLayout(new BorderLayout()); // ======== dialogPane ======== dialogPane.setBorder(new EmptyBorder(12, 12, 12, 12)); dialogPane.setLayout(new BorderLayout()); // ======== contentPanel ======== contentPanel.setLayout(new BorderLayout(0, 10)); // ======== scrollPane1 ======== scrollPane1.setViewportView(table); contentPanel.add(scrollPane1, BorderLayout.CENTER); // ======== panel1 ======== filterPanel.setLayout(new JideBoxLayout(filterPanel, JideBoxLayout.X_AXIS, 5)); // ---- label1 ---- filterLabel.setText("Filter:"); filterPanel.add(filterLabel, JideBoxLayout.FIX); // ---- filterTextField ---- filterPanel.add(filterTextField, JideBoxLayout.VARY); rowCountLabel.setHorizontalAlignment(JLabel.RIGHT); JPanel sillyPanel = new JPanel(); sillyPanel.setLayout(new JideBoxLayout(sillyPanel, JideBoxLayout.X_AXIS, 0)); sillyPanel.setPreferredSize(new Dimension(100, 28)); sillyPanel.add(rowCountLabel, JideBoxLayout.VARY); filterPanel.add(sillyPanel, JideBoxLayout.FIX); contentPanel.add(filterPanel, BorderLayout.NORTH); dialogPane.add(contentPanel, BorderLayout.CENTER); // ======== buttonBar ======== buttonBar.setBorder(new EmptyBorder(12, 0, 0, 0)); buttonBar.setLayout(new GridBagLayout()); ((GridBagLayout) buttonBar.getLayout()).columnWidths = new int[] {0, 85, 80}; ((GridBagLayout) buttonBar.getLayout()).columnWeights = new double[] {1.0, 0.0, 0.0}; // ---- okButton ---- okButton.setText("Load"); okButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { loadButtonActionPerformed(e); } }); buttonBar.add( okButton, new GridBagConstraints( 1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 5), 0, 0)); // ---- cancelButton ---- cancelButton.setText("Cancel"); cancelButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { cancelButtonActionPerformed(e); } }); buttonBar.add( cancelButton, new GridBagConstraints( 2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); dialogPane.add(buttonBar, BorderLayout.SOUTH); contentPane.add(dialogPane, BorderLayout.CENTER); setSize(700, 620); setLocationRelativeTo(getOwner()); }
public LogDateChooser(String label) { thisDialog = this; border = new EtchedBorder(); setBorder(border); Font f = new Font("Helvetica", Font.PLAIN, 10); title = new JLabel(label); add(title); setLayout(new DateLayout()); dfs = new DateFormatSymbols(); months = dfs.getMonths(); weekdays = dfs.getShortWeekdays(); for (int i = 0; i < 7; i++) { days[i] = new JLabel(weekdays[i + 1]); days[i].setFont(f); add(days[i]); } gc = new GregorianCalendar(); mDown = new JButton("<"); mDown.setMargin(new Insets(0, 0, 0, 0)); mDown.addActionListener(new MDownEar()); mDown.setBorderPainted(false); mDown.setFont(f); mDown.setForeground(Color.BLUE); add(mDown); mUp = new JButton(">"); mUp.setMargin(new Insets(0, 0, 0, 0)); mUp.addActionListener(new MUpEar()); mUp.setBorderPainted(false); mUp.setFont(f); mUp.setForeground(Color.BLUE); add(mUp); month = new JLabel(months[gc.get(Calendar.MONTH)]); month.setHorizontalAlignment(SwingConstants.CENTER); month.setFont(f); add(month); year = new JLabel(new Integer(gc.get(Calendar.YEAR)).toString()); year.setFont(f); add(year); yDown = new JButton("<"); yDown.setMargin(new Insets(0, 0, 0, 0)); yDown.addActionListener(new YDownEar()); yDown.setBorderPainted(false); yDown.setFont(f); yDown.setForeground(Color.BLUE); add(yDown); yUp = new JButton(">"); yUp.setMargin(new Insets(0, 0, 0, 0)); yUp.addActionListener(new YUpEar()); yUp.setBorderPainted(false); yUp.setFont(f); yUp.setForeground(Color.BLUE); add(yUp); // System.out.println(year.getText()); NumberEar numberEar = new NumberEar(); for (int i = 0; i < 31; i++) { number[i] = new JButton(new Integer(i + 1).toString()); number[i].setMargin(new Insets(0, 0, 0, 0)); number[i].addActionListener(numberEar); number[i].setBorderPainted(false); number[i].setContentAreaFilled(false); number[i].setFont(f); number[i].setForeground(Color.BLUE); add(number[i]); } number[0].setForeground(Color.CYAN); }
void jbInit() throws Exception { panel1.setLayout(borderLayout1); jPanel1.setBorder(BorderFactory.createEtchedBorder()); jPanel1.setPreferredSize(new Dimension(14, 100)); jPanel1.setLayout(borderLayout2); jPanel2.setBorder(BorderFactory.createEtchedBorder()); jPanel2.setPreferredSize(new Dimension(10, 40)); jPanel2.setLayout(gridBagLayout1); jLabel2.setText("Oznaka banke:"); bPronadji.setPreferredSize(new java.awt.Dimension(80, 27)); bPronadji.setText("Pronadji "); bPronadji.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { bPronadji_actionPerformed(e); } }); bIzlaz.setPreferredSize(new Dimension(80, 27)); bIzlaz.setText("Izlaz"); bIzlaz.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { bIzlaz_actionPerformed(e); } }); txtOznakaBanke.setPreferredSize(new Dimension(120, 21)); getContentPane().add(panel1); panel1.add(jPanel1, BorderLayout.NORTH); { jLabel1 = new JLabel(); jPanel1.add(jLabel1, BorderLayout.CENTER); jLabel1.setText("PREGLED FILIJALA BANKE"); jLabel1.setFont(new java.awt.Font("Times New Roman", 1, 18)); jLabel1.setPreferredSize(new java.awt.Dimension(588, 96)); jLabel1.setHorizontalTextPosition(SwingConstants.CENTER); jLabel1.setHorizontalAlignment(SwingConstants.CENTER); jLabel1.setVerticalAlignment(SwingConstants.TOP); { jLabel3 = new JLabel(); jLabel1.add(jLabel3); jLabel3.setText("NAZIV:"); jLabel3.setBounds(7, 49, 42, 28); jLabel3.setFont(new java.awt.Font("Times New Roman", 1, 12)); } { jLabel4 = new JLabel(); jLabel1.add(jLabel4); jLabel4.setText("ADRESA:"); jLabel4.setBounds(280, 49, 63, 28); jLabel4.setFont(new java.awt.Font("Times New Roman", 1, 12)); } { jLnazivBanke = new JLabel(); jLabel1.add(jLnazivBanke); jLnazivBanke.setBounds(56, 49, 203, 28); } { jLadresaBanke = new JLabel(); jLabel1.add(jLadresaBanke); jLadresaBanke.setBounds(336, 49, 238, 28); } } panel1.add(jPanel2, BorderLayout.SOUTH); jPanel2.add( jLabel2, new GridBagConstraints( 0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jPanel2.add( txtOznakaBanke, new GridBagConstraints( 1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 10, 0, 0), 0, 0)); jPanel2.add( bPronadji, new GridBagConstraints( 5, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 10, 0, 0), 0, 0)); jPanel2.add( bIzlaz, new GridBagConstraints( 5, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 200, 0, 0), 0, 0)); panel1.add(jScrollPane1, BorderLayout.CENTER); jScrollPane1.getViewport().add(tabBanke, null); TModelPrijave tMP = new TModelPrijave(tabBanke); tabBanke.setModel(tMP); ((TModelPrijave) tabBanke.getModel()).initColumns(); }
/** Instantiates a new game panel. */ public GamePanel() { super(); setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); CARD_BACK.add(new CardPanel("img/cards/BACK.png")); // The code below is just for reference // dealerCards = new ArrayList<>(); // for (int i = 0; i < dealerInHand.size(); i++) // { // dealerCards.add(new CardPanel("img/cards/" + dealerInHand.get(i) + ".png")); // } // // playerCardsOne = new ArrayList<>(); // for (int i = 0; i < playerInHandOne.size(); i++) // { // playerCardsOne.add(new CardPanel("img/cards/" + playerInHandOne.get(i) + ".png")); // } // // playerCardsTwo = new ArrayList<>(); // for (int i = 0; i < playerInHandTwo.size(); i++) // { // playerCardsTwo.add(new CardPanel("img/cards/" + playerInHandTwo.get(i) + ".png")); // } // The code above is just for reference dealerDeckContainer = new CardDeckContainer(); dealerStatContainer = new JPanel(new BorderLayout()); dealerStatContainer.setOpaque(false); JLabel dealerStatTitle = new JLabel("Dealer in Hand"); dealerStatTitle.setForeground(Color.WHITE); dealerStatTitle.setHorizontalAlignment(JLabel.CENTER); dealerStatTitle.setFont(new Font("", Font.PLAIN, 12)); dealerStatPoint.setForeground(Color.WHITE); dealerStatPoint.setHorizontalAlignment(JLabel.CENTER); dealerStatPoint.setFont(new Font("", Font.PLAIN, 12)); dealerStatContainer.add(dealerStatTitle, BorderLayout.NORTH); dealerStatContainer.add(dealerStatPoint, BorderLayout.CENTER); playerDeckOneContainer = new CardDeckContainer(); playerStatOneContainer = new JPanel(new BorderLayout()); playerStatOneContainer.setOpaque(false); JLabel playerStatOneTitle = new JLabel("Player in Hand"); playerStatOneTitle.setForeground(Color.WHITE); playerStatOneTitle.setHorizontalAlignment(JLabel.CENTER); playerStatOneTitle.setFont(new Font("", Font.PLAIN, 12)); playerStatOnePoint.setForeground(Color.WHITE); playerStatOnePoint.setHorizontalAlignment(JLabel.CENTER); playerStatOnePoint.setFont(new Font("", Font.PLAIN, 12)); playerStatOneDescription.setForeground(Color.WHITE); playerStatOneDescription.setHorizontalAlignment(JLabel.CENTER); playerStatOneDescription.setFont(new Font("", Font.BOLD, 12)); playerStatOneContainer.add(playerStatOneTitle, BorderLayout.NORTH); playerStatOneContainer.add(playerStatOnePoint, BorderLayout.CENTER); playerStatOneContainer.add(playerStatOneDescription, BorderLayout.SOUTH); playerDeckTwoContainer = new CardDeckContainer(new CardDeckPanel(CARD_BACK)); playerStatTwoContainer = new JPanel(new BorderLayout()); playerStatTwoContainer.setOpaque(false); JLabel playerStatTwoTitle = new JLabel("Player Hand 2"); playerStatTwoTitle.setForeground(Color.WHITE); playerStatTwoTitle.setHorizontalAlignment(JLabel.CENTER); playerStatTwoTitle.setFont(new Font("", Font.PLAIN, 12)); playerStatTwoPoint.setForeground(Color.WHITE); playerStatTwoPoint.setHorizontalAlignment(JLabel.CENTER); playerStatTwoPoint.setFont(new Font("", Font.PLAIN, 12)); playerStatTwoDescription.setForeground(Color.WHITE); playerStatTwoDescription.setHorizontalAlignment(JLabel.CENTER); playerStatTwoDescription.setFont(new Font("", Font.BOLD, 12)); playerStatTwoContainer.add(playerStatTwoTitle, BorderLayout.NORTH); playerStatTwoContainer.add(playerStatTwoPoint, BorderLayout.CENTER); playerStatTwoContainer.add(playerStatTwoDescription, BorderLayout.SOUTH); gameStatPanel = new JPanel(); gameStatPanelPlayerName = new JLabel(); gameStatPanelCurrentChips = new JLabel(); gameStatPanelCurrentBet = new JLabel(); gameStatPanelPlayerName.setFont(new Font("", Font.PLAIN, 14)); gameStatPanelPlayerName.setForeground(Color.WHITE); gameStatPanelPlayerName.setBorder(new EmptyBorder(0, 0, 0, 5)); gameStatPanelCurrentChips.setFont(new Font("", Font.PLAIN, 14)); gameStatPanelCurrentChips.setForeground(Color.WHITE); gameStatPanelCurrentChips.setBorder(new EmptyBorder(0, 5, 0, 5)); gameStatPanelCurrentBet.setFont(new Font("", Font.PLAIN, 14)); gameStatPanelCurrentBet.setForeground(Color.WHITE); gameStatPanelCurrentBet.setBorder(new EmptyBorder(0, 5, 0, 0)); gameStatPanel.add(gameStatPanelPlayerName); gameStatPanel.add(gameStatPanelCurrentChips); gameStatPanel.add(gameStatPanelCurrentBet); gameStatPanel.setOpaque(false); gameButtonPanel = new JPanel(cardLayout); betButtonPanel = new JPanel(); playButtonPanel = new JPanel(); JLabel pleaseBet = new JLabel("Please bet: "); pleaseBet.setFont(new Font("", Font.PLAIN, 14)); pleaseBet.setForeground(Color.WHITE); betButtonPanel.add(pleaseBet); betField = new JTextField(); betField.setFont(new Font("", Font.PLAIN, 14)); betField.setPreferredSize(new Dimension(80, 28)); betButtonPanel.add(betField); JButton betButton = new JButton("Bet"); JButton backButton = new JButton("Back"); betButtonPanel.add(betButton); betButtonPanel.add(backButton); betButtonPanel.setOpaque(false); hitButton = new JButton("Hit"); standButton = new JButton("Stand"); doubleButton = new JButton("Double"); // JButton splitButton = new JButton("Split"); // splitButton.setEnabled(false); playButtonPanel.add(hitButton); playButtonPanel.add(standButton); playButtonPanel.add(doubleButton); // playButtonPanel.add(splitButton); playButtonPanel.setOpaque(false); gameButtonPanel.add("betbutton", betButtonPanel); gameButtonPanel.add("playbutton", playButtonPanel); gameButtonPanel.setOpaque(false); add(gameStatPanel); add(dealerDeckContainer); add(playerDeckTwoContainer); add(playerDeckOneContainer); add(gameButtonPanel); this.addComponentListener( new ComponentAdapter() { @Override public void componentShown(ComponentEvent e) { Game.initGame(); } }); betButtonPanel.addComponentListener( new ComponentAdapter() { @Override public void componentShown(ComponentEvent e) { betField.setText(""); if (BlackJack.player.getChip() <= 0) { JOptionPane.showMessageDialog( null, "You are penniless!", "Information", JOptionPane.INFORMATION_MESSAGE); User.deleteUserByName(BlackJack.player.getName()); BlackJack.player = new Player(true); BlackJack.dealer = new Player(false); BlackjackFrame.cardLayout.show(getParent(), "welcome"); } hitButton.setEnabled(true); standButton.setEnabled(true); doubleButton.setEnabled(true); BlackJack.player.setBet(0); BlackJack.player.getHandOne().clear(); BlackJack.player.getHandTwo().clear(); BlackJack.dealer.getHandOne().clear(); GamePanel.gameStatPanelPlayerName.setText("Player: " + BlackJack.player.getName()); GamePanel.gameStatPanelCurrentChips.setText("Chips: " + BlackJack.player.getChip()); GamePanel.gameStatPanelCurrentBet.setText("Bet: 0"); GamePanel.gameStatPanel.repaint(); } }); betField.addKeyListener( new KeyAdapter() { @Override public void keyTyped(KeyEvent e) { int keyChar = e.getKeyChar(); if (keyChar < KeyEvent.VK_0 || keyChar > KeyEvent.VK_9) { e.consume(); } } }); betButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Game.bet(Integer.parseInt(betField.getText())); } }); backButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int choice = JOptionPane.showConfirmDialog( null, "Do you want to go back to main menu?\nYour record will be saved.", "Go Back", JOptionPane.YES_NO_OPTION); if (choice == JOptionPane.YES_OPTION) { User.updateUser(); BlackJack.player = new Player(true); BlackJack.dealer = new Player(false); BlackjackFrame.cardLayout.show(getParent(), "welcome"); } } }); hitButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doubleButton.setEnabled(false); Game.hit(); } }); standButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { hitButton.setEnabled(false); standButton.setEnabled(false); doubleButton.setEnabled(false); playerStatOneDescription.setText("Stand"); playerStatOneDescription.repaint(); Game.dealerGame(); } }); doubleButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { hitButton.setEnabled(false); standButton.setEnabled(false); doubleButton.setEnabled(false); if (!Game.doubleDown()) { hitButton.setEnabled(true); standButton.setEnabled(true); doubleButton.setEnabled(false); } } }); }
/** Construct the toolbar panel. */ protected JPanel getToolbar() { JPanel toolbar = new JPanel(); getExecuteButton().setText("Execute*"); getExecuteButton() .addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { removeStatsTabs(); execute(); } }); JButton statsButton = new JButton("Calc Stats"); statsButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { Window owner = (Window) getTopLevelAncestor(); new WatchedProcess(owner) { public void watch() { calcStats(); } }; } }); Box b1 = Box.createVerticalBox(); b1.add(getParamsPanel()); b1.add(Box.createVerticalStrut(10)); Box b2 = Box.createHorizontalBox(); b2.add(Box.createGlue()); b2.add(getExecuteButton()); b1.add(b2); b1.add(Box.createVerticalStrut(10)); if (getAlgorithmRunner().getDataModel() instanceof DataSet) { Box b3 = Box.createHorizontalBox(); b3.add(Box.createGlue()); b3.add(statsButton); b1.add(b3); } // if (getAlgorithmRunner().getParams() instanceof MeekSearchParams) { // MeekSearchParams params = (MeekSearchParams) getAlgorithmRunner().getParams(); // JCheckBox preventCycles = new JCheckBox("Aggressively Prevent Cycles"); // preventCycles.setHorizontalTextPosition(AbstractButton.RIGHT); // preventCycles.setSelected(params.isAggressivelyPreventCycles()); // // preventCycles.addActionListener(new ActionListener() { // public void actionPerformed(ActionEvent e) { // JCheckBox box = (JCheckBox) e.getSource(); // MeekSearchParams params = (MeekSearchParams) // getAlgorithmRunner().getParams(); // params.setAggressivelyPreventCycles(box.isSelected()); // } // }); // // b1.add(Box.createVerticalStrut(5)); // Box hBox = Box.createHorizontalBox(); // hBox.add(Box.createHorizontalGlue()); // hBox.add(preventCycles); // b1.add(hBox); // b1.add(Box.createVerticalStrut(5)); // } Box b4 = Box.createHorizontalBox(); JLabel label = new JLabel( "<html>" + "*Please note that some" + "<br>searches may take a" + "<br>long time to complete." + "</html>"); label.setHorizontalAlignment(SwingConstants.CENTER); label.setVerticalAlignment(SwingConstants.CENTER); label.setBorder(new TitledBorder("")); b4.add(label); b1.add(Box.createVerticalStrut(10)); b1.add(b4); toolbar.add(b1); return toolbar; }