private JPanel createDynamicCenterPanel(PrimitiveForm primitiveForm, DOTProperty property) { final JTable theTable = new JTable(); PrimitiveFormPropertyPair pfpPair = new PrimitiveFormPropertyPair(primitiveForm.getName(), property); _dynamicTables.put(pfpPair, theTable); DOTPoint dotPoint = (DOTPoint) _dotDefinitionDialogFrame.getScratchDisplayObjectType(); final DynamicDOTItemManager tableModel = (DynamicDOTItemManager) dotPoint.getTableModel(primitiveForm, property); theTable.setModel(tableModel); class NumberComparator implements Comparator<Number> { public int compare(Number o1, Number o2) { final double d1 = o1.doubleValue(); final double d2 = o2.doubleValue(); if (d1 < d2) { return -1; } if (d1 == d2) { return 0; } return 1; } } TableRowSorter<DynamicDOTItemManager> tableRowSorter = new TableRowSorter<DynamicDOTItemManager>(); tableRowSorter.setModel(tableModel); tableRowSorter.setComparator(4, new NumberComparator()); tableRowSorter.setComparator(5, new NumberComparator()); theTable.setRowSorter(tableRowSorter); JButton newDOTItemButton = new JButton("Neue Zeile"); newDOTItemButton.setEnabled(_dotDefinitionDialogFrame.isEditable()); JButton deleteDOTItemButton = new JButton("Zeile löschen"); deleteDOTItemButton.setEnabled(false); JButton showConflictsButton = new JButton("Zeige Konflikte"); addButtonListeners( primitiveForm, property, newDOTItemButton, deleteDOTItemButton, showConflictsButton); addListSelectionListener(theTable, deleteDOTItemButton); JPanel dotButtonsPanel = new JPanel(); dotButtonsPanel.setLayout(new SpringLayout()); dotButtonsPanel.add(newDOTItemButton); dotButtonsPanel.add(deleteDOTItemButton); dotButtonsPanel.add(showConflictsButton); dotButtonsPanel.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10)); SpringUtilities.makeCompactGrid(dotButtonsPanel, 1, 5, 20); JPanel thePanel = new JPanel(); thePanel.setLayout(new SpringLayout()); thePanel.setBorder(BorderFactory.createMatteBorder(2, 2, 2, 2, Color.BLACK)); thePanel.add(new JScrollPane(theTable)); thePanel.add(dotButtonsPanel); SpringUtilities.makeCompactGrid(thePanel, 2, 20, 5); return thePanel; }
public RobonoboFrame(RobonoboController control, String[] args) { this.control = control; this.cmdLineArgs = args; setTitle("robonobo"); setIconImage(GUIUtils.getImage("/icon/robonobo-64x64.png")); setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); addWindowListener(new CloseListener()); menuBar = Platform.getPlatform().getMenuBar(this); setJMenuBar(menuBar); JPanel contentPane = new JPanel(); double[][] cellSizen = {{5, 200, 5, TableLayout.FILL, 5}, {3, TableLayout.FILL, 5}}; contentPane.setLayout(new TableLayout(cellSizen)); setContentPane(contentPane); leftSidebar = new LeftSidebar(this); contentPane.add(leftSidebar, "1,1"); mainPanel = new MainPanel(this); contentPane.add(mainPanel, "3,1"); setPreferredSize(new Dimension(1024, 723)); pack(); leftSidebar.selectMyMusic(); guiConfig = (GuiConfig) control.getConfig("gui"); addListeners(); }
public RemoveFrame() { frame = new JFrame("Select Files you wish to Remove from Drive"); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.getRootPane().setDefaultButton(confirm); try { files = DriveList.list(); } catch (IOException e) { files = new ArrayList<File>(); } confirm = new JButton("Remove"); quit = new JButton("Cancel"); confirm.addActionListener(this); quit.addActionListener(this); frame.setLayout(new BorderLayout()); checkPanel = new JPanel(); control = new JPanel(); control.setLayout(new GridLayout(1, 2)); control.add(confirm); control.add(quit); frame.add(control, BorderLayout.SOUTH); drawCheckPanel(); frame.add(checkPanel, BorderLayout.CENTER); frame.pack(); frame.setVisible(true); }
private JPanel makeAttributesPanel() { JPanel panel = new JPanel(new GridLayout(1, 2, 8, 8)); panel.add(this.makePathAttributesPanel()); panel.add(this.makeInteriorAttributesPanel()); return panel; }
protected void initComponents() { activation = new JComboBox(new String[] {KEY_EQUIVALENT, TAB_TRIGGER}); final CardLayout cardLayout = new CardLayout(); activationSpec = new JPanel(); activationSpec.setLayout(cardLayout); keyEquivalent = new JTextField(); tabTrigger = new JTextField(); name = new JTextField(); activationSpec.add(keyEquivalent, KEY_EQUIVALENT); activationSpec.add(tabTrigger, TAB_TRIGGER); activation.addItemListener( new ItemListener() { @Override public void itemStateChanged(ItemEvent itemEvent) { if (itemEvent.getStateChange() != ItemEvent.SELECTED) return; cardLayout.show(activationSpec, (String) itemEvent.getItem()); } }); scope = new JTextField(); }
/** Arg Constructor */ public TicTacToeFrame() { // Creates a panel for grid layout // http://www.java-tips.org/java-se-tips-100019/15-javax-swing/1751-how-to-make-split-pane-using-swing8.html JPanel gameBoardPanel = new JPanel(new GridLayout(3, 3, 0, 0)); // panel 1 JPanel gameStatusPanel = new JPanel(); // panel 2 // JLabel gameStatusLabel = new JLabel("Area 2"); // gameBoardPanel.add(j1); gameStatusPanel.add(gameStatusLabel2); gameStatusPanel.add(gameStatusLabel3); gameStatusPanel.add(gameStatusLabel); JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, gameBoardPanel, gameStatusPanel); splitPane.setResizeWeight(0.9); splitPane.setOneTouchExpandable(true); getContentPane().add(splitPane); // Adds 9 cells to grid layout for (int i = 0; i < 3; i++) { for (int k = 0; k < 3; k++) { gameBoardPanel.add(cells[i][k] = new Cell()); } } }
private JComponent createSettingsPanel() { JPanel result = new JPanel(new FlowLayout(FlowLayout.RIGHT, 3, 0)); result.add(new JLabel(ApplicationBundle.message("label.font.size"))); myFontSizeSlider = new JSlider(JSlider.HORIZONTAL, 0, FontSize.values().length - 1, 3); myFontSizeSlider.setMinorTickSpacing(1); myFontSizeSlider.setPaintTicks(true); myFontSizeSlider.setPaintTrack(true); myFontSizeSlider.setSnapToTicks(true); UIUtil.setSliderIsFilled(myFontSizeSlider, true); result.add(myFontSizeSlider); result.setBorder(BorderFactory.createLineBorder(UIUtil.getBorderColor(), 1)); myFontSizeSlider.addChangeListener( new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { if (myIgnoreFontSizeSliderChange) { return; } EditorColorsManager colorsManager = EditorColorsManager.getInstance(); EditorColorsScheme scheme = colorsManager.getGlobalScheme(); scheme.setQuickDocFontSize(FontSize.values()[myFontSizeSlider.getValue()]); applyFontSize(); } }); String tooltipText = ApplicationBundle.message("quickdoc.tooltip.font.size.by.wheel"); result.setToolTipText(tooltipText); myFontSizeSlider.setToolTipText(tooltipText); result.setVisible(false); result.setOpaque(true); myFontSizeSlider.setOpaque(true); return result; }
public About() { cl = ClassLoader.getSystemClassLoader(); // ----------------------------------------CENTER--------------------------------// imgAbout = new ImageIcon(cl.getResource("om.png")); lblAbout = new JLabel(imgAbout); lblAbout.setBounds(0, 0, 450, 263); JPanel pnlCenter = new JPanel(); pnlCenter.setLayout(null); pnlCenter.add(lblAbout); btnOk = new JButton(new ImageIcon(cl.getResource("ok.png"))); btnOk.setBounds(390, 215, 40, 30); pnlCenter.add(btnOk); btnOk.addActionListener(this); // -----------------------------------CONTAINER----------------------------------// Container c = getContentPane(); c.setLayout(new BorderLayout()); c.add(pnlCenter, BorderLayout.CENTER); setSize(450, 280); setVisible(true); setResizable(false); setLocation(580, 280); // setDefaultCloseOperation(EXIT_ON_CLOSE); }
static void tell(String question, String btnText) { final JDialog d = new JDialog(); d.setLocationRelativeTo(null); JPanel bpane = new JPanel(new FlowLayout()); JLabel l = new JLabel(question); JPanel cp = (JPanel) d.getContentPane(); cp.setLayout(new FlowLayout()); cp.add(l, BorderLayout.CENTER); cp.add(bpane, BorderLayout.SOUTH); JButton b1 = new JButton("OK"); bpane.add(b1); d.pack(); d.setVisible(true); b1.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ans = ((JButton) e.getSource()).getText(); d.dispose(); } }); }
// -------------------------------------------------------------------------------------- // // ---------------------------------- Constructor Helpers ------------------------------- // // -------------------------------------------------------------------------------------- // private void buildActiveKits(JPanel container) { // initialize variable final int WIDTH = 150; // set containment panel properties container.setLayout(new BoxLayout(container, BoxLayout.Y_AXIS)); setComponentSize(container, 150, PAGE_HEIGHT); JLabel header = new JLabel("Active Kits"); header.setHorizontalAlignment(header.CENTER); header.setFont(new Font("Serif", Font.BOLD, 18)); setComponentSize(header, WIDTH, 25); // create list model and list listModel = new DefaultListModel(); kitList = new JList(listModel); kitList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); kitList.addListSelectionListener(this); kitList.setFixedCellHeight(25); JScrollPane listScrollPane = new JScrollPane(kitList); // add elements to containment panel container.add(header); container.add(listScrollPane); }
FactoryManagerGUI(FactoryManager parent, int pWidth, int pHeight) { this.parent = parent; this.PAGE_WIDTH = pWidth; this.PAGE_HEIGHT = pHeight; // initialize class variables activeKitsContainer = new JPanel(); activeKitsPanel = new JPanel(); kitDataPanel = new JPanel(); kits = new TreeMap<Integer, Kits>(); buildInfo = new ArrayList<Kits>(); images = parent.getImageArray(); greyLine = BorderFactory.createLineBorder(Color.DARK_GRAY); // build Active Kits Container activeKitsContainer.setLayout(new BoxLayout(activeKitsContainer, BoxLayout.X_AXIS)); setComponentSize(activeKitsContainer, PAGE_WIDTH, PAGE_HEIGHT); setComponentSize(kitDataPanel, 450, PAGE_HEIGHT); buildActiveKits(activeKitsPanel); activeKitsContainer.add(activeKitsPanel); activeKitsContainer.add(kitDataPanel); // add master containers to frame this.add(activeKitsContainer); }
/* * The following method creates the textfield to change the text * and the button to update the label. * postcondition: returns the panel containing the textfield and button. */ public JPanel createUpdateButton() { JLabel textLabel = new JLabel(new String("Change text to: ")); textField = new JTextField(new String("Big Java"), 20); textField.setFont(new Font(("Times"), Font.PLAIN, 12)); update = new JButton(new String("Update")); update.setDefaultCapable(true); // This class is used to create a special ActionListener for this menu item class ButtonListener implements ActionListener { /* * This method is called when the update button is clicked */ public void actionPerformed(ActionEvent event) { // Call the method to change the text on the screen. setSampleFont(); } // end actionPerformed method } ActionListener listener = new ButtonListener(); update.addActionListener(listener); JPanel panel = new JPanel(); panel.add(textLabel); panel.add(textField); panel.add(update); return panel; } // end createUpdateButton method
private void initialize() { setName("JunkPanel"); setLayout(new GridBagLayout()); refreshLanguage(); // Adds all of the components final GridBagConstraints constraints = new GridBagConstraints(); constraints.anchor = GridBagConstraints.WEST; final Insets insets5555 = new Insets(5, 5, 5, 5); constraints.insets = insets5555; constraints.weightx = 1.0; constraints.gridwidth = 1; constraints.gridy = 0; constraints.insets = insets5555; constraints.gridx = 0; add(hideJunkMessagesCheckBox, constraints); constraints.gridy++; add(markJunkIdentityBadCheckBox, constraints); constraints.gridy++; constraints.fill = GridBagConstraints.HORIZONTAL; { final JSeparator separator = new JSeparator(SwingConstants.HORIZONTAL); add(separator, constraints); } constraints.fill = GridBagConstraints.NONE; constraints.gridy++; add(stopBoardUpdatesWhenDosedCheckBox, constraints); constraints.gridy++; { final JPanel subPanel = new JPanel(new GridBagLayout()); final GridBagConstraints subConstraints = new GridBagConstraints(); subConstraints.insets = new Insets(0, 10, 0, 10); subConstraints.anchor = GridBagConstraints.WEST; subConstraints.gridx = 0; subPanel.add(LinvalidSubsequentMessagesThreshold, subConstraints); subConstraints.gridx = 1; subPanel.add(TfInvalidSubsequentMessagesThreshold, subConstraints); add(subPanel, constraints); } // glue constraints.gridy++; constraints.gridx = 0; constraints.fill = GridBagConstraints.BOTH; constraints.weightx = 1; constraints.weighty = 1; add(new JLabel(""), constraints); // Add listeners stopBoardUpdatesWhenDosedCheckBox.addActionListener(listener); }
/** * Builds reading lists tab. * * @return component. */ protected JComponent buildReadingListsTab() { // Wording JComponent wording = msg(Strings.message("guide.dialog.readinglists.wording")); // Buttons Dimension btnSize = new Dimension(20, 20); btnAddReadingList.setPreferredSize(btnSize); btnRemoveList.setPreferredSize(btnSize); FlowLayout layout = new FlowLayout(FlowLayout.LEFT); JPanel bbar = new JPanel(layout); bbar.add(btnAddReadingList); bbar.add(btnRemoveList); layout.setHgap(0); layout.setVgap(0); // Panel BBFormBuilder builder = new BBFormBuilder("0:grow"); builder.setDefaultDialogBorder(); builder.append(wording); builder.appendUnrelatedComponentsGapRow(2); builder.appendRow("min:grow"); builder.append(new JScrollPane(tblReadingLists), 1, CellConstraints.FILL, CellConstraints.FILL); builder.append(bbar); return builder.getPanel(); }
public Initialize() { setTitle(""); setSize(400, 300); setLocationRelativeTo(null); JPanel p = new JPanel(); p.setLayout(new GridLayout(3, 2)); typel = new JLabel("Animal Type:"); typef = new JComboBox(); typef.addItem("Cow"); typef.addItem("Deer"); typef.addItem("Horse"); tot_popl = new JLabel("Initial population:"); tot_pop = new JTextField(12); annuler = new JButton("Cancel"); validate = new JButton("Create"); annuler.addActionListener(this); validate.addActionListener(this); p.add(typel); p.add(typef); p.add(tot_popl); p.add(tot_pop); p.add(annuler); p.add(validate); setContentPane(p); this.pack(); // bien regrouper les éléments }
@Nullable @Override public JComponent createComponent() { myEnabled = new JBCheckBox("Enable EditorConfig support"); final JPanel result = new JPanel(); result.setLayout(new BoxLayout(result, BoxLayout.LINE_AXIS)); final JPanel panel = new JPanel(new VerticalFlowLayout()); result.setBorder(IdeBorderFactory.createTitledBorder("EditorConfig", false)); panel.add(myEnabled); final JLabel warning = new JLabel("EditorConfig may override the IDE code style settings"); warning.setFont(UIUtil.getLabelFont(UIUtil.FontSize.SMALL)); warning.setBorder(IdeBorderFactory.createEmptyBorder(0, 20, 0, 0)); panel.add(warning); panel.setAlignmentY(Component.TOP_ALIGNMENT); result.add(panel); final JButton export = new JButton("Export"); export.addActionListener( (event) -> { final Component parent = UIUtil.findUltimateParent(result); if (parent instanceof IdeFrame) { Utils.export(((IdeFrame) parent).getProject()); } }); export.setAlignmentY(Component.TOP_ALIGNMENT); result.add(export); return result; }
public TestSwingExample1() { super("ActionExample"); setChannel(currentChannel); // enable/disable the Actions as appropriate channelLabel.setHorizontalAlignment(JLabel.CENTER); channelLabel.setFont(new Font("Serif", Font.PLAIN, 32)); getContentPane().add(channelLabel, BorderLayout.NORTH); JPanel buttonPanel = new JPanel(new GridLayout(2, 2, 16, 6)); buttonPanel.setBorder(BorderFactory.createEmptyBorder(6, 16, 16, 16)); getContentPane().add(buttonPanel, BorderLayout.CENTER); buttonPanel.add(new JButton(upAction)); buttonPanel.add(new JButton(gotoFavoriteAction)); buttonPanel.add(new JButton(downAction)); buttonPanel.add(new JButton(setFavoriteAction)); JMenuBar mb = new JMenuBar(); JMenu menu = new JMenu("Channel"); menu.add(new JMenuItem(upAction)); menu.add(new JMenuItem(downAction)); menu.addSeparator(); menu.add(new JMenuItem(gotoFavoriteAction)); menu.add(new JMenuItem(setFavoriteAction)); mb.add(menu); setJMenuBar(mb); }
private JPanel createFieldPanel() { myDoNotReplaceRadioButton = new JBRadioButton(UIUtil.replaceMnemonicAmpersand("Do n&ot replace")); myReplaceFieldsInaccessibleInRadioButton = new JBRadioButton( UIUtil.replaceMnemonicAmpersand("Replace fields &inaccessible in usage context")); myReplaceAllFieldsRadioButton = new JBRadioButton(UIUtil.replaceMnemonicAmpersand("&Replace all fields")); myDoNotReplaceRadioButton.setFocusable(false); myReplaceFieldsInaccessibleInRadioButton.setFocusable(false); myReplaceAllFieldsRadioButton.setFocusable(false); final ButtonGroup group = new ButtonGroup(); group.add(myDoNotReplaceRadioButton); group.add(myReplaceFieldsInaccessibleInRadioButton); group.add(myReplaceAllFieldsRadioButton); final JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); panel.add(myDoNotReplaceRadioButton); panel.add(myReplaceFieldsInaccessibleInRadioButton); panel.add(myReplaceAllFieldsRadioButton); panel.setBorder( IdeBorderFactory.createTitledBorder( "Replace fields used in expression with their getters", true)); return panel; }
private JPanel createRadioButtonPanel() { JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new GridLayout(1, 3)); middleButton = new JRadioButton("Middle Page"); middleButton.setHorizontalAlignment(AbstractButton.CENTER); middleButton.setActionCommand(Page.MIDDLE); middleButton.setEnabled(false); endButton = new JRadioButton("End Page"); endButton.setHorizontalAlignment(AbstractButton.CENTER); endButton.setActionCommand(Page.END); endButton.setEnabled(false); initButton = new JRadioButton("Start Page"); initButton.setHorizontalAlignment(AbstractButton.CENTER); initButton.setActionCommand(Page.START); initButton.setEnabled(false); ButtonGroup group = new ButtonGroup(); group.add(initButton); group.add(middleButton); group.add(endButton); buttonPanel.add(initButton); buttonPanel.add(middleButton); buttonPanel.add(endButton); buttonPanel.setBorder(BorderFactory.createEtchedBorder()); return buttonPanel; }
private JPanel createNamePanel() { final GridBag c = new GridBag().setDefaultAnchor(GridBagConstraints.WEST).setDefaultInsets(1, 1, 1, 1); final JPanel namePanel = new JPanel(new GridBagLayout()); final JLabel typeLabel = new JLabel(UIUtil.replaceMnemonicAmpersand("&Type:")); c.nextLine().next().weightx(0).fillCellNone(); namePanel.add(typeLabel, c); myTypeComboBox = createTypeComboBox( GroovyIntroduceParameterUtil.findVar(myInfo), GroovyIntroduceParameterUtil.findExpr(myInfo), findStringPart()); c.next().weightx(1).fillCellHorizontally(); namePanel.add(myTypeComboBox, c); typeLabel.setLabelFor(myTypeComboBox); final JLabel nameLabel = new JLabel(UIUtil.replaceMnemonicAmpersand("&Name:")); c.nextLine().next().weightx(0).fillCellNone(); namePanel.add(nameLabel, c); myNameSuggestionsField = createNameField(GroovyIntroduceParameterUtil.findVar(myInfo)); c.next().weightx(1).fillCellHorizontally(); namePanel.add(myNameSuggestionsField, c); nameLabel.setLabelFor(myNameSuggestionsField); GrTypeComboBox.registerUpDownHint(myNameSuggestionsField, myTypeComboBox); return namePanel; }
public SignUpPanel() { RegisterButton = new JButton("Register"); // initializing two button references UsernameField = new JTextField(15); PasswordField = new JPasswordField(15); PasswordField1 = new JPasswordField(15); JLabel UsernameLabel = new JLabel("Username: "******"Password: "******"Re-enter Password"); JPanel UsernamePanel = new JPanel(); JPanel PasswordPanel = new JPanel(); JPanel PasswordPanel1 = new JPanel(); UsernamePanel.add(UsernameLabel); UsernamePanel.add(UsernameField); PasswordPanel.add(PasswordLabel); PasswordPanel.add(PasswordField); PasswordPanel1.add(PasswordLabel1); PasswordPanel1.add(PasswordField1); add(UsernamePanel); add(PasswordPanel); add(PasswordPanel1); add(RegisterButton); // add the two buttons on to this panel RegisterButton.addActionListener(this); // event listener registration }
/** * builds and displays the frame without the colored fractal; registers the buttons; sets size, * location, close operation; calls changeFractal() */ private void makeWindow() { // set size and location setSize(740, 800); setLocation(100, 0); // specify close button action setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // instantiate panel panelNorth = new JPanel(); // instantiate buttons and register action listener up = new JButton("level up"); down = new JButton("level down"); up.addActionListener(this); down.addActionListener(this); // set layout setLayout(new BorderLayout(10, 10)); // add panel to frame and buttons to panel add(panelNorth, BorderLayout.NORTH); panelNorth.add(up); panelNorth.add(down); // call changeFractal changeFractal(); }
/** Description of the Method */ public void init() { // super.init(); size = new Dimension(570, 570); contentPane = (JPanel) this.getContentPane(); contentPane.setLayout(borderLayout1); Dimension d = messagePanel.getSize(); d.height += 20; messagePanel.setPreferredSize(d); contentPane.add(messagePanel, BorderLayout.SOUTH); contentPane.setOpaque(true); userPanel.setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(2, 2, 2, 2); messagePanel.setLayout(borderLayout5); contentPane.setOpaque(true); contentPane.setBackground(Color.white); this.setSize(size); messagePanel.add(labelMessage, BorderLayout.NORTH); // Logg.logg("MhClient: Före XttTree-skapande", 6); this.mhTable = new MhTable(root, false, this.labelMessage); // Logg.logg("MhClient: mhTable-skapande klart", 6); this.contentPane.add(this.mhTable.splitPane, BorderLayout.CENTER); }
public void createPanel() { panel = new JPanel(new GridLayout(3, 1)); // A panel object is created; panel.setBackground(Color.GREEN); // Set the background color of the panel panel.add(buttonPlus); // Add the button object to the panel panel.add(buttonMinus); // and the other one also. panel.add(text); // Add the text object to the panel. }
public static void main(String[] args) { final Browser browser = new Browser(); BrowserView browserView = new BrowserView(browser); final JTextField addressBar = new JTextField("http://www.teamdev.com/jxbrowser"); addressBar.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { browser.loadURL(addressBar.getText()); } }); JPanel addressPane = new JPanel(new BorderLayout()); addressPane.add(new JLabel(" URL: "), BorderLayout.WEST); addressPane.add(addressBar, BorderLayout.CENTER); JFrame frame = new JFrame("JxBrowser - Hello World"); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.add(addressPane, BorderLayout.NORTH); frame.add(browserView, BorderLayout.CENTER); frame.setSize(800, 500); frame.setLocationRelativeTo(null); frame.setVisible(true); browser.loadURL(addressBar.getText()); }
private static JPanel makePanel(String title, String href) { JPanel p = new JPanel(new GridBagLayout()); p.setBorder(BorderFactory.createTitledBorder(title)); JLabel label = new JLabel(href); JEditorPane editor = new JEditorPane("text/html", href); editor.setOpaque(false); editor.setEditable(false); editor.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE); GridBagConstraints c = new GridBagConstraints(); c.gridheight = 1; c.gridx = 0; c.insets = new Insets(5, 5, 5, 0); c.anchor = GridBagConstraints.EAST; c.gridy = 0; p.add(new JLabel("JLabel: "), c); c.gridy = 2; p.add(new JLabel("JEditorPane: "), c); c.gridx = 1; c.weightx = 1d; c.anchor = GridBagConstraints.WEST; c.gridy = 0; p.add(label, c); c.gridy = 2; p.add(editor, c); return p; }
/** * This method initializes AggButtonPanel * * @return javax.swing.JPanel */ private JPanel getAggButtonPanel() { if (AggButtonPanel == null) { GridBagConstraints gridBagConstraints21 = new GridBagConstraints(); gridBagConstraints21.gridx = 0; gridBagConstraints21.gridy = 4; GridBagConstraints gridBagConstraints11 = new GridBagConstraints(); gridBagConstraints11.gridx = 0; gridBagConstraints11.gridy = 3; GridBagConstraints gridBagConstraints2 = new GridBagConstraints(); gridBagConstraints2.gridx = 0; gridBagConstraints2.gridy = 2; GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); gridBagConstraints1.gridx = 0; gridBagConstraints1.gridy = 1; GridBagConstraints gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; AggButtonPanel = new JPanel(); AggButtonPanel.setLayout(new GridBagLayout()); AggButtonPanel.add(getAggAdd(), gridBagConstraints); AggButtonPanel.add(getAggRemove(), gridBagConstraints1); AggButtonPanel.add(getAggEdit(), gridBagConstraints2); AggButtonPanel.add(getDoneButton(), gridBagConstraints11); AggButtonPanel.add(getAbort(), gridBagConstraints21); } return AggButtonPanel; }
protected DictionaryWindow(MainFrame parent) { super(parent, true); setTitle("Dictionary"); setBounds(new Rectangle(0, 0, 330, 330)); JPanel mainPanel = new JPanel(new BorderLayout()); DefaultListModel<String> listModel = new DefaultListModel<String>(); JList<String> list = new JList<String>(listModel); JScrollPane scroll = new JScrollPane(list); for (String word : parent.dictionary.getSortedDictionary()) listModel.addElement(word); JButton ok = new JButton("OK"); ok.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dispose(); } }); mainPanel.add(scroll, BorderLayout.CENTER); mainPanel.add(ok, BorderLayout.SOUTH); add(mainPanel); setDefaultCloseOperation(DISPOSE_ON_CLOSE); setLocationRelativeTo(null); setVisible(true); }
public ActionFrame() { setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT); buttonPanel = new JPanel(); // define actions Action yellowAction = new ColorAction("Yellow", new ImagIcon("yellow-ball.gif"), Color.YELLOW); Action blueAction = new ColorAction("Blue", new ImageIcon("blue-ball.gif"), Color.BLUE); Action redAction = new ColorAction("Red", new ImageIcon("red-ball.gif"), Color.RED); // add buttons for these actions buttonPanel.add(new JButton(yellowAction)); buttonPanel.add(new JButton(blueAction)); buttonPanel.add(new JButton(recAction)); // add panel to frame add(buttonPanel); // associate the Y, B, and R keys with names InputMap imap = buttonPanel.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); imap.put(KeyStroke.getKeyStroke("ctrl Y"), "panel.yellow"); imap.put(KeyStroke.getKeyStroke("Ctrl B"), "panel.blue"); imap.put(KeyStroke.getKeyStroke("ctrl R"), "panel.red"); // associate the names with actions ActionMap amap = buttonPanel.getActionMap(); amap.put("panel.yellow", yellowAction); amap.put("panel.blue", blueAction); amap.put("panel.red", redAction); }
private JPanel getMainPanel() { if (mainPanel == null) { mainPanel = new JPanel(); mainPanel.setPreferredSize(new Dimension(550, 300)); GridBagLayout layout = new GridBagLayout(); mainPanel.setLayout(layout); GridBagConstraints constraints = new GridBagConstraints(); constraints.fill = GridBagConstraints.BOTH; constraints.weightx = 2; constraints.weighty = 1; constraints.anchor = GridBagConstraints.NORTHWEST; constraints.gridwidth = 2; layout.setConstraints(getAvailableRobotsPanel(), constraints); mainPanel.add(getAvailableRobotsPanel()); constraints.gridwidth = 1; constraints.weightx = 0; constraints.weighty = 0; constraints.anchor = GridBagConstraints.CENTER; layout.setConstraints(getButtonsPanel(), constraints); mainPanel.add(getButtonsPanel()); constraints.gridwidth = GridBagConstraints.REMAINDER; constraints.weightx = 1; constraints.weighty = 1; constraints.anchor = GridBagConstraints.NORTHWEST; layout.setConstraints(getSelectedRobotsPanel(), constraints); mainPanel.add(getSelectedRobotsPanel()); } return mainPanel; }