/** * 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 MenuButtonAcqMode(Color color, String toolTip) { back = new JButton(null, new ColoredIcon(Color.black)); back.setPreferredSize(new Dimension(22, 22)); setMainButton(back); setPopupMenu(new ColorPanel(back)); setPopupLocation(MenuedButton.BELOW); setSelectedColor(color); setToolTipText(toolTip); }
/* create a new button and add the respective coordinates */ public void createNewButton(int x, int y) { this.x = x; // Autoboxing! this.y = y; button = new JButton(); button.setPreferredSize(new Dimension(20, 20)); // for leftclicks button.setActionCommand(this.x.toString() + " " + this.y.toString()); // for rightclicks button.setName(this.x.toString() + " " + this.y.toString()); }
public void layoutComponents() { setLayout(new BorderLayout()); add(main, BorderLayout.CENTER); if (popperIsVisible) { if (getPopperButtonLocation() == RIGHT) { popper.setPreferredSize(new Dimension(14, main.getHeight())); add(popper, BorderLayout.EAST); } else if (getPopperButtonLocation() == BOTTOM) { popper.setPreferredSize(new Dimension(main.getWidth(), 14)); add(popper, BorderLayout.SOUTH); setPopperArrowDirection(DOWN); setPopupLocation(popper.getX(), popper.getY() + popper.getHeight() + 5); } } Utilities.updateView(this); }
protected void setButtonsSize() { int nMaxWidth = 0, nMaxHeight = 0; Dimension objSize; Iterator objIterator = buttons.values().iterator(); while (objIterator.hasNext()) { JButton objButton = (JButton) objIterator.next(); objButton.setPreferredSize(null); objSize = objButton.getPreferredSize(); nMaxWidth = Math.max(nMaxWidth, objSize.width); nMaxHeight = Math.max(nMaxHeight, objSize.height); } objSize = new Dimension(nMaxWidth, nMaxHeight); d = objSize; objIterator = buttons.values().iterator(); while (objIterator.hasNext()) { ((JButton) objIterator.next()).setPreferredSize(objSize); } }
/** Initialize the common user interface components. */ private void initUI() { /* initialize fields */ { pFileSeqPanels = new TreeMap<FileSeq, JFileSeqPanel>(); } /* initialize the popup menus */ { initBasicMenus(true, false); updateMenuToolTips(); } /* initialize the panel components */ { setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); /* header */ { pApplyToolTipText = "Replace the working area files with the selected checked-in files."; pUnApplyToolTipText = "There are no unsaved changes to Apply at this time."; JPanel panel = initHeader(true); add(panel); } add(Box.createRigidArea(new Dimension(0, 4))); /* full node name */ { LinkedList<Component> extra = new LinkedList<Component>(); extra.add(Box.createRigidArea(new Dimension(4, 0))); { JButton btn = new JButton(); pSeqLayoutButton = btn; btn.setName(pIsListLayout ? "ListLayoutButton" : "TabbedLayoutButton"); Dimension size = new Dimension(19, 19); btn.setMinimumSize(size); btn.setMaximumSize(size); btn.setPreferredSize(size); btn.setActionCommand("seq-layout-changed"); btn.addActionListener(this); extra.add(btn); } initNameField(this, extra); pNodeNameField.setFocusable(true); pNodeNameField.addKeyListener(this); pNodeNameField.addMouseListener(this); } add(Box.createRigidArea(new Dimension(0, 4))); { JTabbedPane tab = new JTabbedPane(); pFileSeqsTab = tab; tab.setVisible(!pIsListLayout); add(tab); } { Box vbox = new Box(BoxLayout.Y_AXIS); pFileSeqsBox = vbox; { JScrollPane scroll = UIFactory.createVertScrollPane(vbox); pFileSeqsScroll = scroll; scroll.setVisible(!pIsListLayout); add(scroll); } } Dimension size = new Dimension(sSize + 22, 120); setMinimumSize(size); setPreferredSize(size); setFocusable(true); addKeyListener(this); addMouseListener(this); } updateNodeStatus(null, null, null); }
/** * Draws the GUI that allows a user to select assets to be updated. * * @return true if the user made a valid choice of assets to replace. * @throws PipelineException */ private boolean buildUpdateGUI() throws PipelineException { Box finalBox = new Box(BoxLayout.Y_AXIS); top = new Box(BoxLayout.Y_AXIS); JScrollPane scroll; { scroll = new JScrollPane(finalBox); scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); Dimension size = new Dimension(sVSize + sVSize + sTSize + 52, 500); scroll.setMinimumSize(size); scroll.setPreferredSize(size); scroll.getViewport().setScrollMode(JViewport.BACKINGSTORE_SCROLL_MODE); } /* query the user */ diag = new JToolDialog("Propagate Asset", scroll, "Continue"); areas = mclient.getWorkingAreas(); { Box hbox = new Box(BoxLayout.X_AXIS); Component comps[] = UIFactory.createTitledPanels(); JPanel tpanel = (JPanel) comps[0]; JPanel vpanel = (JPanel) comps[1]; { userField = UIFactory.createTitledCollectionField( tpanel, "User:"******"The user whose area the node is being created in."); userField.setActionCommand("user"); userField.setSelected(PackageInfo.sUser); userField.addActionListener(this); } UIFactory.addVerticalSpacer(tpanel, vpanel, 3); { viewField = UIFactory.createTitledCollectionField( tpanel, "View:", sTSize, vpanel, areas.get(PackageInfo.sUser), diag, sVSize, "The working area to create the nodes in."); viewField.setActionCommand("wrap"); viewField.addActionListener(this); } UIFactory.addVerticalSpacer(tpanel, vpanel, 3); { toolsetField = UIFactory.createTitledCollectionField( tpanel, "Toolset:", sTSize, vpanel, mclient.getActiveToolsetNames(), diag, sVSize, "The toolset to set on all the nodes."); toolsetField.setSelected(mclient.getDefaultToolsetName()); toolsetField.setActionCommand("wrap"); toolsetField.addActionListener(this); } UIFactory.addVerticalSpacer(tpanel, vpanel, 3); w = new Wrapper( userField.getSelected(), viewField.getSelected(), toolsetField.getSelected(), mclient); charList = SonyConstants.getAssetList(w, project, AssetType.CHARACTER); setsList = SonyConstants.getAssetList(w, project, AssetType.SET); propsList = SonyConstants.getAssetList(w, project, AssetType.PROP); { projectField = UIFactory.createTitledCollectionField( tpanel, "Project:", sTSize, vpanel, Globals.getChildrenDirs(w, "/projects"), diag, sVSize, "All the projects in pipeline."); projectField.setActionCommand("proj"); projectField.addActionListener(this); } hbox.add(comps[2]); top.add(hbox); } { Box vbox = new Box(BoxLayout.Y_AXIS); Box hbox = new Box(BoxLayout.X_AXIS); JButton button = new JButton("Propagate Additional Asset"); button.setName("ValuePanelButton"); button.setRolloverEnabled(false); button.setFocusable(false); Dimension d = new Dimension(sVSize, 25); button.setPreferredSize(d); button.setMinimumSize(d); button.setMaximumSize(new Dimension(Integer.MAX_VALUE, 25)); vbox.add(Box.createRigidArea(new Dimension(0, 5))); hbox.add(button); hbox.add(Box.createRigidArea(new Dimension(4, 0))); vbox.add(hbox); vbox.add(Box.createRigidArea(new Dimension(0, 5))); button.setActionCommand("add"); button.addActionListener(this); top.add(vbox); } list = new Box(BoxLayout.Y_AXIS); test = new JDrawer("Propagate Additional Asset", list, false); top.add(test); list.add(assetChoiceBox()); finalBox.add(top); { JPanel spanel = new JPanel(); spanel.setName("Spacer"); spanel.setMinimumSize(new Dimension(sTSize + sVSize, 7)); spanel.setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE)); spanel.setPreferredSize(new Dimension(sTSize + sVSize, 7)); finalBox.add(spanel); } diag.setVisible(true); if (diag.wasConfirmed()) { // get list of things to change. for (Component comp : list.getComponents()) { if (comp instanceof Box) { Box can = (Box) comp; JCollectionField oldOne = (JCollectionField) can.getComponent(2); JCollectionField newOne = (JCollectionField) can.getComponent(4); TreeMap<String, String> assetList = new TreeMap<String, String>(); assetList.putAll(charList); assetList.putAll(propsList); assetList.putAll(setsList); String key = assetList.get(oldOne.getSelected()) + lr; String value = assetList.get(newOne.getSelected()) + lr; if (!key.equals(value)) { potentialUpdates.add(key); pAssetManager.put(key, new AssetInfo(key, value)); } // System.err.println("bUG: "+pAssetManager.get(key).getHiLoResShots()); } } if (!pAssetManager.isEmpty()) return true; } return false; } // end buildReplacementGUI
/* * main constructor * @param debug - boolean for debug mode */ public boardPanel(boolean debug) { // initial constructor super(); debugBoardPanel = debug; // continue defining boardPanel this.setLayout(new GridBagLayout()); cons.fill = GridBagConstraints.BOTH; cons.insets = new Insets(0, 0, 0, 0); cons.anchor = GridBagConstraints.FIRST_LINE_START; this.setVisible(true); // button preferred size Dimension btnSize = new Dimension(25, 25); // top row // ------------------------------------------------------------------------------------------ // spa btnSpa = new JButton("Spa"); allRooms[0] = btnSpa; btnSpa.setPreferredSize(btnSize); cons.gridx = 0; cons.gridy = 0; cons.gridwidth = 5; cons.gridheight = 5; btnSpa.setBackground(defaultRoomColor); btnSpa.setOpaque(true); btnSpa.setBorderPainted(false); btnSpa.addActionListener(new myActionListener()); this.add(btnSpa, cons); // space buttons for (int y = 0; y < 5; y++) { for (int x = 5; x < 10; x++) { createBlankButtons(x, y, btnSize); } } // theater btnTheater = new JButton("Theater"); allRooms[1] = btnTheater; btnTheater.setPreferredSize(btnSize); cons.gridx = 10; cons.gridy = 0; cons.gridwidth = 5; cons.gridheight = 5; btnTheater.setOpaque(true); btnTheater.setBorderPainted(false); btnTheater.setBackground(defaultRoomColor); btnTheater.addActionListener(new myActionListener()); this.add(btnTheater, cons); // space buttons for (int y = 0; y < 5; y++) { for (int x = 15; x < 20; x++) { createBlankButtons(x, y, btnSize); } } // Living Room btnLivingRoom = new JButton("Living Room"); allRooms[2] = btnLivingRoom; btnLivingRoom.setPreferredSize(btnSize); cons.gridx = 20; cons.gridy = 0; cons.gridwidth = 5; cons.gridheight = 5; btnLivingRoom.setBackground(defaultRoomColor); btnLivingRoom.setOpaque(true); btnLivingRoom.setBorderPainted(false); btnLivingRoom.addActionListener(new myActionListener()); this.add(btnLivingRoom, cons); // space buttons for (int y = 0; y < 5; y++) { for (int x = 25; x < 30; x++) { createBlankButtons(x, y, btnSize); } } // observatory btnObservatory = new JButton("Observatory"); allRooms[3] = btnObservatory; btnObservatory.setPreferredSize(btnSize); cons.gridx = 30; cons.gridy = 0; cons.gridwidth = 5; cons.gridheight = 5; btnObservatory.setBackground(defaultRoomColor); btnObservatory.setOpaque(true); btnObservatory.setBorderPainted(false); btnObservatory.addActionListener(new myActionListener()); this.add(btnObservatory, cons); // top to middle spaces // ------------------------------------------------------------------------------------------ // space buttons for (int y = 5; y < 10; y++) { for (int x = 0; x < 35; x++) { createBlankButtons(x, y, btnSize); } } // middle row // ------------------------------------------------------------------------------------------ // Patio btnPatio = new JButton("Patio"); allRooms[4] = btnPatio; btnPatio.setPreferredSize(btnSize); cons.gridx = 0; cons.gridy = 10; cons.gridwidth = 5; cons.gridheight = 5; btnPatio.setBackground(defaultRoomColor); btnPatio.setOpaque(true); btnPatio.setBorderPainted(false); btnPatio.addActionListener(new myActionListener()); this.add(btnPatio, cons); // space buttons for (int y = 10; y < 15; y++) { for (int x = 5; x < 10; x++) { createBlankButtons(x, y, btnSize); } } // pool btnPool = new JButton("Pool"); allRooms[5] = btnPool; btnPool.setPreferredSize(btnSize); cons.gridx = 10; cons.gridy = 10; cons.gridwidth = 15; cons.gridheight = 5; btnPool.setBackground(defaultPoolColor); btnPool.setOpaque(true); btnPool.setBorderPainted(false); btnPool.addActionListener(new myActionListener()); this.add(btnPool, cons); // space buttons for (int y = 10; y < 15; y++) { for (int x = 25; x < 30; x++) { createBlankButtons(x, y, btnSize); } } // Hall btnHall = new JButton("Hall"); allRooms[6] = btnHall; btnHall.setPreferredSize(btnSize); cons.gridx = 30; cons.gridy = 10; cons.gridwidth = 5; cons.gridheight = 5; btnHall.setBackground(defaultRoomColor); btnHall.setOpaque(true); btnHall.setBorderPainted(false); btnHall.addActionListener(new myActionListener()); this.add(btnHall, cons); // middle to bottom spaces // ------------------------------------------------------------------------------------------ // space buttons for (int y = 15; y < 20; y++) { for (int x = 0; x < 35; x++) { createBlankButtons(x, y, btnSize); } } // bottom row // ------------------------------------------------------------------------------------------ // Kitchen btnKitchen = new JButton("Kitchen"); allRooms[7] = btnKitchen; btnKitchen.setPreferredSize(btnSize); cons.gridx = 0; cons.gridy = 20; cons.gridwidth = 5; cons.gridheight = 5; btnKitchen.setBackground(defaultRoomColor); btnKitchen.setOpaque(true); btnKitchen.setBorderPainted(false); btnKitchen.addActionListener(new myActionListener()); this.add(btnKitchen, cons); // space buttons for (int y = 20; y < 25; y++) { for (int x = 5; x < 10; x++) { createBlankButtons(x, y, btnSize); } } // dining room btnDiningRoom = new JButton("Dining Room"); allRooms[8] = btnDiningRoom; btnPool.setPreferredSize(btnSize); cons.gridx = 10; cons.gridy = 20; cons.gridwidth = 15; cons.gridheight = 5; btnDiningRoom.setBackground(defaultRoomColor); btnDiningRoom.setOpaque(true); btnDiningRoom.setBorderPainted(false); btnDiningRoom.addActionListener(new myActionListener()); this.add(btnDiningRoom, cons); // space buttons for (int y = 20; y < 25; y++) { for (int x = 25; x < 30; x++) { createBlankButtons(x, y, btnSize); } } // Guest House btnGuestHouse = new JButton("Guest House"); allRooms[9] = btnGuestHouse; btnGuestHouse.setPreferredSize(btnSize); cons.gridx = 30; cons.gridy = 20; cons.gridwidth = 5; cons.gridheight = 5; btnGuestHouse.setBackground(defaultRoomColor); btnGuestHouse.setOpaque(true); btnGuestHouse.setBorderPainted(false); btnGuestHouse.addActionListener(new myActionListener()); this.add(btnGuestHouse, cons); // textArea // ------------------------------------------------------------------------------------------ // create textarea for output cons.gridx = 0; cons.gridy = 25; cons.gridwidth = 35; this.add(jsp, cons); }
public void init() { areaventana = new JPanel(); areabotones = new JPanel(); imagen = new JLabel(""); presentacion = new JButton(imgPlay); siguiente = new JButton(imgSiguiente); atras = new JButton(imgAnterior); ptiempo = new JSlider(); carpeta = new JButton(imgNuevaCarpeta); grid = new JButton(imgGrid); bcomentario = new JButton(imgComentario); zoom = new JButton(imgZoom); /* Agregando los componentes */ areaventana.add(imagen); // areaventana.add(desplazamiento); areabotones.add(grid); areabotones.add(atras); areabotones.add(presentacion); areabotones.add(siguiente); areabotones.add(ptiempo); areabotones.add(carpeta); areabotones.add(bcomentario); areabotones.add(zoom); areabotones.setBackground(colorGris); areaventana.setBackground(colorGris); // desplazamiento.setVisible(false); // areaventana.add(desplazamiento); /* GUI GUI GUI GUI */ presentacion.setBackground(colorGris); atras.setBackground(colorGris); siguiente.setBackground(colorGris); carpeta.setBackground(colorGris); grid.setBackground(colorGris); ptiempo.setBackground(colorGris); bcomentario.setBackground(colorGris); zoom.setBackground(colorGris); presentacion.setPreferredSize(new Dimension(100, 80)); atras.setPreferredSize(new Dimension(100, 80)); siguiente.setPreferredSize(new Dimension(100, 80)); carpeta.setPreferredSize(new Dimension(100, 80)); grid.setPreferredSize(new Dimension(100, 80)); bcomentario.setPreferredSize(new Dimension(100, 80)); zoom.setPreferredSize(new Dimension(100, 80)); grid.setFocusPainted(false); atras.setFocusPainted(false); siguiente.setFocusPainted(false); carpeta.setFocusPainted(false); presentacion.setFocusPainted(false); bcomentario.setFocusPainted(false); zoom.setFocusPainted(false); grid.setBorder(null); atras.setBorder(null); siguiente.setBorder(null); carpeta.setBorder(null); presentacion.setBorder(null); areabotones.setBorder(null); areaventana.setBorder(null); bcomentario.setBorder(null); zoom.setBorder(null); /* GUI GUI GUI GUI */ /* Action Listeners */ siguiente.addActionListener(this); atras.addActionListener(this); presentacion.addActionListener(this); carpeta.addActionListener(this); grid.addActionListener(this); bcomentario.addActionListener(this); zoom.addActionListener(this); this.setLayout(new BorderLayout()); add(areaventana, BorderLayout.CENTER); add(areabotones, BorderLayout.SOUTH); ptiempo.setVisible(false); siguiente.setEnabled(false); atras.setEnabled(false); presentacion.setEnabled(false); grid.setEnabled(false); bcomentario.setEnabled(false); zoom.setEnabled(false); /* Abre el selector desde que inicia el programa */ chooser = new JFileChooser(); chooser.setDialogTitle("Selecciona una imagen..."); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); chooser.setAcceptAllFileFilterUsed(false); // Abrir archivo es de acá... returnChooser = chooser.showOpenDialog(ArcViewer.this); if (returnChooser == 0) { imagenes = lista.Miranda(chooser, returnChooser); siguiente.setEnabled(true); atras.setEnabled(true); presentacion.setEnabled(true); grid.setEnabled(true); bcomentario.setEnabled(true); zoom.setEnabled(true); for (int asd1 = 0; asd1 < imagenes.size(); asd1++) { imagenesbean.add(new ImagenBean(imagenes.get(asd1), 0, 0)); } String getImgSelected = chooser.getSelectedFile().getPath(); for (int index = 0; index < imagenesbean.size(); index++) { if (getImgSelected.equals(imagenesbean.get(index).getIcon())) { imagen.setIcon(new ImageIcon(imagenesbean.get(index).getIcon())); indexaux = index; } } } else { System.out.println("No Selection"); carpeta.setEnabled(true); } // for (int asd1=0; asd1 < imagenes.size(); asd1++) { // imagenesbean.add(new ImagenBean(imagenes.get(asd1),0,0)); // } // String getImgSelected = chooser.getSelectedFile().getPath(); // for (int index=0; index < imagenesbean.size(); index++) { // if (getImgSelected.equals( imagenesbean.get(index).getIcon() )) { // imagen.setIcon(new ImageIcon(imagenesbean.get(index).getIcon())); // indexaux = index; // } // } }
public NavigatorBar() { try { jbInit(); controlPageNr.setColumns(3); controlPageNr.setValue(new Integer(1)); controlPageNr.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (controlPageNr.getDouble() == null) controlPageNr.setValue(new Integer(1)); if (!checkValidPage()) return; currentPageNr = controlPageNr.getDouble().intValue(); gotoPage(); } }); controlPageNr.addFocusListener( new FocusAdapter() { public void focusGained(FocusEvent e) { if (controlPageNr.getDouble() == null) controlPageNr.setValue(new Integer(1)); currentPageNr = controlPageNr.getDouble().intValue(); } public void focusLost(FocusEvent e) { if (controlPageNr.getDouble() == null) controlPageNr.setValue(new Integer(1)); if (!checkValidPage()) return; int lastValue = currentPageNr; currentPageNr = controlPageNr.getDouble().intValue(); if (lastValue != currentPageNr) gotoPage(); } }); firstButton.setToolTipText( ClientSettings.getInstance() .getResources() .getResource("Load the first block of records")); firstButton.setPreferredSize(new Dimension(32, 32)); prevPgButton.setToolTipText( ClientSettings.getInstance() .getResources() .getResource("Load the previous block of records")); prevPgButton.setPreferredSize(new Dimension(32, 32)); prevButton.setToolTipText( ClientSettings.getInstance() .getResources() .getResource("Select the previous row in grid")); prevButton.setPreferredSize(new Dimension(32, 32)); nextButton.setToolTipText( ClientSettings.getInstance().getResources().getResource("Select the next row in grid")); nextButton.setPreferredSize(new Dimension(32, 32)); nextPgButton.setToolTipText( ClientSettings.getInstance() .getResources() .getResource("Load the next block of records")); nextPgButton.setPreferredSize(new Dimension(32, 32)); lastButton.setToolTipText( ClientSettings.getInstance() .getResources() .getResource("Load the last block of records")); lastButton.setPreferredSize(new Dimension(32, 32)); } catch (Exception e) { e.printStackTrace(); } }
/** ** Constructor. Sets up user interface and initializations */ public Secondtry() { operators = true; doClear = false; frame = new JFrame("Calculator"); frame.setLayout(new BorderLayout(10, 10)); display = new JTextArea(); display.setSize(245, 100); display.setFont(new Font("SansSerif", Font.BOLD, 28)); display.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); // create the numeric buttons for calculator for (int i = 0; i < 10; i++) { jb[i] = new JButton("" + (i)); jb[i].addActionListener(this); jb[i].setFont(new Font("SansSerif", Font.BOLD, 14)); } // create the square root button root = new JButton("\u221A"); root.addActionListener(this); root.setFont(new Font("SansSerif", Font.BOLD, 14)); // create the clear button clear = new JButton("C"); clear.addActionListener(this); clear.setFont(new Font("SansSerif", Font.BOLD, 14)); // create the plus button plus = new JButton("\u002B"); plus.addActionListener(this); plus.setFont(new Font("SansSerif", Font.BOLD, 14)); // create the minus button minus = new JButton("\u002D"); minus.addActionListener(this); minus.setFont(new Font("SansSerif", Font.BOLD, 14)); // create the multiply button mult = new JButton("\u002A"); mult.addActionListener(this); mult.setFont(new Font("SansSerif", Font.BOLD, 14)); // create the division button div = new JButton("\u002F"); div.addActionListener(this); div.setFont(new Font("SansSerif", Font.BOLD, 14)); // create the equals button equals = new JButton("\u003D"); equals.addActionListener(this); equals.setFont(new Font("SansSerif", Font.BOLD, 14)); equals.setPreferredSize(new Dimension(50, 60)); // create the point button point = new JButton("\u002E"); point.addActionListener(this); point.setFont(new Font("SansSerif", Font.BOLD, 14)); // button grid JPanel buttons = new JPanel(new GridLayout(5, 4, 4, 4)); // add buttons to grid buttons.add(clear); buttons.add(root); buttons.add(div); buttons.add(mult); // add numeric buttons to grid for (int i = 7; i < 10; i++) buttons.add(jb[i]); buttons.add(minus); // add numeric buttons to grid for (int i = 4; i < 7; i++) buttons.add(jb[i]); buttons.add(plus); // add numeric buttons to grid for (int i = 1; i < 4; i++) buttons.add(jb[i]); buttons.add(equals); buttons.add(jb[0]); buttons.add(point); frame.add(display, BorderLayout.CENTER); frame.add(buttons, BorderLayout.SOUTH); frame.setSize(300, 400); frame.setVisible(true); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }
// Here some legacy code makes use of generics. They are tested, so there // is no risk of an actual error, but Java issues a warning. @SuppressWarnings("unchecked") public DialogParameters( JFrame parent, Vector<ParameterDescription> vec, boolean strict, Vector<LayerDesc> layers) { super(parent, Globals.messages.getString("Param_opt"), true); keyb1 = new OSKeybPanel(KEYBMODES.GREEK); keyb2 = new OSKeybPanel(KEYBMODES.MISC); keyb1.setField(this); keyb2.setField(this); keyb.addTab("Greek", keyb1); keyb.addTab("Misc", keyb2); keyb.setVisible(false); v = vec; int ycount = 0; // We create dynamically all the needed elements. // For this reason, we work on arrays of the potentially useful Swing // objects. jtf = new JTextField[MAX_ELEMENTS]; jcb = new JCheckBox[MAX_ELEMENTS]; jco = new JComboBox[MAX_ELEMENTS]; active = false; addComponentListener(this); GridBagLayout bgl = new GridBagLayout(); GridBagConstraints constraints = new GridBagConstraints(); Container contentPane = getContentPane(); contentPane.setLayout(bgl); boolean extStrict = strict; ParameterDescription pd; int top = 0; JLabel lab; tc = 0; cc = 0; co = 0; // We process all parameter passed. Depending on its type, a // corresponding interface element will be created. // A symmetrical operation is done when validating parameters. for (ycount = 0; ycount < v.size(); ++ycount) { if (ycount > MAX) break; pd = (ParameterDescription) v.elementAt(ycount); // We do not need to store label objects, since we do not need // to retrieve data from them. lab = new JLabel(pd.description); constraints.weightx = 100; constraints.weighty = 100; constraints.gridx = 1; constraints.gridy = ycount; constraints.gridwidth = 1; constraints.gridheight = 1; // The first element needs a little bit more space at the top. if (ycount == 0) top = 10; else top = 0; // Here we configure the grid layout constraints.insets = new Insets(top, 20, 0, 6); constraints.fill = GridBagConstraints.VERTICAL; constraints.anchor = GridBagConstraints.EAST; lab.setEnabled(!(pd.isExtension && extStrict)); if (!(pd.parameter instanceof Boolean)) contentPane.add(lab, constraints); constraints.anchor = GridBagConstraints.WEST; constraints.insets = new Insets(top, 0, 0, 0); constraints.fill = GridBagConstraints.HORIZONTAL; // Now, depending on the type of parameter we create interface // elements and we populate the dialog. if (pd.parameter instanceof PointG) { jtf[tc] = new JTextField(10); jtf[tc].setText("" + ((PointG) (pd.parameter)).x); constraints.weightx = 100; constraints.weighty = 100; constraints.gridx = 2; constraints.gridy = ycount; constraints.gridwidth = 1; constraints.gridheight = 1; // Disable FidoCadJ extensions in the strict compatibility mode jtf[tc].setEnabled(!(pd.isExtension && extStrict)); contentPane.add(jtf[tc++], constraints); jtf[tc] = new JTextField(10); jtf[tc].setText("" + ((PointG) (pd.parameter)).y); constraints.weightx = 100; constraints.weighty = 100; constraints.gridx = 3; constraints.gridy = ycount; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.insets = new Insets(top, 6, 0, 20); constraints.fill = GridBagConstraints.HORIZONTAL; jtf[tc].setEnabled(!(pd.isExtension && extStrict)); contentPane.add(jtf[tc++], constraints); } else if (pd.parameter instanceof String) { jtf[tc] = new JTextField(24); jtf[tc].setText((String) (pd.parameter)); // If we have a String text field in the first position, its // contents should be evidenced, since it is supposed to be // the most important field (e.g. for the AdvText primitive) if (ycount == 0) jtf[tc].selectAll(); constraints.weightx = 100; constraints.weighty = 100; constraints.gridx = 2; constraints.gridy = ycount; constraints.gridwidth = 2; constraints.gridheight = 1; constraints.insets = new Insets(top, 0, 0, 20); constraints.fill = GridBagConstraints.HORIZONTAL; jtf[tc].setEnabled(!(pd.isExtension && extStrict)); contentPane.add(jtf[tc++], constraints); } else if (pd.parameter instanceof Boolean) { jcb[cc] = new JCheckBox(pd.description); jcb[cc].setSelected(((Boolean) (pd.parameter)).booleanValue()); constraints.weightx = 100; constraints.weighty = 100; constraints.gridx = 2; constraints.gridy = ycount; constraints.gridwidth = 2; constraints.gridheight = 1; constraints.insets = new Insets(top, 0, 0, 20); constraints.fill = GridBagConstraints.HORIZONTAL; jcb[cc].setEnabled(!(pd.isExtension && extStrict)); contentPane.add(jcb[cc++], constraints); } else if (pd.parameter instanceof Integer) { jtf[tc] = new JTextField(24); jtf[tc].setText(((Integer) pd.parameter).toString()); constraints.weightx = 100; constraints.weighty = 100; constraints.gridx = 2; constraints.gridy = ycount; constraints.gridwidth = 2; constraints.gridheight = 1; constraints.insets = new Insets(top, 0, 0, 20); constraints.fill = GridBagConstraints.HORIZONTAL; jtf[tc].setEnabled(!(pd.isExtension && extStrict)); contentPane.add(jtf[tc++], constraints); } else if (pd.parameter instanceof Float) { // TODO. // WARNING: (DB) this is supposed to be temporary. In fact, I // am planning to upgrade some of the parameters from int // to float. But for a few months, the users should not be // aware of that, even if the internal representation is // slowing being adapted. jtf[tc] = new JTextField(24); int dummy = java.lang.Math.round((Float) pd.parameter); jtf[tc].setText("" + dummy); constraints.weightx = 100; constraints.weighty = 100; constraints.gridx = 2; constraints.gridy = ycount; constraints.gridwidth = 2; constraints.gridheight = 1; constraints.insets = new Insets(top, 0, 0, 20); constraints.fill = GridBagConstraints.HORIZONTAL; jtf[tc].setEnabled(!(pd.isExtension && extStrict)); contentPane.add(jtf[tc++], constraints); } else if (pd.parameter instanceof FontG) { GraphicsEnvironment gE; gE = GraphicsEnvironment.getLocalGraphicsEnvironment(); String[] s = gE.getAvailableFontFamilyNames(); jco[co] = new JComboBox(); for (int i = 0; i < s.length; ++i) { jco[co].addItem(s[i]); if (s[i].equals(((FontG) pd.parameter).getFamily())) jco[co].setSelectedIndex(i); } constraints.weightx = 100; constraints.weighty = 100; constraints.gridx = 2; constraints.gridy = ycount; constraints.gridwidth = 2; constraints.gridheight = 1; constraints.insets = new Insets(top, 0, 0, 20); constraints.fill = GridBagConstraints.HORIZONTAL; jco[co].setEnabled(!(pd.isExtension && extStrict)); contentPane.add(jco[co++], constraints); } else if (pd.parameter instanceof LayerInfo) { jco[co] = new JComboBox(new Vector<LayerDesc>(layers)); jco[co].setSelectedIndex(((LayerInfo) pd.parameter).layer); jco[co].setRenderer(new LayerCellRenderer()); constraints.weightx = 100; constraints.weighty = 100; constraints.gridx = 2; constraints.gridy = ycount; constraints.gridwidth = 2; constraints.gridheight = 1; constraints.insets = new Insets(top, 0, 0, 20); constraints.fill = GridBagConstraints.HORIZONTAL; jco[co].setEnabled(!(pd.isExtension && extStrict)); contentPane.add(jco[co++], constraints); } else if (pd.parameter instanceof ArrowInfo) { jco[co] = new JComboBox<ArrowInfo>(); jco[co].addItem(new ArrowInfo(0)); jco[co].addItem(new ArrowInfo(1)); jco[co].addItem(new ArrowInfo(2)); jco[co].addItem(new ArrowInfo(3)); jco[co].setSelectedIndex(((ArrowInfo) pd.parameter).style); jco[co].setRenderer(new ArrowCellRenderer()); constraints.weightx = 100; constraints.weighty = 100; constraints.gridx = 2; constraints.gridy = ycount; constraints.gridwidth = 2; constraints.gridheight = 1; constraints.insets = new Insets(top, 0, 0, 20); constraints.fill = GridBagConstraints.HORIZONTAL; jco[co].setEnabled(!(pd.isExtension && extStrict)); contentPane.add(jco[co++], constraints); } else if (pd.parameter instanceof DashInfo) { jco[co] = new JComboBox<DashInfo>(); for (int k = 0; k < Globals.dashNumber; ++k) { jco[co].addItem(new DashInfo(k)); } jco[co].setSelectedIndex(((DashInfo) pd.parameter).style); jco[co].setRenderer(new DashCellRenderer()); constraints.weightx = 100; constraints.weighty = 100; constraints.gridx = 2; constraints.gridy = ycount; constraints.gridwidth = 2; constraints.gridheight = 1; constraints.insets = new Insets(top, 0, 0, 20); constraints.fill = GridBagConstraints.HORIZONTAL; jco[co].setEnabled(!(pd.isExtension && extStrict)); contentPane.add(jco[co++], constraints); } } // Put the OK and Cancel buttons and make them active. JButton ok = new JButton(Globals.messages.getString("Ok_btn")); JButton cancel = new JButton(Globals.messages.getString("Cancel_btn")); JButton keybd = new JButton("\u00B6\u2211\u221A"); // phylum keybd.setFocusable(false); keybd.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { // If at this point, the keyboard is not visible, this means // that it will become visible in a while. It is better to // resize first and then show up the keyboard. if (keyb.isVisible()) { MIN_WIDTH = 400; MIN_HEIGHT = 350; } else { MIN_WIDTH = 400; MIN_HEIGHT = 500; } // setSize(MIN_WIDTH, MIN_HEIGHT); keyb.setVisible(!keyb.isVisible()); pack(); } }); constraints.gridx = 0; constraints.gridy = ycount++; constraints.gridwidth = 4; constraints.gridheight = 1; constraints.anchor = GridBagConstraints.EAST; constraints.insets = new Insets(6, 20, 20, 20); // Put the OK and Cancel buttons and make them active. Box b = Box.createHorizontalBox(); b.add(keybd); // phylum b.add(Box.createHorizontalGlue()); ok.setPreferredSize(cancel.getPreferredSize()); if (Globals.okCancelWinOrder) { b.add(ok); b.add(Box.createHorizontalStrut(12)); b.add(cancel); } else { b.add(cancel); b.add(Box.createHorizontalStrut(12)); b.add(ok); } // b.add(Box.createHorizontalStrut(12)); contentPane.add(b, constraints); constraints.gridx = 0; constraints.gridy = ycount; constraints.gridwidth = 4; constraints.gridheight = 1; constraints.anchor = GridBagConstraints.EAST; constraints.insets = new Insets(6, 20, 20, 20); contentPane.add(keyb, constraints); ok.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent evt) { try { int ycount; ParameterDescription pd; tc = 0; cc = 0; co = 0; // Here we read all the contents of the interface and we // update the contents of the parameter description array. for (ycount = 0; ycount < v.size(); ++ycount) { if (ycount > MAX) break; pd = (ParameterDescription) v.elementAt(ycount); if (pd.parameter instanceof PointG) { ((PointG) (pd.parameter)).x = Integer.parseInt(jtf[tc++].getText()); ((PointG) (pd.parameter)).y = Integer.parseInt(jtf[tc++].getText()); } else if (pd.parameter instanceof String) { pd.parameter = jtf[tc++].getText(); } else if (pd.parameter instanceof Boolean) { pd.parameter = Boolean.valueOf(jcb[cc++].isSelected()); } else if (pd.parameter instanceof Integer) { pd.parameter = Integer.valueOf(Integer.parseInt(jtf[tc++].getText())); } else if (pd.parameter instanceof Float) { pd.parameter = Float.valueOf(Float.parseFloat(jtf[tc++].getText())); } else if (pd.parameter instanceof FontG) { pd.parameter = new FontG((String) jco[co++].getSelectedItem()); } else if (pd.parameter instanceof LayerInfo) { pd.parameter = new LayerInfo(jco[co++].getSelectedIndex()); } else if (pd.parameter instanceof ArrowInfo) { pd.parameter = new ArrowInfo(jco[co++].getSelectedIndex()); } else if (pd.parameter instanceof DashInfo) { pd.parameter = new DashInfo(jco[co++].getSelectedIndex()); } } } catch (NumberFormatException E) { // Error detected. Probably, the user has entered an // invalid string when FidoCadJ was expecting a numerical // input. JOptionPane.showMessageDialog( null, Globals.messages.getString("Format_invalid"), "", JOptionPane.INFORMATION_MESSAGE); return; } active = true; // Globals.activeWindow.setEnabled(true); setVisible(false); keyb.setVisible(false); } }); cancel.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent evt) { // Globals.activeWindow.setEnabled(true); setVisible(false); keyb.setVisible(false); } }); // Here is an action in which the dialog is closed AbstractAction cancelAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { // Globals.activeWindow.setEnabled(true); setVisible(false); keyb.setVisible(false); } }; DialogUtil.addCancelEscape(this, cancelAction); this.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { // Globals.activeWindow.setEnabled(true); keyb.setVisible(false); } }); pack(); DialogUtil.center(this); getRootPane().setDefaultButton(ok); }
public SmartToolBar(RuntimeConfigFrame fr) { frame = fr; setFloatable(true); treeCombo = new TreeCombo(frame.model); treeCombo.addActionListener(new ComboListener()); treeCombo.setPreferredSize(new Dimension(210, 25)); treeCombo.setMinimumSize(new Dimension(210, 25)); treeCombo.setMaximumSize(new Dimension(210, 25)); add(treeCombo); addSeparator(); addSeparator(); addSeparator(); ToolBarAction toolBarAction = new ToolBarAction(); JButton saveAsButton = add(toolBarAction); ImageIcon icon = frame .getCommonBuilderUIImpl() .getScaledImage("file.png", "images/runtimeadmin", 28, 28, Image.SCALE_DEFAULT); saveAsButton.setPreferredSize(new Dimension(28, 28)); saveAsButton.setMinimumSize(new Dimension(28, 28)); saveAsButton.setMaximumSize(new Dimension(28, 28)); saveAsButton.setBorderPainted(false); saveAsButton.setIcon(icon); icon = frame .getCommonBuilderUIImpl() .getScaledImage("file_mo.png", "images/runtimeadmin", 28, 28, Image.SCALE_DEFAULT); saveAsButton.setRolloverIcon(icon); saveAsButton.setActionCommand("Apply To Server"); saveAsButton.setToolTipText(RuntimeConfigFrame.getString("Apply To Server")); addSeparator(); JButton close = add(toolBarAction); icon = frame .getCommonBuilderUIImpl() .getScaledImage("exit.png", "images/", 28, 28, Image.SCALE_DEFAULT); close.setPreferredSize(new Dimension(28, 28)); close.setMinimumSize(new Dimension(28, 28)); close.setMaximumSize(new Dimension(28, 28)); close.setIcon(icon); close.setBorderPainted(false); icon = frame .getCommonBuilderUIImpl() .getScaledImage("exit_mo.png", "images/", 28, 28, Image.SCALE_DEFAULT); close.setRolloverIcon(icon); close.setActionCommand("Close"); close.setToolTipText(RuntimeConfigFrame.getString("Close")); addSeparator(); JButton help = add(toolBarAction); icon = frame .getCommonBuilderUIImpl() .getScaledImage("toolhelp.png", "images/", 28, 28, Image.SCALE_DEFAULT); help.setPreferredSize(new Dimension(28, 28)); help.setMinimumSize(new Dimension(28, 28)); help.setMaximumSize(new Dimension(28, 28)); help.setBorderPainted(false); help.setIcon(icon); icon = frame .getCommonBuilderUIImpl() .getScaledImage("toolhelp_mo.png", "images/", 28, 28, Image.SCALE_DEFAULT); help.setRolloverIcon(icon); help.setActionCommand("Help Contents"); help.setToolTipText(RuntimeConfigFrame.getString("Help")); // addSeparator(); }
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); }
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 jbInit() throws Exception { saveButton.setText("Save"); saveButton.addActionListener(new PrintfTemplateEditor_saveButton_actionAdapter(this)); cancelButton.setText("Cancel"); cancelButton.addActionListener(new PrintfTemplateEditor_cancelButton_actionAdapter(this)); this.setTitle(this.getTitle() + " Template Editor"); printfPanel.setLayout(gridBagLayout1); formatLabel.setFont(new java.awt.Font("DialogInput", 0, 12)); formatLabel.setText("Format String:"); buttonPanel.setLayout(flowLayout1); printfPanel.setBorder(BorderFactory.createEtchedBorder()); printfPanel.setMinimumSize(new Dimension(100, 160)); printfPanel.setPreferredSize(new Dimension(380, 160)); parameterPanel.setLayout(gridBagLayout2); parameterLabel.setText("Parameters:"); parameterLabel.setFont(new java.awt.Font("DialogInput", 0, 12)); parameterTextArea.setMinimumSize(new Dimension(100, 25)); parameterTextArea.setPreferredSize(new Dimension(200, 25)); parameterTextArea.setEditable(true); parameterTextArea.setText(""); insertButton.setMaximumSize(new Dimension(136, 20)); insertButton.setMinimumSize(new Dimension(136, 20)); insertButton.setPreferredSize(new Dimension(136, 20)); insertButton.setToolTipText( "insert the format in the format string and add parameter to list."); insertButton.setText("Insert Parameter"); insertButton.addActionListener(new PrintfTemplateEditor_insertButton_actionAdapter(this)); formatTextArea.setMinimumSize(new Dimension(100, 25)); formatTextArea.setPreferredSize(new Dimension(200, 15)); formatTextArea.setText(""); parameterPanel.setBorder(null); parameterPanel.setMinimumSize(new Dimension(60, 40)); parameterPanel.setPreferredSize(new Dimension(300, 40)); insertMatchButton.addActionListener( new PrintfTemplateEditor_insertMatchButton_actionAdapter(this)); insertMatchButton.setText("Insert Match"); insertMatchButton.setToolTipText( "insert the match in the format string and add parameter to list."); insertMatchButton.setPreferredSize(new Dimension(136, 20)); insertMatchButton.setMinimumSize(new Dimension(136, 20)); insertMatchButton.setMaximumSize(new Dimension(136, 20)); matchPanel.setPreferredSize(new Dimension(300, 40)); matchPanel.setBorder(null); matchPanel.setMinimumSize(new Dimension(60, 60)); matchPanel.setLayout(gridBagLayout3); InsertPanel.setLayout(gridLayout1); gridLayout1.setColumns(1); gridLayout1.setRows(2); gridLayout1.setVgap(0); InsertPanel.setBorder(BorderFactory.createEtchedBorder()); InsertPanel.setMinimumSize(new Dimension(100, 100)); InsertPanel.setPreferredSize(new Dimension(380, 120)); editorPane.setText(""); editorPane.addKeyListener(new PrintfEditor_editorPane_keyAdapter(this)); printfTabPane.addChangeListener(new PrintfEditor_printfTabPane_changeAdapter(this)); parameterPanel.add( insertButton, new GridBagConstraints( 1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(8, 6, 13, 8), 0, 10)); parameterPanel.add( paramComboBox, new GridBagConstraints( 0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(8, 8, 13, 0), 258, 11)); paramComboBox.setRenderer(new MyCellRenderer()); InsertPanel.add(matchPanel, null); InsertPanel.add(parameterPanel, null); buttonPanel.add(cancelButton, null); buttonPanel.add(saveButton, null); this.getContentPane().add(printfTabPane, BorderLayout.NORTH); this.getContentPane().add(InsertPanel, BorderLayout.CENTER); matchPanel.add( insertMatchButton, new GridBagConstraints( 1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(8, 6, 13, 8), 0, 10)); matchPanel.add( matchComboBox, new GridBagConstraints( 0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(8, 8, 13, 0), 258, 11)); printfPanel.add( parameterLabel, new GridBagConstraints( 0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(7, 5, 0, 5), 309, 0)); printfPanel.add( formatLabel, new GridBagConstraints( 0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(4, 5, 0, 5), 288, 0)); printfPanel.add( formatTextArea, new GridBagConstraints( 0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(6, 5, 0, 5), 300, 34)); printfPanel.add( parameterTextArea, new GridBagConstraints( 0, 3, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(6, 5, 6, 5), 300, 34)); printfTabPane.addTab("Editor View", null, editorPanel, "View in Editor"); printfTabPane.addTab("Printf View", null, printfPanel, "Vies as Printf"); editorPane.setCharacterAttributes(PLAIN_ATTR, true); editorPane.addStyle("PLAIN", editorPane.getLogicalStyle()); editorPanel.getViewport().add(editorPane, null); this.getContentPane().add(buttonPanel, BorderLayout.SOUTH); buttonGroup.add(cancelButton); }
private void initializeComponents() { this.setTitle("Synchro - Kopierassistent"); this.setBounds(0, 0, 550, 600); this.setResizable(true); this.setLayout(null); this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); this.addWindowListener(this); mainPanel = new JPanel(); mainPanel.setBounds(0, 0, this.getWidth() - 20, 25); // fcPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK)); mainPanel.setLayout(null); btnBackup = new JButton("Backup"); btnBackup.setBounds(this.getWidth() / 2, 0, this.getWidth() / 2 - 20, mainPanel.getHeight()); btnBackup.addActionListener(this); mainPanel.add(btnBackup); this.add(mainPanel); fcPanel = new JPanel(); fcPanel.setBounds(10, 40, this.getWidth(), 260); // fcPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK)); fcPanel.setLayout(null); quellLabel = new JLabel("Bitte Quellverzeichnis auswählen"); quellLabel.setBounds(10, 5, 320, 20); fcPanel.add(quellLabel); quellListModel = new DefaultListModel<>(); quellJList = new JList<ListItem>(quellListModel); quellJList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); quellJList.setLayoutOrientation(JList.VERTICAL); quellJList.addListSelectionListener(this); listBoxScroller = new JScrollPane(quellJList); listBoxScroller.setBounds(0, 30, 315, 100); fcPanel.add(listBoxScroller); btnQAuswahl = new JButton("Quellverz. hinzufügen"); btnQAuswahl.setBounds(320, 30, 200, 25); btnQAuswahl.addActionListener(this); fcPanel.add(btnQAuswahl); btnQEntfernen = new JButton("Quellverz. entfernen"); btnQEntfernen.setBounds(320, 60, 200, 25); btnQEntfernen.addActionListener(this); fcPanel.add(btnQEntfernen); zielLabel = new JLabel("Bitte Zielverzeichnis auswählen"); zielLabel.setBounds(10, 135, 320, 20); fcPanel.add(zielLabel); zielListModel = new DefaultListModel<>(); zielJList = new JList<ListItem>(zielListModel); zielJList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); zielJList.setLayoutOrientation(JList.VERTICAL); zielJList.addListSelectionListener(this); listBoxScroller2 = new JScrollPane(zielJList); listBoxScroller2.setBounds(0, 160, 315, 100); fcPanel.add(listBoxScroller2); btnZAuswahl = new JButton("Zielverz. hinzufügen"); btnZAuswahl.setBounds(320, 160, 200, 25); btnZAuswahl.addActionListener(this); fcPanel.add(btnZAuswahl); btnZEntfernen = new JButton("Zielverz. entfernen"); btnZEntfernen.setBounds(320, 190, 200, 25); btnZEntfernen.addActionListener(this); fcPanel.add(btnZEntfernen); this.add(fcPanel); ButtonGroup bGrp = new ButtonGroup(); optionPanel = new JPanel(); optionPanel.setBounds(10, 300 + 10, this.getWidth() - 40, 90); optionPanel.setPreferredSize(new Dimension(this.getWidth() - 40, 90)); // optionPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK)); optionPanel.setLayout(new GridLayout(3, 1)); nUebSchr = new JRadioButton("Keine Dateien überschreiben"); nUebSchr.addItemListener(this); bGrp.add(nUebSchr); optionPanel.add(nUebSchr); ueSchr = new JRadioButton("Neuere Dateien überschreiben"); ueSchr.addItemListener(this); bGrp.add(ueSchr); optionPanel.add(ueSchr); aUeSchr = new JRadioButton("Alle Dateien überschreiben"); aUeSchr.addItemListener(this); bGrp.add(aUeSchr); optionPanel.add(aUeSchr); this.add(optionPanel); syncPanel = new JPanel(); syncPanel.setBounds( 10, optionPanel.getY() + optionPanel.getHeight() + 10, this.getWidth() - 30, 25); // syncPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK)); syncPanel.setLayout(new BorderLayout()); btnSync = new JButton("Sync it!"); btnSync.setBounds(0, 0, 150, (syncPanel.getHeight() / 3)); btnSync.addActionListener(this); btnSync.setPreferredSize(new Dimension(150, (syncPanel.getHeight() / 3))); btnSync.setMaximumSize(new Dimension(150, (syncPanel.getHeight() / 3))); syncPanel.add(btnSync, BorderLayout.LINE_START); btnAbbruch = new JButton("Abbrechen"); btnAbbruch.setBounds(0, 0, 150, (syncPanel.getHeight() / 3)); btnAbbruch.addActionListener(this); btnAbbruch.setPreferredSize(new Dimension(150, (syncPanel.getHeight() / 3))); btnAbbruch.setMaximumSize(new Dimension(150, (syncPanel.getHeight() / 3))); btnAbbruch.setVisible(false); syncPanel.add(btnAbbruch, BorderLayout.LINE_END); progressBar = new JProgressBar(JProgressBar.HORIZONTAL); progressBar.setBorderPainted(true); progressBar.setPreferredSize(new Dimension(300, (syncPanel.getHeight() / 3))); progressBar.setForeground(Color.RED); progressBar.setStringPainted(true); progressBar.setVisible(true); syncPanel.add(progressBar, BorderLayout.CENTER); this.add(syncPanel); logPanel = new JPanel(); logPanel.setBounds( 10, syncPanel.getY() + syncPanel.getHeight() + 10, this.getWidth() - 30, 105); logPanel.setLayout(new BorderLayout()); textArea = new JTextArea(); textArea.setMargin(new Insets(3, 3, 3, 3)); textArea.setBackground(Color.black); textArea.setForeground(Color.LIGHT_GRAY); textArea.setAutoscrolls(true); textArea.setFocusable(false); textAreaScroller = new JScrollPane(textArea); DefaultCaret caret = (DefaultCaret) textArea.getCaret(); caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); textAreaScroller.setBounds(0, 0, syncPanel.getWidth(), 50); logPanel.add(textAreaScroller, BorderLayout.CENTER); this.add(logPanel, BorderLayout.SOUTH); }
public void initializeComponents( DiscountCardsTableModel tableModel, MessageSource messageSource, LocaleHolder localeHolder) { this.tableModel = tableModel; this.filters = new ArrayList<>(); FiltersPurpose filtersPurpose = tableModel.getFiltersPurpose(); FilterElementsListener filterElementsListener = new FilterElementsListener(); // panel for search operations filtersPanel = new JPanel(); filtersPanel.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder( messageSource.getMessage( "mainForm.panel.search.title", null, localeHolder.getLocale())), BorderFactory.createEmptyBorder())); filtersPanel.setLayout(new GridBagLayout()); GridBagConstraints constraints = new GridBagConstraints(); constraints.fill = GridBagConstraints.HORIZONTAL; constraints.insets = new Insets(1, 5, 1, 5); boolean allCardsPurpose = FiltersPurpose.ALL_DISCOUNT_CARDS == filtersPurpose; for (Field field : DiscountCardJdo.class.getDeclaredFields()) { FilterColumn filterColumn = field.getAnnotation(FilterColumn.class); if (filterColumn != null) { if (allCardsPurpose && filterColumn.showForAllDiscountCards()) { FilterUnit filterUnit = new FilterUnit(); if (allCardsPurpose) { filterUnit.order = filterColumn.orderForAllDiscountCards(); } filterUnit.order = filterUnit.order == 0 ? Integer.MAX_VALUE : filterUnit.order; filterUnit.filterType = filterColumn.type(); filterUnit.columnTitle = getColumnTitle(field, messageSource, localeHolder); filterUnit.columnDatePattern = getColumnDatePattern(field); if (!filterColumn.labelKey().isEmpty()) { filterUnit.label = new JLabel( messageSource.getMessage( filterColumn.labelKey(), null, localeHolder.getLocale())); filterUnit.textField = new JTextField(filterColumn.editSize()); filterUnit.textField.getDocument().addDocumentListener(filterElementsListener); } if (filterColumn.checkBoxesNumber() > 0) { filterUnit.checkBoxes = new JCheckBox[filterColumn.checkBoxesNumber()]; for (int i = 0; i < filterColumn.checkBoxesNumber(); ++i) { String text = messageSource.getMessage( filterColumn.checkBoxesText()[i], null, localeHolder.getLocale()); String actionCommand = messageSource.getMessage( filterColumn.checkBoxesAction()[i], null, localeHolder.getLocale()); filterUnit.checkBoxes[i] = new JCheckBox(text); filterUnit.checkBoxes[i].setActionCommand(actionCommand); if (field.getName().equals("activationDate")) { filterUnit.checkBoxes[i].setSelected(true); } else { filterUnit.checkBoxes[i].setSelected(false); } filterUnit.checkBoxes[i].addItemListener( new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { int state = e.getStateChange(); if (state == ItemEvent.SELECTED) { applyFilters(); updateAnalyzeComponent(); } else if (state == ItemEvent.DESELECTED) { applyFilters(); updateAnalyzeComponent(); } } }); } } filters.add(filterUnit); } } } Collections.sort( filters, new Comparator<FilterUnit>() { @Override public int compare(FilterUnit filterUnit1, FilterUnit filterUnit2) { return filterUnit1.order - filterUnit2.order; } }); for (int i = 0; i < filters.size(); ++i) { if (filters.get(i).label != null) { filters.get(i).label.setLabelFor(filters.get(i).textField); constraints.fill = GridBagConstraints.NONE; constraints.gridwidth = GridBagConstraints.RELATIVE; constraints.anchor = GridBagConstraints.EAST; constraints.weightx = 0.0; filtersPanel.add(filters.get(i).label, constraints); constraints.fill = GridBagConstraints.HORIZONTAL; constraints.gridwidth = GridBagConstraints.REMAINDER; constraints.anchor = GridBagConstraints.EAST; constraints.weightx = 1.0; filtersPanel.add(filters.get(i).textField, constraints); } else if (filters.get(i).checkBoxes != null) { JPanel checkBoxPanel = new JPanel(); checkBoxPanel.setLayout(new BoxLayout(checkBoxPanel, BoxLayout.LINE_AXIS)); checkBoxPanel.add(Box.createHorizontalGlue()); for (int j = 0; j < filters.get(i).checkBoxes.length; ++j) { checkBoxPanel.add(filters.get(i).checkBoxes[j]); checkBoxPanel.add(Box.createHorizontalGlue()); } constraints.fill = GridBagConstraints.HORIZONTAL; constraints.gridwidth = GridBagConstraints.REMAINDER; constraints.anchor = GridBagConstraints.EAST; constraints.weightx = 1.0; filtersPanel.add(checkBoxPanel, constraints); } } JButton clearSearchButton = new JButton( messageSource.getMessage( "mainForm.button.clear.title", null, localeHolder.getLocale())); clearSearchButton.setPreferredSize(new Dimension(500, 20)); clearSearchButton.setMaximumSize(new Dimension(500, 20)); clearSearchButton.setMinimumSize(new Dimension(500, 20)); constraints.gridx = 1; constraints.gridy = filters.size() + 1; constraints.gridwidth = GridBagConstraints.REMAINDER; constraints.anchor = GridBagConstraints.EAST; constraints.weightx = 1.0; clearSearchButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { for (FilterUnit filterUnit : filters) { if (filterUnit.label != null) { filterUnit.textField.setText(""); } else if (filterUnit.checkBoxes != null) { for (int j = 0; j < filterUnit.checkBoxes.length; ++j) { filterUnit.checkBoxes[j].setSelected(true); } } } } }); filtersPanel.add(clearSearchButton, constraints); sorter = new TableRowSorter<>(tableModel); cardAnalyzeComponent.initializeComponents(tableModel, messageSource, localeHolder); }