{ setLayout(new GridBagLayout()); // Elrendezés beállítása GridBagConstraints c = new GridBagConstraints(); // Szükséges konstans JLabel lbUsername = new JLabel("Felhasználónév"); // A felhasználónév címkéje JLabel lbPassword = new JLabel("Jelszó"); // A jelszó címkéje lbUsername.setIcon(RM.getUsernameIcon()); // "felhasználónév" címke Ikonjának beállítása lbPassword.setIcon(RM.getPasswordIcon()); // "Jelszó" címke Ikonjának beállítása lbUsername.setPreferredSize(new Dimension(120, 25)); // Címke átméretezése lbPassword.setPreferredSize(new Dimension(120, 25)); // Címke átméretezése // [0,0] c.gridx = 0; // oszlop c.gridy = 0; // sor add(lbUsername, c); // a "Felhasználónév" címke hozzáadása // [1,0] c.gridx = 1; add(tfUsername, c); // A "felhasználónév" szövegmező hozzáadása // [0,1] c.gridx = 0; c.gridy = 1; add(lbPassword, c); // A "Jelszó" címke hozzáadása // [1,1] c.gridx = 1; c.gridy = 1; add(pfPassword, c); // A "jelszó" jelszómező hozzáadása }
public ComboBoxDemo() { super(new BorderLayout()); String[] petStrings = {"Bird", "Cat", "Dog", "Rabbit", "Pig"}; // Create the combo box, select the item at index 4. // Indices start at 0, so 4 specifies the pig. JComboBox petList = new JComboBox(petStrings); petList.setSelectedIndex(4); petList.addActionListener(this); // Set up the picture. picture = new JLabel(); picture.setFont(picture.getFont().deriveFont(Font.ITALIC)); picture.setHorizontalAlignment(JLabel.CENTER); updateLabel(petStrings[petList.getSelectedIndex()]); picture.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); // The preferred size is hard-coded to be the width of the // widest image and the height of the tallest image + the border. // A real program would compute this. picture.setPreferredSize(new Dimension(177, 122 + 10)); // Lay out the demo. add(petList, BorderLayout.PAGE_START); add(picture, BorderLayout.PAGE_END); setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); }
// Initializes this component. private void jbInit() { segmentTable.addFocusListener( new FocusListener() { public void focusGained(FocusEvent e) { segmentTable_focusGained(e); } public void focusLost(FocusEvent e) { segmentTable_focusLost(e); } }); segmentTable.setTableHeader(null); scrollPane = new JScrollPane(segmentTable); scrollPane.setMinimumSize(new Dimension(getTableWidth(), 0)); setLayout(new BorderLayout(0, 0)); determineColumnWidth(); nameLbl.setPreferredSize(new Dimension(getTableWidth(), 25)); nameLbl.setMinimumSize(new Dimension(getTableWidth(), 0)); nameLbl.setFont(Utilities.labelsFont); segmentTable.setFont(Utilities.valueFont); setBorder(BorderFactory.createEtchedBorder()); setMinimumSize(new Dimension(getTableWidth(), 0)); this.add(nameLbl, BorderLayout.NORTH); this.add(scrollPane, BorderLayout.CENTER); }
private static void createAndShowGUI() { JFrame fr = new JFrame("Test"); JLabel label = new JLabel("picture"); label.setPreferredSize(new Dimension(500, 500)); spane = new JScrollPane(label); fr.getContentPane().add(spane); sbar = spane.getVerticalScrollBar(); fr.setSize(200, 200); fr.setVisible(true); }
Project2_Square_Thompson(int y, int x, Project2_BoardView_Thompson b) { super(); this.x = x; this.y = y; bv = b; if (((x + y) % 2) == 0) setBackground(Color.white); else setBackground(Color.gray); setPreferredSize(new Dimension(42, 42)); jl = new JLabel(); jl.setPreferredSize(new Dimension(32, 32)); add(jl); addMouseListener(new SquareMouseListener()); }
@Override public Component getListCellRendererComponent( JList<? extends Color> list, Color value, int index, boolean isSelected, boolean cellHasFocus) { JLabel renderer = (JLabel) defaultRenderer_.getListCellRendererComponent( list, value, index, isSelected, cellHasFocus); renderer.setBackground(value); renderer.setText(""); renderer.setPreferredSize(preferredSize_); return renderer; }
public Mode(int x, int y) { this.setSize(x, y); try { intro = new ImageIcon("introScreen.jpg"); } catch (Exception e) { } m1.setPreferredSize(new Dimension(150, 40)); m2.setPreferredSize(new Dimension(150, 40)); back.setPreferredSize(new Dimension(80, 40)); l.setPreferredSize(new Dimension(150, 100)); l.setFont(new Font("Serif", Font.BOLD, 60)); l.setForeground(Color.yellow); m1.addActionListener(this); m2.addActionListener(this); back.addActionListener(this); this.setLayout(new FlowLayout(FlowLayout.CENTER, this.getWidth(), 100)); this.add(l); this.add(m1); this.add(m2); this.add(back); }
public ColorChooserDemo() { super(new BorderLayout()); // 设置一个标签,做广告的。也用来显示用户选择的颜色。 banner = new JLabel("欢迎使用颜色选择器!", JLabel.CENTER); banner.setForeground(Color.yellow); banner.setBackground(Color.blue); banner.setOpaque(true); banner.setFont(new Font("SansSerif", Font.BOLD, 24)); banner.setPreferredSize(new Dimension(100, 65)); JPanel bannerPanel = new JPanel(new BorderLayout()); bannerPanel.add(banner, BorderLayout.CENTER); bannerPanel.setBorder(BorderFactory.createTitledBorder("广告")); // 设置选择颜色选择器 tcc = new JColorChooser(banner.getForeground()); // 设置初始颜色 tcc.getSelectionModel().addChangeListener(this); // 给所有模式添加监听 tcc.setBorder(BorderFactory.createTitledBorder("选择颜色")); add(bannerPanel, BorderLayout.CENTER); add(tcc, BorderLayout.PAGE_END); }
public Difficulty(int x, int y) { this.setSize(x, y); try { intro = new ImageIcon("introScreen.jpg"); } catch (Exception e) { } easy.setPreferredSize(new Dimension(100, 40)); medium.setPreferredSize(new Dimension(100, 40)); hard.setPreferredSize(new Dimension(100, 40)); back.setPreferredSize(new Dimension(80, 40)); l.setPreferredSize(new Dimension(250, 100)); l.setFont(new Font("Serif", Font.BOLD, 50)); l.setForeground(Color.yellow); easy.addActionListener(this); medium.addActionListener(this); hard.addActionListener(this); back.addActionListener(this); this.setLayout(new FlowLayout(FlowLayout.CENTER, this.getWidth(), 75)); this.add(l); this.add(easy); this.add(medium); this.add(hard); this.add(back); }
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(); }
private void init(Font font) { JPanel content = new JPanel(new BorderLayout()); content.setBorder(new EmptyBorder(12, 12, 12, 12)); setContentPane(content); JPanel listPanel = new JPanel(new GridLayout(1, 3, 6, 6)); String[] fonts; try { fonts = getFontList(); } catch (Exception e) { Log.log(Log.ERROR, this, "Broken Java implementation!"); Log.log(Log.ERROR, this, e); fonts = new String[] {"Broken Java implementation!"}; } JPanel familyPanel = createTextFieldAndListPanel( "font-selector.family", familyField = new JTextField(), familyList = new JList(fonts)); listPanel.add(familyPanel); String[] sizes = {"9", "10", "12", "14", "16", "18", "24"}; JPanel sizePanel = createTextFieldAndListPanel( "font-selector.size", sizeField = new JTextField(), sizeList = new JList(sizes)); listPanel.add(sizePanel); String[] styles = { jEdit.getProperty("font-selector.plain"), jEdit.getProperty("font-selector.bold"), jEdit.getProperty("font-selector.italic"), jEdit.getProperty("font-selector.bolditalic") }; JPanel stylePanel = createTextFieldAndListPanel( "font-selector.style", styleField = new JTextField(), styleList = new JList(styles)); styleField.setEditable(false); listPanel.add(stylePanel); familyList.setSelectedValue(font.getFamily(), true); familyField.setText(font.getFamily()); sizeList.setSelectedValue(String.valueOf(font.getSize()), true); sizeField.setText(String.valueOf(font.getSize())); styleList.setSelectedIndex(font.getStyle()); styleField.setText((String) styleList.getSelectedValue()); ListHandler listHandler = new ListHandler(); familyList.addListSelectionListener(listHandler); sizeList.addListSelectionListener(listHandler); styleList.addListSelectionListener(listHandler); content.add(BorderLayout.NORTH, listPanel); preview = new JLabel(jEdit.getProperty("font-selector.long-text")) { public void paintComponent(Graphics g) { if (fontSelector != null) fontSelector.setAntiAliasEnabled(g); super.paintComponent(g); } }; preview.setBorder(new TitledBorder(jEdit.getProperty("font-selector.preview"))); updatePreview(); Dimension prefSize = preview.getPreferredSize(); prefSize.height = 50; preview.setPreferredSize(prefSize); content.add(BorderLayout.CENTER, preview); JPanel buttons = new JPanel(); buttons.setLayout(new BoxLayout(buttons, BoxLayout.X_AXIS)); buttons.setBorder(new EmptyBorder(12, 0, 0, 0)); buttons.add(Box.createGlue()); ok = new JButton(jEdit.getProperty("common.ok")); ok.addActionListener(new ActionHandler()); getRootPane().setDefaultButton(ok); buttons.add(ok); buttons.add(Box.createHorizontalStrut(6)); cancel = new JButton(jEdit.getProperty("common.cancel")); cancel.addActionListener(new ActionHandler()); buttons.add(cancel); buttons.add(Box.createGlue()); content.add(BorderLayout.SOUTH, buttons); pack(); setLocationRelativeTo(getParent()); setVisible(true); }
/** * Creates the <tt>Component</tt> hierarchy of the central area of this <tt>CallPeerPanel</tt> * which displays the photo of the <tt>CallPeer</tt> or the video if any. */ private VideoContainer createCenter() { photoLabel.setPreferredSize(new Dimension(90, 90)); return createVideoContainer(photoLabel); }
private JComponent buildTopPanel(boolean enablePipette) throws ParseException { final JPanel result = new JPanel(new BorderLayout()); final JPanel previewPanel = new JPanel(new BorderLayout()); if (enablePipette && myPicker != null) { final JButton pipette = new JButton(); pipette.setUI(new BasicButtonUI()); pipette.setRolloverEnabled(true); pipette.setIcon(AllIcons.Ide.Pipette); pipette.setBorder(IdeBorderFactory.createEmptyBorder()); pipette.setRolloverIcon(AllIcons.Ide.Pipette_rollover); pipette.setFocusable(false); pipette.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { myPicker.setInitialColor(getColor()); myPicker.show(); } }); previewPanel.add(pipette, BorderLayout.WEST); } myPreviewComponent = new ColorPreviewComponent(); previewPanel.add(myPreviewComponent, BorderLayout.CENTER); result.add(previewPanel, BorderLayout.NORTH); final JPanel rgbPanel = new JPanel(); rgbPanel.setLayout(new BoxLayout(rgbPanel, BoxLayout.X_AXIS)); if (!UIUtil.isUnderAquaLookAndFeel()) { myR_after.setPreferredSize(new Dimension(14, -1)); myG_after.setPreferredSize(new Dimension(14, -1)); myB_after.setPreferredSize(new Dimension(14, -1)); } rgbPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); rgbPanel.add(myR); rgbPanel.add(myRed); if (!UIUtil.isUnderAquaLookAndFeel()) rgbPanel.add(myR_after); rgbPanel.add(Box.createHorizontalStrut(2)); rgbPanel.add(myG); rgbPanel.add(myGreen); if (!UIUtil.isUnderAquaLookAndFeel()) rgbPanel.add(myG_after); rgbPanel.add(Box.createHorizontalStrut(2)); rgbPanel.add(myB); rgbPanel.add(myBlue); if (!UIUtil.isUnderAquaLookAndFeel()) rgbPanel.add(myB_after); rgbPanel.add(Box.createHorizontalStrut(2)); rgbPanel.add(myFormat); result.add(rgbPanel, BorderLayout.WEST); final JPanel hexPanel = new JPanel(); hexPanel.setLayout(new BoxLayout(hexPanel, BoxLayout.X_AXIS)); hexPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); hexPanel.add(new JLabel("#")); hexPanel.add(myHex); result.add(hexPanel, BorderLayout.EAST); return result; }
private void flushWeekAndDayPanal(Calendar c) { // c.set c.set(Calendar.DAY_OF_MONTH, 1); c.setFirstDayOfWeek(0); int firstdayofWeek = c.get(Calendar.DAY_OF_WEEK); int lastdayofWeek = c.getActualMaximum(Calendar.DAY_OF_MONTH); String colname[] = {"日", "一", "二", "三", "四", "五", "六"}; int today = getNowCalendar().get(Calendar.DAY_OF_MONTH); // 璁剧疆鍥哄畾瀛椾綋锛屼互鍏嶈皟鐢ㄧ幆澧冩敼鍙樺奖鍝嶇晫闈㈢編瑙� dayPanel.setFont(new java.awt.Font("寰蒋闆呴粦", java.awt.Font.PLAIN, 12)); dayPanel.setLayout(new GridBagLayout()); dayPanel.setBackground(palletTableColor); JLabel cell; for (int i = 0; i < 7; i++) { cell = new JLabel(colname[i]); cell.setHorizontalAlignment(JLabel.CENTER); cell.setPreferredSize(new Dimension(25, 25)); if (i == 0 || i == 6) { cell.setForeground(weekendFontColor); } else { cell.setForeground(weekFontColor); } dayPanel.add( cell, new GridBagConstraints( i, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); } int actionCommandId = 1; for (int i = 0; i < 6; i++) { for (int j = 0; j < 7; j++) { JButton numberButton = daysButton[i][j]; actionCommandId = Integer.parseInt(numberButton.getActionCommand()); if (actionCommandId == today) { numberButton.setBackground(todayBtnColor); } if ((actionCommandId + firstdayofWeek - 2) % 7 == 6 || (actionCommandId + firstdayofWeek - 2) % 7 == 0) { numberButton.setForeground(weekendFontColor); } else { numberButton.setForeground(dateFontColor); } if (actionCommandId <= lastdayofWeek) { int y = 0; if ((firstdayofWeek - 1) <= (j + firstdayofWeek - 1) % 7) { y = i + 1; } else { y = i + 2; } dayPanel.add( numberButton, new GridBagConstraints( (j + firstdayofWeek - 1) % 7, y, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); } } } }
/** Create GUI elements */ private void loadGUI() { setTitle("Wifi QRCode Generator"); mainPanel = new JPanel(); BoxLayout vBoxLayout = new BoxLayout(mainPanel, BoxLayout.Y_AXIS); mainPanel.setLayout(vBoxLayout); int LABEL_WIDTH = 100; int LABEL_HEIGHT = 30; int EDIT_WIDTH = 200; int EDIT_HEIGHT = 30; // guide label { // This layout simply makes label looks left-alignmented JPanel barPanel = new JPanel(); BoxLayout barHLayout = new BoxLayout(barPanel, BoxLayout.X_AXIS); barPanel.setLayout(barHLayout); JLabel ssoGuideLabel = new JLabel("Enter your SSO and click button below to login"); ssoGuideLabel.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 15)); barPanel.add(ssoGuideLabel); mainPanel.add(barPanel); } Font gFont = new Font(Font.SANS_SERIF, Font.PLAIN, 13); Config config = Config.instance(); // email password remember password { JPanel userPanel = new JPanel(); BoxLayout hBoxLayout = new BoxLayout(userPanel, BoxLayout.X_AXIS); userPanel.setLayout(hBoxLayout); JLabel emailLabel = new JLabel("Email:"); Dimension labelDimension = new Dimension(LABEL_WIDTH, LABEL_HEIGHT); emailLabel.setMinimumSize(labelDimension); emailLabel.setPreferredSize(labelDimension); emailLabel.setMaximumSize(labelDimension); userPanel.add(emailLabel); userPanel.add(Box.createRigidArea(new Dimension(5, 0))); emailField = new TextField(); emailField.setMinimumSize(new Dimension(EDIT_WIDTH, EDIT_HEIGHT)); emailField.setMaximumSize(new Dimension(EDIT_WIDTH + 300, EDIT_HEIGHT)); emailField.setFont(gFont); emailField.setText(config.getEmail()); userPanel.add(emailField); mainPanel.add(userPanel); JPanel passwordPanel = new JPanel(); BoxLayout hBoxLayout2 = new BoxLayout(passwordPanel, BoxLayout.X_AXIS); passwordPanel.setLayout(hBoxLayout2); JLabel passwordLabel = new JLabel("SSO Password:"******"Remember password", false); rememberPasswordCheckbox.setState(config.getRememberPassword()); mainPanel.add(rememberPasswordCheckbox); mainPanel.add(Box.createHorizontalGlue()); } JPanel centerPanel = new JPanel(); BorderLayout bLayout = new BorderLayout(); centerPanel.setLayout(bLayout); buttonGetPassword = new JButton(idleButtonText); Font font = new Font(Font.SERIF, Font.BOLD, 18); buttonGetPassword.setFont(font); buttonGetPassword.setMinimumSize(new Dimension(300, 50)); buttonGetPassword.setPreferredSize(new Dimension(300, 50)); buttonGetPassword.setMaximumSize(new Dimension(300, 50)); centerPanel.add(buttonGetPassword, BorderLayout.CENTER); hintLabel = new JLabel("Enter your SSO and click button to start"); hintLabel.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 15)); centerPanel.add(hintLabel, BorderLayout.SOUTH); mainPanel.add(centerPanel); wifiPasswordField = new TextField("Wifi password has not been generated"); mainPanel.add(wifiPasswordField); JPanel qrCenterPanel = new JPanel(); BorderLayout bLayout2 = new BorderLayout(); qrCenterPanel.setLayout(bLayout2); qrCodeLabel = new JLabel(""); qrCodeLabel.setMinimumSize(new Dimension(400, 400)); qrCodeLabel.setPreferredSize(new Dimension(400, 400)); qrCodeLabel.setMaximumSize(new Dimension(400, 400)); qrCodeLabel.setHorizontalAlignment(JLabel.CENTER); qrCodeLabel.setVerticalAlignment(JLabel.CENTER); qrCodeLabel.setIcon(idleIcon); qrCenterPanel.add(qrCodeLabel, BorderLayout.CENTER); mainPanel.add(qrCenterPanel); // client download section { Font clientFont = new Font(Font.SANS_SERIF, Font.BOLD, 15); Dimension clientDimension = new Dimension(200, 30); JPanel clientPanel = new JPanel(); BorderLayout cp_bLayout = new BorderLayout(); clientPanel.setLayout(cp_bLayout); HyberLinkLabel androidLabel = new HyberLinkLabel( " [ Android Client ] ", "https://github.com/tangyanhan/ClrGstAutoLogin-/blob/master/ClrGstAutoConnect/bin/ClrGstAutoConnect.apk"); androidLabel.setMinimumSize(clientDimension); androidLabel.setFont(clientFont); clientPanel.add(androidLabel, BorderLayout.WEST); HyberLinkLabel iosLabel = new HyberLinkLabel(" [ iOS Client ] ", ""); iosLabel.setMinimumSize(clientDimension); iosLabel.setFont(clientFont); clientPanel.add(iosLabel, BorderLayout.EAST); mainPanel.add(clientPanel); } add(mainPanel); this.pack(); this.setVisible(true); this.setLocation(300, 100); this.setSize(500, 730); buttonGetPassword.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { long elapsed = Calendar.getInstance().getTimeInMillis() - lastClickTime; // If we got the successfull password 5 minutes ago if (((elapsed / 1000) / 60) < 5) { hintLabel.setText("Take a rest! You have got the QR code already!"); return; } fetchPassword(); if (!Config.instance().getWifiPassword().isEmpty()) lastClickTime = Calendar.getInstance().getTimeInMillis(); } }); }
/** Constructor (create and layout page) */ public SOAPMonitorPage(String host_name) { host = host_name; // Set up default filter (show all messages) filter = new SOAPMonitorFilter(); // Use borders to help improve appearance etched_border = new EtchedBorder(); // Build top portion of split (list panel) model = new SOAPMonitorTableModel(); table = new JTable(model); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.setRowSelectionInterval(0, 0); table.setPreferredScrollableViewportSize(new Dimension(600, 96)); table.getSelectionModel().addListSelectionListener(this); scroll = new JScrollPane(table); remove_button = new JButton("Remove"); remove_button.addActionListener(this); remove_button.setEnabled(false); remove_all_button = new JButton("Remove All"); remove_all_button.addActionListener(this); filter_button = new JButton("Filter ..."); filter_button.addActionListener(this); list_buttons = new JPanel(); list_buttons.setLayout(new FlowLayout()); list_buttons.add(remove_button); list_buttons.add(remove_all_button); list_buttons.add(filter_button); list_panel = new JPanel(); list_panel.setLayout(new BorderLayout()); list_panel.add(scroll, BorderLayout.CENTER); list_panel.add(list_buttons, BorderLayout.SOUTH); list_panel.setBorder(empty_border); // Build bottom portion of split (message details) details_time = new JLabel("Time: ", SwingConstants.RIGHT); details_target = new JLabel("Target Service: ", SwingConstants.RIGHT); details_status = new JLabel("Status: ", SwingConstants.RIGHT); details_time_value = new JLabel(); details_target_value = new JLabel(); details_status_value = new JLabel(); Dimension preferred_size = details_time.getPreferredSize(); preferred_size.width = 1; details_time.setPreferredSize(preferred_size); details_target.setPreferredSize(preferred_size); details_status.setPreferredSize(preferred_size); details_time_value.setPreferredSize(preferred_size); details_target_value.setPreferredSize(preferred_size); details_status_value.setPreferredSize(preferred_size); details_header = new JPanel(); details_header_layout = new GridBagLayout(); details_header.setLayout(details_header_layout); details_header_constraints = new GridBagConstraints(); details_header_constraints.fill = GridBagConstraints.BOTH; details_header_constraints.weightx = 0.5; details_header_layout.setConstraints(details_time, details_header_constraints); details_header.add(details_time); details_header_layout.setConstraints(details_time_value, details_header_constraints); details_header.add(details_time_value); details_header_layout.setConstraints(details_target, details_header_constraints); details_header.add(details_target); details_header_constraints.weightx = 1.0; details_header_layout.setConstraints(details_target_value, details_header_constraints); details_header.add(details_target_value); details_header_constraints.weightx = .5; details_header_layout.setConstraints(details_status, details_header_constraints); details_header.add(details_status); details_header_layout.setConstraints(details_status_value, details_header_constraints); details_header.add(details_status_value); details_header.setBorder(etched_border); request_label = new JLabel("SOAP Request", SwingConstants.CENTER); request_text = new SOAPMonitorTextArea(); request_text.setEditable(false); request_scroll = new JScrollPane(request_text); request_panel = new JPanel(); request_panel.setLayout(new BorderLayout()); request_panel.add(request_label, BorderLayout.NORTH); request_panel.add(request_scroll, BorderLayout.CENTER); response_label = new JLabel("SOAP Response", SwingConstants.CENTER); response_text = new SOAPMonitorTextArea(); response_text.setEditable(false); response_scroll = new JScrollPane(response_text); response_panel = new JPanel(); response_panel.setLayout(new BorderLayout()); response_panel.add(response_label, BorderLayout.NORTH); response_panel.add(response_scroll, BorderLayout.CENTER); details_soap = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); details_soap.setTopComponent(request_panel); details_soap.setRightComponent(response_panel); details_soap.setResizeWeight(.5); details_panel = new JPanel(); layout_button = new JButton("Switch Layout"); layout_button.addActionListener(this); reflow_xml = new JCheckBox("Reflow XML text"); reflow_xml.addActionListener(this); details_buttons = new JPanel(); details_buttons.setLayout(new FlowLayout()); details_buttons.add(reflow_xml); details_buttons.add(layout_button); details_panel.setLayout(new BorderLayout()); details_panel.add(details_header, BorderLayout.NORTH); details_panel.add(details_soap, BorderLayout.CENTER); details_panel.add(details_buttons, BorderLayout.SOUTH); details_panel.setBorder(empty_border); // Add the two parts to the age split pane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT); split.setTopComponent(list_panel); split.setRightComponent(details_panel); // Build status area start_button = new JButton("Start"); start_button.addActionListener(this); stop_button = new JButton("Stop"); stop_button.addActionListener(this); status_buttons = new JPanel(); status_buttons.setLayout(new FlowLayout()); status_buttons.add(start_button); status_buttons.add(stop_button); status_text = new JLabel(); status_text.setBorder(new BevelBorder(BevelBorder.LOWERED)); status_text_panel = new JPanel(); status_text_panel.setLayout(new BorderLayout()); status_text_panel.add(status_text, BorderLayout.CENTER); status_text_panel.setBorder(empty_border); status_area = new JPanel(); status_area.setLayout(new BorderLayout()); status_area.add(status_buttons, BorderLayout.WEST); status_area.add(status_text_panel, BorderLayout.CENTER); status_area.setBorder(etched_border); // Add the split and status area to page setLayout(new BorderLayout()); add(split, BorderLayout.CENTER); add(status_area, BorderLayout.SOUTH); }
/** * Create me * * @param persistenceManager A reference to the persistence manager in case we need it * @param label The label to use in the dialog title */ public LoadBundleDialog(IdvPersistenceManager persistenceManager, String label) { dialogTitle = label; label = null; this.persistenceManager = persistenceManager; msgLabel1 = new JLabel(" "); msgLabel1.setMinimumSize(new Dimension(250, 20)); msgLabel1.setPreferredSize(new Dimension(250, 20)); msgLabel2 = new JLabel(" "); msgLabel2.setMinimumSize(new Dimension(250, 20)); msgLabel2.setPreferredSize(new Dimension(250, 20)); progressBar = new RovingProgress(); progressBar.start(); progressBar.setBorder(BorderFactory.createLineBorder(Color.gray)); JLabel waitLbl = new JLabel(IdvWindow.getWaitIcon()); ActionListener buttonListener = new ActionListener() { public void actionPerformed(ActionEvent ae) { removeItems = true; // removeItems = ae.getActionCommand().equals(CMD_CANCELANDREMOVE); okToRun = false; setMessage("Cancelling load. Please wait..."); Misc.runInABit( 2000, new Runnable() { public void run() { dispose(); } }); } }; // String[] cmds = { CMD_CANCELANDREMOVE, GuiUtils.CMD_CANCEL }; String[] cmds = {GuiUtils.CMD_CANCEL}; // String[] tts = { "Press to cancel and remove any loaded items", // "Press to cancel" }; String[] tts = {"Press to cancel and remove loaded items"}; JPanel buttonPanel = GuiUtils.makeButtons(buttonListener, cmds, cmds, tts, null); GuiUtils.tmpInsets = GuiUtils.INSETS_2; JComponent labelComp = GuiUtils.doLayout( new Component[] { new JLabel("Status:"), msgLabel1, waitLbl, GuiUtils.filler(), msgLabel2, GuiUtils.filler() }, 3, GuiUtils.WT_NYN, GuiUtils.WT_N); contents = GuiUtils.inset(labelComp, 5); if (label != null) { contents = GuiUtils.topCenter(GuiUtils.cLabel("Loading: " + label), contents); } // contents = GuiUtils.vbox(contents, // GuiUtils.inset(progressBar, 5), // buttonPanel); contents = GuiUtils.vbox(contents, buttonPanel); }
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); }
protected void initComponents() { int border = 6; this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); this.setBorder( new CompoundBorder( BorderFactory.createEmptyBorder(9, 9, 9, 9), new TitledBorder("Download"))); this.setToolTipText("Layer imagery bulk download."); final JPanel locationPanel = new JPanel(new BorderLayout(5, 5)); JLabel locationLabel = new JLabel(" Cache:"); final JLabel locationName = new JLabel(""); JButton locationButton = new JButton("..."); locationPanel.add(locationLabel, BorderLayout.WEST); locationPanel.add(locationName, BorderLayout.CENTER); locationPanel.add(locationButton, BorderLayout.EAST); this.add(locationPanel); locationButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser fc = new JFileChooser(); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); fc.setMultiSelectionEnabled(false); int status = fc.showOpenDialog(locationPanel); if (status == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); if (file != null) { locationName.setText(file.getPath()); cache = new BasicDataFileStore(file); updateRetrievablePanels(selector.getSector()); } } } }); // Select sector button JPanel sectorPanel = new JPanel(new GridLayout(0, 1, 0, 0)); sectorPanel.setBorder(BorderFactory.createEmptyBorder(border, border, border, border)); selectButton = new JButton("Select sector"); selectButton.setToolTipText("Press Select then press and drag button 1 on globe"); selectButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { selectButtonActionPerformed(event); } }); sectorPanel.add(selectButton); sectorLabel = new JLabel("-"); sectorLabel.setPreferredSize(new Dimension(350, 16)); sectorLabel.setHorizontalAlignment(JLabel.CENTER); sectorPanel.add(sectorLabel); this.add(sectorPanel); // Retrievable list combo and start button JPanel retrievablesPanel = new JPanel(); retrievablesPanel.setLayout(new BoxLayout(retrievablesPanel, BoxLayout.Y_AXIS)); retrievablesPanel.setBorder(BorderFactory.createEmptyBorder(border, border, border, border)); // RetrievablePanel list for (JPanel panel : this.retrievables) { retrievablesPanel.add(panel); } this.add(retrievablesPanel); // Start button JPanel startPanel = new JPanel(new GridLayout(0, 1, 0, 0)); startPanel.setBorder(BorderFactory.createEmptyBorder(border, border, border, border)); startButton = new JButton("Start download"); startButton.setEnabled(false); startButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { startButtonActionPerformed(event); } }); startPanel.add(startButton); this.add(startPanel); // Download monitor panel monitorPanel = new JPanel(); monitorPanel.setLayout(new BoxLayout(monitorPanel, BoxLayout.Y_AXIS)); monitorPanel.setBorder(BorderFactory.createEmptyBorder(border, border, border, border)); // this.add(monitorPanel); // Put the monitor panel in a scroll pane. JPanel dummyPanel = new JPanel(new BorderLayout()); dummyPanel.add(monitorPanel, BorderLayout.NORTH); JScrollPane scrollPane = new JScrollPane(dummyPanel); scrollPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); scrollPane.setPreferredSize(new Dimension(350, 200)); this.add(scrollPane); }