public SidebarOption(String labelTxt, String rsc) { label = new JLabel(labelTxt); label.setForeground(Color.WHITE); label.setFont(font); add(label); setOpaque(false); setMaximumSize(new Dimension(1000, label.getPreferredSize().height + 5)); this.rsc = ClassLoader.getSystemClassLoader().getResource(rsc); }
// --------------------------------initGUI------------------------------------ public void initGUI() { bDeployed = bOpponentDeployed = false; listAT = new LinkedList(); frame.setJMenuBar(new GameMenuBar(this)); panParty = new PartyPanel(200, 480); panStatus = new JPanel(null); oMap = new Map(600, 350); panChat = new ChatPanel(600, 200); Container contentPane = frame.getContentPane(); panParty.setOpaque(true); panStatus.setOpaque(true); panChat.setOpaque(true); panStatus.setPreferredSize(new Dimension(200, 70)); contentPane.add(panStatus); contentPane.add(panParty); contentPane.add(oMap); contentPane.add(panChat); SpringLayout oLayout = new SpringLayout(); contentPane.setLayout(oLayout); oLayout.putConstraint(SpringLayout.WEST, panParty, 0, SpringLayout.WEST, contentPane); oLayout.putConstraint(SpringLayout.NORTH, panParty, 0, SpringLayout.NORTH, contentPane); oLayout.putConstraint(SpringLayout.WEST, panStatus, 0, SpringLayout.WEST, contentPane); oLayout.putConstraint(SpringLayout.SOUTH, panStatus, 0, SpringLayout.SOUTH, contentPane); oLayout.putConstraint(SpringLayout.EAST, oMap, 0, SpringLayout.EAST, contentPane); oLayout.putConstraint(SpringLayout.NORTH, oMap, 0, SpringLayout.NORTH, contentPane); oLayout.putConstraint(SpringLayout.WEST, panChat, 0, SpringLayout.EAST, panStatus); oLayout.putConstraint(SpringLayout.NORTH, panChat, 0, SpringLayout.SOUTH, oMap); oLayout.putConstraint(SpringLayout.EAST, contentPane, 0, SpringLayout.EAST, panChat); oLayout.putConstraint(SpringLayout.SOUTH, contentPane, 0, SpringLayout.SOUTH, panChat); panChat.validate(); panChat.setVisible(true); Insets oInsets = panStatus.getInsets(); int nX = oInsets.left + 5; int nY = oInsets.top + 5; lblStatus1 = new JLabel("Not Connected..."); lblStatus2 = new JLabel("No Party Formed..."); lblStatus3 = new JLabel(); Dimension oSize = lblStatus1.getPreferredSize(); lblStatus1.setBounds(nX, nY, 180, oSize.height); nY += oSize.height + 7; lblStatus2.setBounds(nX, nY, 180, oSize.height); nY += oSize.height + 7; lblStatus3.setBounds(nX, nY, 180, oSize.height); panStatus.add(lblStatus1); panStatus.add(lblStatus2); panStatus.add(lblStatus3); frame.pack(); frame.setResizable(false); frame.setLocation( ((scrBounds.x + scrBounds.width - frame.getWidth()) / 2), ((scrBounds.y + scrBounds.height - frame.getHeight()) / 2)); oMap.addKeyListener(oMap); oMap.setButtonEvents(this); }
protected boolean exportApplicationPrompt() throws IOException, SketchException { JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); panel.add(Box.createVerticalStrut(6)); // Box panel = Box.createVerticalBox(); // Box labelBox = Box.createHorizontalBox(); // String msg = "<html>Click Export to Application to create a standalone, " + // "double-clickable application for the selected plaforms."; // String msg = "Export to Application creates a standalone, \n" + // "double-clickable application for the selected plaforms."; String line1 = "Export to Application creates double-clickable,"; String line2 = "standalone applications for the selected plaforms."; JLabel label1 = new JLabel(line1, SwingConstants.CENTER); JLabel label2 = new JLabel(line2, SwingConstants.CENTER); label1.setAlignmentX(Component.LEFT_ALIGNMENT); label2.setAlignmentX(Component.LEFT_ALIGNMENT); // label1.setAlignmentX(); // label2.setAlignmentX(0); panel.add(label1); panel.add(label2); int wide = label2.getPreferredSize().width; panel.add(Box.createVerticalStrut(12)); final JCheckBox windowsButton = new JCheckBox("Windows"); // windowsButton.setMnemonic(KeyEvent.VK_W); windowsButton.setSelected(Preferences.getBoolean("export.application.platform.windows")); windowsButton.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { Preferences.setBoolean( "export.application.platform.windows", windowsButton.isSelected()); } }); final JCheckBox macosxButton = new JCheckBox("Mac OS X"); // macosxButton.setMnemonic(KeyEvent.VK_M); macosxButton.setSelected(Preferences.getBoolean("export.application.platform.macosx")); macosxButton.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { Preferences.setBoolean("export.application.platform.macosx", macosxButton.isSelected()); } }); final JCheckBox linuxButton = new JCheckBox("Linux"); // linuxButton.setMnemonic(KeyEvent.VK_L); linuxButton.setSelected(Preferences.getBoolean("export.application.platform.linux")); linuxButton.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { Preferences.setBoolean("export.application.platform.linux", linuxButton.isSelected()); } }); JPanel platformPanel = new JPanel(); // platformPanel.setLayout(new BoxLayout(platformPanel, BoxLayout.X_AXIS)); platformPanel.add(windowsButton); platformPanel.add(Box.createHorizontalStrut(6)); platformPanel.add(macosxButton); platformPanel.add(Box.createHorizontalStrut(6)); platformPanel.add(linuxButton); platformPanel.setBorder(new TitledBorder("Platforms")); // Dimension goodIdea = new Dimension(wide, platformPanel.getPreferredSize().height); // platformPanel.setMaximumSize(goodIdea); wide = Math.max(wide, platformPanel.getPreferredSize().width); platformPanel.setAlignmentX(Component.LEFT_ALIGNMENT); panel.add(platformPanel); // Box indentPanel = Box.createHorizontalBox(); // indentPanel.add(Box.createHorizontalStrut(new JCheckBox().getPreferredSize().width)); final JCheckBox showStopButton = new JCheckBox("Show a Stop button"); // showStopButton.setMnemonic(KeyEvent.VK_S); showStopButton.setSelected(Preferences.getBoolean("export.application.stop")); showStopButton.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { Preferences.setBoolean("export.application.stop", showStopButton.isSelected()); } }); showStopButton.setEnabled(Preferences.getBoolean("export.application.fullscreen")); showStopButton.setBorder(new EmptyBorder(3, 13, 6, 13)); // indentPanel.add(showStopButton); // indentPanel.setAlignmentX(Component.LEFT_ALIGNMENT); final JCheckBox fullScreenButton = new JCheckBox("Full Screen (Present mode)"); // fullscreenButton.setMnemonic(KeyEvent.VK_F); fullScreenButton.setSelected(Preferences.getBoolean("export.application.fullscreen")); fullScreenButton.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { boolean sal = fullScreenButton.isSelected(); Preferences.setBoolean("export.application.fullscreen", sal); showStopButton.setEnabled(sal); } }); fullScreenButton.setBorder(new EmptyBorder(3, 13, 3, 13)); JPanel optionPanel = new JPanel(); optionPanel.setLayout(new BoxLayout(optionPanel, BoxLayout.Y_AXIS)); optionPanel.add(fullScreenButton); optionPanel.add(showStopButton); // optionPanel.add(indentPanel); optionPanel.setBorder(new TitledBorder("Options")); wide = Math.max(wide, platformPanel.getPreferredSize().width); // goodIdea = new Dimension(wide, optionPanel.getPreferredSize().height); optionPanel.setAlignmentX(Component.LEFT_ALIGNMENT); // optionPanel.setMaximumSize(goodIdea); panel.add(optionPanel); Dimension good; // label1, label2, platformPanel, optionPanel good = new Dimension(wide, label1.getPreferredSize().height); label1.setMaximumSize(good); good = new Dimension(wide, label2.getPreferredSize().height); label2.setMaximumSize(good); good = new Dimension(wide, platformPanel.getPreferredSize().height); platformPanel.setMaximumSize(good); good = new Dimension(wide, optionPanel.getPreferredSize().height); optionPanel.setMaximumSize(good); // JPanel actionPanel = new JPanel(); // optionPanel.setLayout(new BoxLayout(optionPanel, BoxLayout.X_AXIS)); // optionPanel.add(Box.createHorizontalGlue()); // final JDialog frame = new JDialog(editor, "Export to Application"); // JButton cancelButton = new JButton("Cancel"); // cancelButton.addActionListener(new ActionListener() { // public void actionPerformed(ActionEvent e) { // frame.dispose(); // return false; // } // }); // Add the buttons in platform-specific order // if (PApplet.platform == PConstants.MACOSX) { // optionPanel.add(cancelButton); // optionPanel.add(exportButton); // } else { // optionPanel.add(exportButton); // optionPanel.add(cancelButton); // } String[] options = {"Export", "Cancel"}; final JOptionPane optionPane = new JOptionPane( panel, JOptionPane.PLAIN_MESSAGE, // JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION, null, options, options[0]); final JDialog dialog = new JDialog(this, "Export Options", true); dialog.setContentPane(optionPane); optionPane.addPropertyChangeListener( new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { String prop = e.getPropertyName(); if (dialog.isVisible() && (e.getSource() == optionPane) && (prop.equals(JOptionPane.VALUE_PROPERTY))) { // If you were going to check something // before closing the window, you'd do // it here. dialog.setVisible(false); } } }); dialog.pack(); dialog.setResizable(false); Rectangle bounds = getBounds(); dialog.setLocation( bounds.x + (bounds.width - dialog.getSize().width) / 2, bounds.y + (bounds.height - dialog.getSize().height) / 2); dialog.setVisible(true); Object value = optionPane.getValue(); if (value.equals(options[0])) { return jmode.handleExportApplication(sketch); } else if (value.equals(options[1]) || value.equals(new Integer(-1))) { // closed window by hitting Cancel or ESC statusNotice("Export to Application canceled."); } return false; }
/** 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); }
void createFrame() { /* see Preferences.java */ int GUI_BIG = 13; int GUI_BETWEEN = 10; int GUI_SMALL = 6; int FIELD_SIZE = 30; int left = GUI_BIG; int top = GUI_BIG; int right = 0; Dimension d; frame = new JFrame("Directives Editor"); Container pane = frame.getContentPane(); pane.setLayout(null); JLabel label = new JLabel("Click here to read about directives."); label.addMouseListener( new MouseListener() { public void mouseClicked(MouseEvent e) { Base.openURL("http://processingjs.org/reference/pjs%20directive"); } public void mouseEntered(MouseEvent e) {} public void mouseExited(MouseEvent e) {} public void mousePressed(MouseEvent e) {} public void mouseReleased(MouseEvent e) {} }); pane.add(label); d = label.getPreferredSize(); label.setBounds(left, top, d.width, d.height); top += d.height + GUI_BETWEEN + GUI_BETWEEN; // CRISP crispBox = new JCheckBox("\"crisp\": disable antialiasing for line(), triangle() and rect()"); pane.add(crispBox); d = crispBox.getPreferredSize(); crispBox.setBounds(left, top, d.width + 10, d.height); right = Math.max(right, left + d.width); top += d.height + GUI_BETWEEN; // FONTS label = new JLabel("\"font\": to load (comma separated)"); pane.add(label); d = label.getPreferredSize(); label.setBounds(left, top, d.width, d.height); top += d.height + GUI_SMALL; fontField = new JTextField(FIELD_SIZE); pane.add(fontField); d = fontField.getPreferredSize(); fontField.setBounds(left, top, d.width, d.height); JButton button = new JButton("scan"); button.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { handleScanFonts(); } }); pane.add(button); Dimension d2 = button.getPreferredSize(); button.setBounds(left + d.width + GUI_SMALL, top, d2.width, d2.height); right = Math.max(right, left + d.width + GUI_SMALL + d2.width); top += d.height + GUI_BETWEEN; // GLOBAL_KEY_EVENTS globalKeyEventsBox = new JCheckBox("\"globalKeyEvents\": receive global key events"); pane.add(globalKeyEventsBox); d = globalKeyEventsBox.getPreferredSize(); globalKeyEventsBox.setBounds(left, top, d.width + 10, d.height); right = Math.max(right, left + d.width); top += d.height + GUI_BETWEEN; // PAUSE_ON_BLUR pauseOnBlurBox = new JCheckBox("\"pauseOnBlur\": pause if applet loses focus"); pane.add(pauseOnBlurBox); d = pauseOnBlurBox.getPreferredSize(); pauseOnBlurBox.setBounds(left, top, d.width + 10, d.height); right = Math.max(right, left + d.width); top += d.height + GUI_BETWEEN; // PRELOAD images label = new JLabel("\"preload\": images (comma separated)"); pane.add(label); d = label.getPreferredSize(); label.setBounds(left, top, d.width, d.height); top += d.height + GUI_SMALL; preloadField = new JTextField(FIELD_SIZE); pane.add(preloadField); d = preloadField.getPreferredSize(); preloadField.setBounds(left, top, d.width, d.height); button = new JButton("scan"); button.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { handleScanImages(); } }); pane.add(button); d2 = button.getPreferredSize(); button.setBounds(left + d.width + GUI_SMALL, top, d2.width, d2.height); right = Math.max(right, left + d.width + GUI_SMALL + d2.width); top += d.height + GUI_BETWEEN; // TRANSPARENT /*transparentBox = new JCheckBox("\"transparent\": set applet background to be transparent"); pane.add(transparentBox); d = transparentBox.getPreferredSize(); transparentBox.setBounds(left, top, d.width + 10, d.height); right = Math.max(right, left + d.width); top += d.height + GUI_BETWEEN;*/ // APPLY / OK button = new JButton("OK"); button.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { applyDirectives(); hide(); } }); pane.add(button); d2 = button.getPreferredSize(); int BUTTON_HEIGHT = d2.height; int BUTTON_WIDTH = 80; int h = right - (BUTTON_WIDTH + GUI_SMALL + BUTTON_WIDTH); button.setBounds(h, top, BUTTON_WIDTH, BUTTON_HEIGHT); h += BUTTON_WIDTH + GUI_SMALL; button = new JButton("Cancel"); button.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { hide(); } }); pane.add(button); button.setBounds(h, top, BUTTON_WIDTH, BUTTON_HEIGHT); top += BUTTON_HEIGHT + GUI_BETWEEN; // frame.getContentPane().add(box); frame.pack(); Insets insets = frame.getInsets(); frame.setSize( right + GUI_BIG + insets.left + insets.right, top + GUI_SMALL + insets.top + insets.bottom); // frame.setResizable(false); frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); frame.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { frame.setVisible(false); } }); Toolkit.registerWindowCloseKeys( frame.getRootPane(), new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { frame.setVisible(false); } }); Toolkit.setIcon(frame); }
public LoginPanel(Image img, ActionListener listener) { super(null); this.listener = listener; if (img == null) { InputStream inData = getClass().getResourceAsStream("/resources/background.gif"); BufferedImage back = null; if (inData != null) try { back = ImageIO.read(inData); } catch (IOException e) { loger.finest("LoginPanel class can't get the background image"); } this.background = back; } setLayout(null); JPanel logingPanel = new JPanel(); loginTitle = new JLabel("Autentificare"); logingPanel.setSize(250, 150); logingPanel.setBorder(new javax.swing.border.LineBorder(Color.black, 2)); logingPanel.setLayout(null); loginTitle.setBounds(3, 0, logingPanel.getWidth(), 20); logingPanel.add(loginTitle); JLabel loginUser = new JLabel("Utilizator"); loginUser.setBounds( 80 - loginUser.getPreferredSize().width, 40, loginUser.getPreferredSize().width, loginUser.getPreferredSize().height); logingPanel.add(loginUser); user = new JTextField(10); user.setBounds(85, 40, user.getPreferredSize().width, user.getPreferredSize().height); // user.setText("test"); // loginUser.setLabelFor(user); logingPanel.add(user); JLabel loginPass = new JLabel("Parola"); loginPass.setBounds( 80 - loginPass.getPreferredSize().width, 80, loginPass.getPreferredSize().width, loginPass.getPreferredSize().height); logingPanel.add(loginPass); // JTextField pass = new JTextField(10); pass = new JPasswordField(10); pass.setBounds(85, 80, pass.getPreferredSize().width, pass.getPreferredSize().height); pass.addKeyListener(this); // pass.setText("test"); // loginUser.setLabelFor(user); logingPanel.add(pass); JButton loginButton = new JButton("Start"); loginButton.setActionCommand("LOGIN"); loginButton.setBounds( 60, 110, loginButton.getPreferredSize().width, loginButton.getPreferredSize().height); // loginButton.setOpaque(false); loginButton.setFocusPainted(false); // loginButton.setContentAreaFilled(false); // loginButton.setBorderPainted(false); loginButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); loginButton.addActionListener(listener); logingPanel.add(loginButton); add(logingPanel); }