List of usage examples for java.awt GridBagConstraints REMAINDER
int REMAINDER
To view the source code for java.awt GridBagConstraints REMAINDER.
Click Source Link
From source file:org.openconcerto.erp.core.sales.credit.component.AvoirClientSQLComponent.java
public void addViews() { this.setLayout(new GridBagLayout()); final GridBagConstraints c = new DefaultGridBagConstraints(); textNumero = new JUniqueTextField(16); // Champ Module c.gridx = 0;/*from w ww . j av a 2 s. c o m*/ c.gridy++; c.gridwidth = GridBagConstraints.REMAINDER; final JPanel addP = ComptaSQLConfElement.createAdditionalPanel(); this.setAdditionalFieldsPanel(new FormLayouter(addP, 1)); this.add(addP, c); c.gridy++; c.gridwidth = 1; this.textNom = new JTextField(); this.date = new JDate(true); this.date.addValueListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { fireValidChange(); } }); // Ligne 1: Numero this.add(new JLabel(getLabelFor("NUMERO"), SwingConstants.RIGHT), c); c.weightx = 1; c.fill = GridBagConstraints.NONE; c.gridx++; DefaultGridBagConstraints.lockMinimumSize(textNumero); this.add(this.textNumero, c); // Date c.gridx++; c.weightx = 0; c.fill = GridBagConstraints.HORIZONTAL; this.add(new JLabel("Date", SwingConstants.RIGHT), c); c.gridx++; c.weightx = 1; c.fill = GridBagConstraints.NONE; this.add(this.date, c); // Ligne 2: Libell c.gridx = 0; c.gridy++; c.weightx = 0; c.fill = GridBagConstraints.HORIZONTAL; this.add(new JLabel(getLabelFor("NOM"), SwingConstants.RIGHT), c); c.gridx++; // c.weightx = 1; this.add(this.textNom, c); // Commercial c.gridx++; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0; this.comboCommercial = new ElementComboBox(); this.comboCommercial.setMinimumSize(this.comboCommercial.getPreferredSize()); this.add(new JLabel(getLabelFor("ID_COMMERCIAL"), SwingConstants.RIGHT), c); c.gridx++; // c.weightx = 1; c.fill = GridBagConstraints.NONE; this.add(this.comboCommercial, c); this.addSQLObject(this.comboCommercial, "ID_COMMERCIAL"); // Ligne 3: Motif c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 0; c.gridy++; c.weightx = 0; this.add(new JLabel(getLabelFor("MOTIF"), SwingConstants.RIGHT), c); c.gridx++; c.gridwidth = 3; // c.weightx = 1; JTextField textMotif = new JTextField(); this.add(textMotif, c); // Client c.gridx = 0; c.gridy++; // c.weightx = 0; c.gridwidth = 1; this.add(new JLabel(getLabelFor("ID_CLIENT"), SwingConstants.RIGHT), c); c.gridx++; c.gridwidth = 3; // c.weightx = 1; c.fill = GridBagConstraints.NONE; this.add(this.comboClient, c); // Adresse spe c.gridx = 0; c.gridy++; c.fill = GridBagConstraints.HORIZONTAL; // c.weightx = 0; c.gridwidth = 1; this.add(new JLabel(getLabelFor("ID_ADRESSE"), SwingConstants.RIGHT), c); c.gridx++; c.gridwidth = 3; // c.weightx = 1; c.fill = GridBagConstraints.NONE; this.add(this.comboAdresse, c); final ComptaPropsConfiguration comptaPropsConfiguration = ((ComptaPropsConfiguration) Configuration .getInstance()); // Contact c.gridx = 0; c.gridy++; c.gridwidth = 1; c.fill = GridBagConstraints.HORIZONTAL; // c.weightx = 0; final JLabel labelContact = new JLabel(getLabelFor("ID_CONTACT"), SwingConstants.RIGHT); this.add(labelContact, c); c.gridx++; c.gridwidth = 3; // c.weightx = 1; c.fill = GridBagConstraints.NONE; this.add(selectContact, c); final SQLElement contactElement = getElement().getForeignElement("ID_CONTACT"); selectContact.init(contactElement, contactElement.getComboRequest(true)); this.addView(selectContact, "ID_CONTACT"); this.defaultContactRowValues = new SQLRowValues(selectContact.getRequest().getPrimaryTable()); selectContact.getAddComp().setDefaults(this.defaultContactRowValues); // Compte Service this.checkCompteServiceAuto = new JCheckBox(getLabelFor("COMPTE_SERVICE_AUTO")); this.addSQLObject(this.checkCompteServiceAuto, "COMPTE_SERVICE_AUTO"); this.compteSelService = new ISQLCompteSelector(); this.labelCompteServ = new JLabel("Compte Service"); c.gridy++; c.gridx = 0; c.gridwidth = 1; // c.weightx = 0; this.labelCompteServ.setHorizontalAlignment(SwingConstants.RIGHT); this.add(this.labelCompteServ, c); c.gridx++; c.gridwidth = GridBagConstraints.REMAINDER; // c.weightx = 1; this.add(this.compteSelService, c); this.addRequiredSQLObject(this.compteSelService, "ID_COMPTE_PCE_SERVICE"); String valServ = DefaultNXProps.getInstance().getStringProperty("ArticleService"); Boolean bServ = Boolean.valueOf(valServ); if (!bServ) { this.labelCompteServ.setVisible(false); this.compteSelService.setVisible(false); } this.checkCompteServiceAuto.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setCompteServiceVisible(!AvoirClientSQLComponent.this.checkCompteServiceAuto.isSelected()); } }); // setCompteServiceVisible(!(bServ != null && !bServ.booleanValue())); // Tarif if (this.getTable().getFieldsName().contains("ID_TARIF")) { // TARIF c.gridy++; c.gridx = 0; c.weightx = 0; c.weighty = 0; c.gridwidth = 1; this.add(new JLabel("Tarif appliquer", SwingConstants.RIGHT), c); c.gridx++; c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 1; this.add(boxTarif, c); this.addView(boxTarif, "ID_TARIF"); boxTarif.addValueListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { table.setTarif(boxTarif.getSelectedRow(), false); } }); } // Table this.table = new AvoirItemTable(); c.gridx = 0; c.gridy++; c.fill = GridBagConstraints.BOTH; c.gridheight = 1; c.gridwidth = GridBagConstraints.REMAINDER; c.weighty = 1; // c.weightx = 0; this.add(this.table, c); this.addView(this.table.getRowValuesTable(), ""); // Panel du bas final JPanel panelBottom = getBottomPanel(); c.gridy++; c.weighty = 0; this.add(panelBottom, c); // Infos c.gridheight = 1; c.gridx = 0; c.gridy++; this.add(new JLabel(getLabelFor("INFOS")), c); c.gridy++; c.fill = GridBagConstraints.BOTH; c.weighty = 0; c.gridwidth = 4; ITextArea infos = new ITextArea(4, 4); infos.setBorder(null); JScrollPane scrollPane = new JScrollPane(infos); DefaultGridBagConstraints.lockMinimumSize(scrollPane); this.add(scrollPane, c); // // Impression this.panelGestDoc = new PanelOOSQLComponent(this); c.fill = GridBagConstraints.NONE; c.gridy++; c.anchor = GridBagConstraints.EAST; this.add(panelGestDoc, c); this.addSQLObject(this.textNom, "NOM"); if (getTable().contains("INFOS")) { this.addSQLObject(infos, "INFOS"); } this.addSQLObject(this.boxAdeduire, "A_DEDUIRE"); this.addSQLObject(textMotif, "MOTIF"); this.addSQLObject(this.comboAdresse, "ID_ADRESSE"); this.addRequiredSQLObject(this.textNumero, "NUMERO"); this.addRequiredSQLObject(this.date, "DATE"); this.addRequiredSQLObject(this.comboClient, "ID_CLIENT"); this.boxAdeduire.addActionListener(this); this.comboClient.addModelListener("wantedID", this.listenerModeReglDefaut); this.comboClient.addModelListener("wantedID", this.changeClientListener); DefaultGridBagConstraints.lockMinimumSize(comboClient); DefaultGridBagConstraints.lockMinimumSize(this.comboAdresse); DefaultGridBagConstraints.lockMinimumSize(this.comboBanque); DefaultGridBagConstraints.lockMinimumSize(comboCommercial); }
From source file:pcgen.gui2.prefs.OutputPanel.java
/** * Instantiates a new output panel./*from w w w . j av a2 s . c o m*/ */ public OutputPanel() { GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); JLabel label; Border etched = null; TitledBorder title1 = BorderFactory.createTitledBorder(etched, IN_OUTPUT); title1.setTitleJustification(TitledBorder.LEADING); this.setBorder(title1); this.setLayout(gridbag); c.fill = GridBagConstraints.BOTH; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(2, 2, 2, 2); Utility.buildConstraints(c, 0, 0, 1, 1, 0, 0); label = new JLabel(LanguageBundle.getString("in_Prefs_outputSheetHTMLDefault")); gridbag.setConstraints(label, c); this.add(label); Utility.buildConstraints(c, 1, 0, 1, 1, 1, 0); outputSheetHTMLDefault = new JTextField( String.valueOf(SettingsHandler.getSelectedCharacterHTMLOutputSheet(null))); // sage_sam 9 April 2003 outputSheetHTMLDefault.addFocusListener(textFieldListener); gridbag.setConstraints(outputSheetHTMLDefault, c); this.add(outputSheetHTMLDefault); Utility.buildConstraints(c, 2, 0, 1, 1, 0, 0); outputSheetHTMLDefaultButton = createChooseButton(); gridbag.setConstraints(outputSheetHTMLDefaultButton, c); this.add(outputSheetHTMLDefaultButton); outputSheetHTMLDefaultButton.addActionListener(prefsButtonHandler); Utility.buildConstraints(c, 0, 1, 1, 1, 0, 0); label = new JLabel(LanguageBundle.getString("in_Prefs_outputSheetPDFDefault")); gridbag.setConstraints(label, c); this.add(label); Utility.buildConstraints(c, 1, 1, 1, 1, 1, 0); outputSheetPDFDefault = new JTextField( String.valueOf(SettingsHandler.getSelectedCharacterPDFOutputSheet(null))); // sage_sam 9 April 2003 outputSheetPDFDefault.addFocusListener(textFieldListener); gridbag.setConstraints(outputSheetPDFDefault, c); this.add(outputSheetPDFDefault); Utility.buildConstraints(c, 2, 1, 1, 1, 0, 0); outputSheetPDFDefaultButton = createChooseButton(); gridbag.setConstraints(outputSheetPDFDefaultButton, c); this.add(outputSheetPDFDefaultButton); outputSheetPDFDefaultButton.addActionListener(prefsButtonHandler); Utility.buildConstraints(c, 0, 2, 1, 1, 0, 0); label = new JLabel(IN_OUTPUT_SHEET_EQ_SET); gridbag.setConstraints(label, c); this.add(label); Utility.buildConstraints(c, 1, 2, 1, 1, 0, 0); outputSheetEqSet = new JTextField(String.valueOf(SettingsHandler.getSelectedEqSetTemplate())); // sage_sam 9 April 2003 outputSheetEqSet.addFocusListener(textFieldListener); gridbag.setConstraints(outputSheetEqSet, c); this.add(outputSheetEqSet); Utility.buildConstraints(c, 2, 2, 1, 1, 0, 0); outputSheetEqSetButton = createChooseButton(); gridbag.setConstraints(outputSheetEqSetButton, c); this.add(outputSheetEqSetButton); outputSheetEqSetButton.addActionListener(prefsButtonHandler); Utility.buildConstraints(c, 0, 3, 3, 1, 0, 0); saveOutputSheetWithPC.setText(IN_SAVE_OUTPUT_SHEET_WITH_PC); gridbag.setConstraints(saveOutputSheetWithPC, c); this.add(saveOutputSheetWithPC); Utility.buildConstraints(c, 0, 4, 1, 1, 0, 0); label = new JLabel(LanguageBundle.getString("in_Prefs_outputSpellSheetDefault")); gridbag.setConstraints(label, c); this.add(label); Utility.buildConstraints(c, 1, 4, 1, 1, 0, 0); outputSheetSpellsDefault = new JTextField(String.valueOf(SettingsHandler.getSelectedSpellSheet())); outputSheetSpellsDefault.addFocusListener(textFieldListener); gridbag.setConstraints(outputSheetSpellsDefault, c); this.add(outputSheetSpellsDefault); Utility.buildConstraints(c, 2, 4, 1, 1, 0, 0); outputSheetSpellsDefaultButton = createChooseButton(); gridbag.setConstraints(outputSheetSpellsDefaultButton, c); this.add(outputSheetSpellsDefaultButton); outputSheetSpellsDefaultButton.addActionListener(prefsButtonHandler); Utility.buildConstraints(c, 0, 5, 3, 1, 0, 0); printSpellsWithPC.setText(LanguageBundle.getString("in_Prefs_printSpellsWithPC")); gridbag.setConstraints(printSpellsWithPC, c); this.add(printSpellsWithPC); Utility.buildConstraints(c, 0, 6, 1, 1, 0, 0); label = new JLabel(IN_PAPER_TYPE); gridbag.setConstraints(label, c); this.add(label); Utility.buildConstraints(c, 1, 6, 2, 1, 0, 0); final int paperCount = Globals.getPaperCount(); paperNames = new String[paperCount]; for (int i = 0; i < paperCount; ++i) { paperNames[i] = Globals.getPaperInfo(i, PaperInfo.NAME); } paperType = new JComboBoxEx<>(paperNames); gridbag.setConstraints(paperType, c); this.add(paperType); Utility.buildConstraints(c, 0, 7, 3, 1, 0, 0); gridbag.setConstraints(removeTempFiles, c); this.add(removeTempFiles); Utility.buildConstraints(c, 0, 8, 3, 1, 0, 0); weaponProfPrintout = new JCheckBox(IN_WEAPON_PROF_PRINTOUT, SettingsHandler.getWeaponProfPrintout()); gridbag.setConstraints(weaponProfPrintout, c); this.add(weaponProfPrintout); Utility.buildConstraints(c, 0, 9, 1, 1, 0, 0); label = new JLabel(IN_POST_EXPORT_COMAND_STANDARD); gridbag.setConstraints(label, c); this.add(label); Utility.buildConstraints(c, 1, 9, 2, 1, 0, 0); postExportCommandStandard = new JTextField(String.valueOf(SettingsHandler.getPostExportCommandStandard())); gridbag.setConstraints(postExportCommandStandard, c); this.add(postExportCommandStandard); Utility.buildConstraints(c, 0, 10, 1, 1, 0, 0); label = new JLabel(IN_POST_EXPORT_COMMAND_PDF); gridbag.setConstraints(label, c); this.add(label); Utility.buildConstraints(c, 1, 10, 2, 1, 0, 0); postExportCommandPDF = new JTextField(String.valueOf(SettingsHandler.getPostExportCommandPDF())); gridbag.setConstraints(postExportCommandPDF, c); this.add(postExportCommandPDF); Utility.buildConstraints(c, 0, 11, 1, 1, 0, 0); label = new JLabel(IN_SKILL_FILTER); gridbag.setConstraints(label, c); this.add(label); Utility.buildConstraints(c, 1, 11, GridBagConstraints.REMAINDER, 1, 0, 0); skillFilter.setModel(new DefaultComboBoxModel<>(new SkillFilter[] { SkillFilter.Ranks, SkillFilter.NonDefault, SkillFilter.Usable, SkillFilter.All })); skillFilter.setSelectedItem(SkillFilter.getByValue(PCGenSettings.OPTIONS_CONTEXT .initInt(PCGenSettings.OPTION_SKILL_FILTER, SkillFilter.Usable.getValue()))); gridbag.setConstraints(skillFilter, c); this.add(skillFilter); Utility.buildConstraints(c, 0, 12, 1, 1, 0, 0); label = new JLabel(IN_INVALID_TO_HIT_TEXT); gridbag.setConstraints(label, c); this.add(label); Utility.buildConstraints(c, 1, 12, 2, 1, 0, 0); invalidToHitText = new JTextField(String.valueOf(SettingsHandler.getInvalidToHitText())); gridbag.setConstraints(invalidToHitText, c); this.add(invalidToHitText); Utility.buildConstraints(c, 0, 13, 1, 1, 0, 0); label = new JLabel(IN_INVALID_DMG_TEXT); gridbag.setConstraints(label, c); this.add(label); Utility.buildConstraints(c, 1, 13, GridBagConstraints.REMAINDER, 1, 0, 0); invalidDmgText = new JTextField(String.valueOf(SettingsHandler.getInvalidDmgText())); gridbag.setConstraints(invalidDmgText, c); this.add(invalidDmgText); Utility.buildConstraints(c, 0, 14, 3, 1, 0, 0); alwaysOverwrite = new JCheckBox(IN_ALWAYS_OVERWRITE, SettingsHandler.getAlwaysOverwrite()); gridbag.setConstraints(alwaysOverwrite, c); this.add(alwaysOverwrite); Utility.buildConstraints(c, 0, 15, 3, 1, 0, 0); showSingleBoxPerBundle = new JCheckBox(IN_SHOW_SINGLE_BOX_PER_BUNDLE, SettingsHandler.getShowSingleBoxPerBundle()); gridbag.setConstraints(showSingleBoxPerBundle, c); this.add(showSingleBoxPerBundle); Utility.buildConstraints(c, 0, 16, 1, 1, 0, 0); label = new JLabel(LanguageBundle.getString("in_Prefs_exportChoice")); // $NON-NSL-1$ gridbag.setConstraints(label, c); this.add(label); Utility.buildConstraints(c, 1, 16, GridBagConstraints.REMAINDER, 1, 0, 0); gridbag.setConstraints(exportChoice, c); this.add(exportChoice); Utility.buildConstraints(c, 0, 17, 3, 1, 0, 0); gridbag.setConstraints(generateTempFileWithPdf, c); this.add(generateTempFileWithPdf); Utility.buildConstraints(c, 0, 20, 3, 1, 1, 1); c.fill = GridBagConstraints.BOTH; label = new JLabel(" "); gridbag.setConstraints(label, c); this.add(label); }
From source file:mazewar.Mazewar.java
/** * The place where all the pieces are put together. *///w w w. ja v a 2s . c o m public Mazewar(String zkServer, int zkPort, int port, String name, String game, boolean robot) { super("ECE419 Mazewar"); consolePrintLn("ECE419 Mazewar started!"); /* Set up parent */ ZK_PARENT += game; // Throw up a dialog to get the GUIClient name. if (name != null) { clientId = name; } else { clientId = JOptionPane.showInputDialog("Enter your name"); } if ((clientId == null) || (clientId.length() == 0)) { Mazewar.quit(); } /* Connect to ZooKeeper and get sequencer details */ List<ClientNode> nodeList = null; try { zkWatcher = new ZkWatcher(); zkConnected = new CountDownLatch(1); zooKeeper = new ZooKeeper(zkServer + ":" + zkPort, ZK_TIMEOUT, new Watcher() { @Override public void process(WatchedEvent event) { /* Release Lock if ZooKeeper is connected */ if (event.getState() == SyncConnected) { zkConnected.countDown(); } else { System.err.println("Could not connect to ZooKeeper!"); System.exit(0); } } }); zkConnected.await(); /* Successfully connected, now create our node on ZooKeeper */ zooKeeper.create(Joiner.on('/').join(ZK_PARENT, clientId), Joiner.on(':').join(InetAddress.getLocalHost().getHostAddress(), port).getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL_SEQUENTIAL); /* Get Seed from Parent */ mazeSeed = Long.parseLong(new String(zooKeeper.getData(ZK_PARENT, false, null))); /* Initialize Sequence Number */ sequenceNumber = new AtomicInteger(zooKeeper.exists(ZK_PARENT, false).getVersion()); /* Get list of nodes */ nodeList = ClientNode.sortList(zooKeeper.getChildren(ZK_PARENT, false)); } catch (Exception e) { e.printStackTrace(); System.exit(1); } // Create the maze maze = new MazeImpl(new Point(mazeWidth, mazeHeight), mazeSeed); assert (maze != null); // Have the ScoreTableModel listen to the maze to find // out how to adjust scores. ScoreTableModel scoreModel = new ScoreTableModel(); assert (scoreModel != null); maze.addMazeListener(scoreModel); /* Initialize packet queue */ packetQueue = new ArrayBlockingQueue<MazePacket>(QUEUE_SIZE); sequencedQueue = new PriorityBlockingQueue<MazePacket>(QUEUE_SIZE, new Comparator<MazePacket>() { @Override public int compare(MazePacket o1, MazePacket o2) { return o1.sequenceNumber.compareTo(o2.sequenceNumber); } }); /* Inject Event Bus into Client */ Client.setEventBus(eventBus); /* Initialize ZMQ Context */ context = ZMQ.context(2); /* Set up publisher */ publisher = context.socket(ZMQ.PUB); publisher.bind("tcp://*:" + port); System.out.println("ZeroMQ Publisher Bound On: " + port); try { Thread.sleep(100); } catch (Exception e) { e.printStackTrace(); } /* Set up subscriber */ subscriber = context.socket(ZMQ.SUB); subscriber.subscribe(ArrayUtils.EMPTY_BYTE_ARRAY); clients = new ConcurrentHashMap<String, Client>(); try { for (ClientNode client : nodeList) { if (client.getName().equals(clientId)) { clientPath = ZK_PARENT + "/" + client.getPath(); guiClient = robot ? new RobotClient(clientId) : new GUIClient(clientId); clients.put(clientId, guiClient); maze.addClient(guiClient); eventBus.register(guiClient); subscriber.connect("tcp://" + new String(zooKeeper.getData(clientPath, false, null))); } else { addRemoteClient(client); } } } catch (Exception e) { e.printStackTrace(); } checkNotNull(guiClient, "Should have received our clientId in CLIENTS list!"); // Create the GUIClient and connect it to the KeyListener queue this.addKeyListener(guiClient); this.isRobot = robot; // Use braces to force constructors not to be called at the beginning of the // constructor. /*{ maze.addClient(new RobotClient("Norby")); maze.addClient(new RobotClient("Robbie")); maze.addClient(new RobotClient("Clango")); maze.addClient(new RobotClient("Marvin")); }*/ // Create the panel that will display the maze. overheadPanel = new OverheadMazePanel(maze, guiClient); assert (overheadPanel != null); maze.addMazeListener(overheadPanel); // Don't allow editing the console from the GUI console.setEditable(false); console.setFocusable(false); console.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder())); // Allow the console to scroll by putting it in a scrollpane JScrollPane consoleScrollPane = new JScrollPane(console); assert (consoleScrollPane != null); consoleScrollPane .setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Console")); // Create the score table scoreTable = new JTable(scoreModel); assert (scoreTable != null); scoreTable.setFocusable(false); scoreTable.setRowSelectionAllowed(false); // Allow the score table to scroll too. JScrollPane scoreScrollPane = new JScrollPane(scoreTable); assert (scoreScrollPane != null); scoreScrollPane.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Scores")); // Create the layout manager GridBagLayout layout = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); getContentPane().setLayout(layout); // Define the constraints on the components. c.fill = GridBagConstraints.BOTH; c.weightx = 1.0; c.weighty = 3.0; c.gridwidth = GridBagConstraints.REMAINDER; layout.setConstraints(overheadPanel, c); c.gridwidth = GridBagConstraints.RELATIVE; c.weightx = 2.0; c.weighty = 1.0; layout.setConstraints(consoleScrollPane, c); c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 1.0; layout.setConstraints(scoreScrollPane, c); // Add the components getContentPane().add(overheadPanel); getContentPane().add(consoleScrollPane); getContentPane().add(scoreScrollPane); // Pack everything neatly. pack(); // Let the magic begin. setVisible(true); overheadPanel.repaint(); this.requestFocusInWindow(); }
From source file:com.ciphertool.zodiacengine.gui.view.SwingUserInterface.java
public void init() { this.addWindowListener(getWindowClosingListener()); this.setTitle(windowTitle); this.setSize(windowWidth, windowHeight); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(DISPOSE_ON_CLOSE); JPanel containerPanel = new JPanel(); getContentPane().add(containerPanel); /*/*from w w w . j ava2s . co m*/ * Use a BorderLayout for the main container so we can use the SOUTH * panel as a status bar and use the NORTH panel as a menu bar, etc. */ containerPanel.setLayout(new BorderLayout()); JPanel bottomPanel = new JPanel(); containerPanel.add(bottomPanel, BorderLayout.SOUTH); bottomPanel.setLayout(new BorderLayout()); JPanel buttonPanel = new JPanel(); bottomPanel.add(buttonPanel, BorderLayout.CENTER); GridLayout gridLayout = new GridLayout(1, 2, 5, 5); buttonPanel.setLayout(gridLayout); buttonPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); startButton = new JButton(startButtonText); startButton.addActionListener(getStartButtonActionListener(false)); buttonPanel.add(startButton); debugButton = new JButton(debugButtonText); debugButton.addActionListener(getStartButtonActionListener(true)); buttonPanel.add(debugButton); continueButton = new JButton(continueButtonText); continueButton.addActionListener(getContinueButtonActionListener()); buttonPanel.add(continueButton); continueButton.setEnabled(false); stopButton = new JButton(stopButtonText); stopButton.addActionListener(getStopButtonActionListener()); buttonPanel.add(stopButton); stopButton.setEnabled(false); JPanel statusPanel = new JPanel(); bottomPanel.add(statusPanel, BorderLayout.SOUTH); statusLabel = new JLabel(statusNotRunning); statusPanel.add(statusLabel); /* * Next make a grid bag for the thirteen input elements with labels on * the left and spinners on the right. */ JPanel mainPanel = new JPanel(); GridBagLayout gridBagLayout = new GridBagLayout(); GridBagConstraints constraints = new GridBagConstraints(); constraints.fill = GridBagConstraints.BOTH; constraints.insets = new Insets(5, 5, 5, 5); constraints.anchor = GridBagConstraints.WEST; mainPanel.setLayout(gridBagLayout); mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); containerPanel.add(mainPanel, BorderLayout.CENTER); List<Cipher> ciphers = cipherDao.findAll(); cipherMap = new HashMap<String, Cipher>(); cipherComboBox = new JComboBox<String>(); String cipherName; for (Cipher cipher : ciphers) { cipherName = cipher.getName(); cipherMap.put(cipherName, cipher); cipherComboBox.addItem(cipherName); if (cipher.getName().equals(defaultCipher)) { cipherComboBox.setSelectedItem(cipherName); } } JLabel cipherNameLabel = new JLabel(cipherNameText); cipherComboBox.addActionListener(getCipherComboBoxActionListener()); constraints.weightx = LAYOUT_LABEL_WEIGHT; constraints.gridwidth = GridBagConstraints.RELATIVE; gridBagLayout.setConstraints(cipherNameLabel, constraints); mainPanel.add(cipherNameLabel); constraints.weightx = LAYOUT_INPUT_WEIGHT; constraints.gridwidth = GridBagConstraints.REMAINDER; gridBagLayout.setConstraints(cipherComboBox, constraints); mainPanel.add(cipherComboBox); appendGenerationsSpinner(gridBagLayout, constraints, mainPanel); appendRunContinuouslyCheckBox(gridBagLayout, constraints, mainPanel); appendPopulationSpinner(gridBagLayout, constraints, mainPanel); appendLifespanSpinner(gridBagLayout, constraints, mainPanel); appendSurvivalRateSpinner(gridBagLayout, constraints, mainPanel); appendMutationRateSpinner(gridBagLayout, constraints, mainPanel); appendMaxMutationsPerIndividualSpinner(gridBagLayout, constraints, mainPanel); appendCrossoverRateSpinner(gridBagLayout, constraints, mainPanel); appendMutateDuringCrossoverCheckBox(gridBagLayout, constraints, mainPanel); appendFitnessEvaluatorComboBox(gridBagLayout, constraints, mainPanel); appendCrossoverAlgorithmComboBox(gridBagLayout, constraints, mainPanel); appendMutationAlgorithmComboBox(gridBagLayout, constraints, mainPanel); appendSelectionAlgorithmComboBox(gridBagLayout, constraints, mainPanel); appendSelectorComboBox(gridBagLayout, constraints, mainPanel); appendCompareToKnownSolutionCheckBox(gridBagLayout, constraints, mainPanel); SwingUtilities.invokeLater(new Runnable() { public void run() { setVisible(true); toFront(); } }); }
From source file:net.sf.jabref.gui.plaintextimport.TextInputDialog.java
private JPanel setUpFieldListPanel() { JPanel inputPanel = new JPanel(); // Panel Layout GridBagLayout gbl = new GridBagLayout(); GridBagConstraints con = new GridBagConstraints(); con.weightx = 0;//from w w w. ja va2 s.c o m con.insets = new Insets(5, 5, 0, 5); con.fill = GridBagConstraints.HORIZONTAL; inputPanel.setLayout(gbl); // Border TitledBorder titledBorder1 = new TitledBorder(BorderFactory.createLineBorder(new Color(153, 153, 153), 2), Localization.lang("Work options")); inputPanel.setBorder(titledBorder1); inputPanel.setMinimumSize(new Dimension(10, 10)); JScrollPane fieldScroller = new JScrollPane(fieldList); fieldScroller.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); // insert buttons insertButton.addActionListener(event -> insertTextForTag(override.isSelected())); // Radio buttons append.setToolTipText(Localization.lang("Append the selected text to BibTeX field")); append.setMnemonic(KeyEvent.VK_A); append.setSelected(true); override.setToolTipText(Localization.lang("Override the BibTeX field by the selected text")); override.setMnemonic(KeyEvent.VK_O); override.setSelected(false); //Group the radio buttons. ButtonGroup group = new ButtonGroup(); group.add(append); group.add(override); JPanel radioPanel = new JPanel(new GridLayout(0, 1)); radioPanel.add(append); radioPanel.add(override); // insert sub components JLabel label1 = new JLabel(Localization.lang("Available BibTeX fields")); con.gridwidth = GridBagConstraints.REMAINDER; gbl.setConstraints(label1, con); inputPanel.add(label1); con.gridwidth = GridBagConstraints.REMAINDER; con.gridheight = 8; con.weighty = 1; con.fill = GridBagConstraints.BOTH; gbl.setConstraints(fieldScroller, con); inputPanel.add(fieldScroller); con.fill = GridBagConstraints.HORIZONTAL; con.weighty = 0; con.gridwidth = 2; gbl.setConstraints(radioPanel, con); inputPanel.add(radioPanel); con.gridwidth = GridBagConstraints.REMAINDER; gbl.setConstraints(insertButton, con); inputPanel.add(insertButton); return inputPanel; }
From source file:TextureByReference.java
public JPanel buildGui() { flipB = new JCheckBox("flip image", true); flipB.addItemListener(this); javax.swing.Box flipBox = new javax.swing.Box(BoxLayout.Y_AXIS); flipBox.add(flipB);/*from ww w . ja v a 2 s. c om*/ Component strut1 = flipBox.createVerticalStrut(flipB.getPreferredSize().height); Component strut2 = flipBox.createVerticalStrut(flipB.getPreferredSize().height); Component strut3 = flipBox.createVerticalStrut(flipB.getPreferredSize().height); Component strut4 = flipBox.createVerticalStrut(flipB.getPreferredSize().height); Component strut5 = flipBox.createVerticalStrut(flipB.getPreferredSize().height); flipBox.add(strut1); flipBox.add(strut2); flipBox.add(strut3); flipBox.add(strut4); flipBox.add(strut5); yUp = new JRadioButton("y up"); yUp.addActionListener(this); yUp.setSelected(true); yDown = new JRadioButton("y down"); yDown.addActionListener(this); ButtonGroup yGroup = new ButtonGroup(); yGroup.add(yUp); yGroup.add(yDown); JLabel yLabel = new JLabel("Image Orientation:"); javax.swing.Box yBox = new javax.swing.Box(BoxLayout.Y_AXIS); yBox.add(yLabel); yBox.add(yUp); yBox.add(yDown); strut1 = yBox.createVerticalStrut(yUp.getPreferredSize().height); strut2 = yBox.createVerticalStrut(yUp.getPreferredSize().height); strut3 = yBox.createVerticalStrut(yUp.getPreferredSize().height); yBox.add(strut1); yBox.add(strut2); yBox.add(strut3); texByRef = new JRadioButton("by reference"); texByRef.addActionListener(this); texByRef.setSelected(true); texByCopy = new JRadioButton("by copy"); texByCopy.addActionListener(this); ButtonGroup texGroup = new ButtonGroup(); texGroup.add(texByRef); texGroup.add(texByCopy); JLabel texLabel = new JLabel("Texture:*"); javax.swing.Box texBox = new javax.swing.Box(BoxLayout.Y_AXIS); texBox.add(texLabel); texBox.add(texByRef); texBox.add(texByCopy); strut1 = texBox.createVerticalStrut(texByRef.getPreferredSize().height); strut2 = texBox.createVerticalStrut(texByRef.getPreferredSize().height); strut3 = texBox.createVerticalStrut(texByRef.getPreferredSize().height); texBox.add(strut1); texBox.add(strut2); texBox.add(strut3); geomByRef = new JRadioButton("by reference"); geomByRef.addActionListener(this); geomByRef.setSelected(true); geomByCopy = new JRadioButton("by copy"); geomByCopy.addActionListener(this); ButtonGroup geomGroup = new ButtonGroup(); geomGroup.add(geomByRef); geomGroup.add(geomByCopy); JLabel geomLabel = new JLabel("Geometry:"); javax.swing.Box geomBox = new javax.swing.Box(BoxLayout.Y_AXIS); geomBox.add(geomLabel); geomBox.add(geomByRef); geomBox.add(geomByCopy); strut1 = geomBox.createVerticalStrut(geomByRef.getPreferredSize().height); strut2 = geomBox.createVerticalStrut(geomByRef.getPreferredSize().height); strut3 = geomBox.createVerticalStrut(geomByRef.getPreferredSize().height); geomBox.add(strut1); geomBox.add(strut2); geomBox.add(strut3); img4ByteABGR = new JRadioButton("TYPE_4BYTE_ABGR"); img4ByteABGR.addActionListener(this); img4ByteABGR.setSelected(true); img3ByteBGR = new JRadioButton("TYPE_3BYTE_BGR"); img3ByteBGR.addActionListener(this); imgIntARGB = new JRadioButton("TYPE_INT_ARGB"); imgIntARGB.addActionListener(this); imgCustomRGBA = new JRadioButton("TYPE_CUSTOM RGBA"); imgCustomRGBA.addActionListener(this); imgCustomRGB = new JRadioButton("TYPE_CUSTOM RGB"); imgCustomRGB.addActionListener(this); ButtonGroup imgGroup = new ButtonGroup(); imgGroup.add(img4ByteABGR); imgGroup.add(img3ByteBGR); imgGroup.add(imgIntARGB); imgGroup.add(imgCustomRGBA); imgGroup.add(imgCustomRGB); JLabel imgLabel = new JLabel("Image Type:*"); javax.swing.Box imgBox = new javax.swing.Box(BoxLayout.Y_AXIS); imgBox.add(imgLabel); imgBox.add(img4ByteABGR); imgBox.add(img3ByteBGR); imgBox.add(imgIntARGB); imgBox.add(imgCustomRGBA); imgBox.add(imgCustomRGB); javax.swing.Box topBox = new javax.swing.Box(BoxLayout.X_AXIS); topBox.add(flipBox); topBox.add(texBox); topBox.add(geomBox); topBox.add(yBox); Component strut = topBox.createRigidArea(new Dimension(10, 10)); topBox.add(strut); topBox.add(imgBox); frameDelay = new JSlider(0, 50, 0); frameDelay.addChangeListener(this); frameDelay.setSnapToTicks(true); frameDelay.setPaintTicks(true); frameDelay.setPaintLabels(true); frameDelay.setMajorTickSpacing(10); frameDelay.setMinorTickSpacing(1); frameDelay.setValue(20); JLabel delayL = new JLabel("frame delay"); javax.swing.Box delayBox = new javax.swing.Box(BoxLayout.X_AXIS); delayBox.add(delayL); delayBox.add(frameDelay); animationB = new JButton(" stop animation "); animationB.addActionListener(this); JLabel texInfo1 = new JLabel("*To use ImageComponent by reference feature, use TYPE_4BYTE_ABGR on Solaris"); JLabel texInfo2 = new JLabel("and TYPE_3BYTE_BGR on Windows"); JPanel buttonP = new JPanel(); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); buttonP.setLayout(gridbag); c.anchor = GridBagConstraints.CENTER; c.gridwidth = GridBagConstraints.REMAINDER; gridbag.setConstraints(topBox, c); buttonP.add(topBox); gridbag.setConstraints(delayBox, c); buttonP.add(delayBox); gridbag.setConstraints(animationB, c); buttonP.add(animationB); gridbag.setConstraints(texInfo1, c); buttonP.add(texInfo1); gridbag.setConstraints(texInfo2, c); buttonP.add(texInfo2); return buttonP; }
From source file:com.rapidminer.gui.new_plotter.gui.ColorSchemeDialog.java
/** * *///from w w w . j av a2 s . c om private void createComponents() { // creat popup menus { popupMenu = new JPopupMenu(); removeMenuItem = new JMenuItem(I18N .getGUILabel("plotter.configuration_dialog.color_scheme_dialog.remove_color_menu_item.label")); removeMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { removeSelectedColorAction(); } }); popupMenu.add(removeMenuItem); changeColorMenuItem = new JMenuItem(I18N .getGUILabel("plotter.configuration_dialog.color_scheme_dialog.change_color_menu_item.label")); changeColorMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { replaceSelectedColorAction(); } }); popupMenu.add(changeColorMenuItem); popupMenu.addSeparator(); moveUpColorMenuItem = new JMenuItem( I18N.getGUILabel("plotter.configuration_dialog.color_scheme_dialog.move_up_menu_item.label")); moveUpColorMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { moveSelectedColorUpAction(); } }); popupMenu.add(moveUpColorMenuItem); moveDownColorMenuItem = new JMenuItem( I18N.getGUILabel("plotter.configuration_dialog.color_scheme_dialog.move_down_menu_item.label")); moveDownColorMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { moveSelectedColorDownAction(); } }); popupMenu.add(moveDownColorMenuItem); } JPanel containerPanel = new JPanel(new GridBagLayout()); containerPanel.setPreferredSize(new Dimension(520, 450)); // create containing panel { { JPanel configurePanel = new JPanel(new GridBagLayout()); configurePanel.setPreferredSize(new Dimension(220, 400)); configurePanel.setBorder(BorderFactory.createTitledBorder(I18N.getGUILabel( "plotter.configuration_dialog.color_scheme_dialog.scheme_configuration_border.label"))); // add scheme list panel { JPanel schemeComboBoxPanel = createSchemeComboBoxPanel(); // add category choosing panel GridBagConstraints itemConstraint = new GridBagConstraints(); itemConstraint.fill = GridBagConstraints.BOTH; itemConstraint.weightx = 1; itemConstraint.weighty = 1; itemConstraint.gridwidth = GridBagConstraints.REMAINDER; itemConstraint.insets = new Insets(2, 2, 2, 5); configurePanel.add(schemeComboBoxPanel, itemConstraint); } { categoryAndGradientConfigPanel = new JPanel(new GridBagLayout()); // add categories panel { JPanel categoryConfigurationPanel = createColorCategoriesPanel(); // add category choosing panel GridBagConstraints itemConstraint = new GridBagConstraints(); itemConstraint.fill = GridBagConstraints.BOTH; itemConstraint.weightx = 1; itemConstraint.weighty = 1; itemConstraint.insets = new Insets(2, 2, 2, 5); itemConstraint.gridwidth = GridBagConstraints.REMAINDER; categoryAndGradientConfigPanel.add(categoryConfigurationPanel, itemConstraint); } // add gradient chooser panel { JPanel gradientConfigPanel = createGradientConfigurationPanel(); GridBagConstraints itemConstraint = new GridBagConstraints(); itemConstraint.fill = GridBagConstraints.BOTH; itemConstraint.weightx = 1; itemConstraint.weighty = 1; itemConstraint.insets = new Insets(2, 2, 2, 5); itemConstraint.gridwidth = GridBagConstraints.REMAINDER; categoryAndGradientConfigPanel.add(gradientConfigPanel, itemConstraint); } GridBagConstraints itemConstraint = new GridBagConstraints(); itemConstraint.fill = GridBagConstraints.BOTH; itemConstraint.weightx = 1; itemConstraint.weighty = 1; itemConstraint.gridwidth = GridBagConstraints.REMAINDER; itemConstraint.insets = new Insets(2, 2, 2, 5); configurePanel.add(categoryAndGradientConfigPanel, itemConstraint); } GridBagConstraints itemConstraint = new GridBagConstraints(); itemConstraint.fill = GridBagConstraints.BOTH; itemConstraint.weightx = 1; itemConstraint.weighty = 1; itemConstraint.gridwidth = GridBagConstraints.RELATIVE; containerPanel.add(configurePanel, itemConstraint); } createPlotPreviewPanel(containerPanel); } // create buttons Collection<AbstractButton> buttons = new LinkedList<AbstractButton>(); buttons.add(makeOkButton()); Action saveAction = new ResourceAction("plotter.configuration_dialog.color_scheme_dialog.save_button") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { save(currentColorSchemes, currentActiveColorSchemeName); // set new scheme plotConfig.setColorSchemes(currentColorSchemes, currentActiveColorSchemeName); } }; saveButton = new JButton(saveAction); buttons.add(saveButton); saveButton.setEnabled(false); Action revertAction = new ResourceAction("plotter.configuration_dialog.color_scheme_dialog.revert_button") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { revert(); } }; revertButton = new JButton(revertAction); revertButton.setEnabled(false); buttons.add(revertButton); buttons.add(makeCancelButton("plotter.configuration_dialog.color_scheme_dialog.cancel_button")); layoutDefault(containerPanel, buttons); }
From source file:de.codesourcery.jasm16.ide.ui.utils.UIUtils.java
protected static final GridBagConstraints constraints(int x, int y, boolean remainderHoriz, boolean remainderVert, int fill) { final GridBagConstraints cnstrs = new GridBagConstraints(); cnstrs.anchor = GridBagConstraints.NORTHWEST; cnstrs.weightx = 1.0d;//from w w w.j av a 2 s .co m cnstrs.weighty = 1.0d; cnstrs.fill = fill; cnstrs.gridheight = remainderVert ? GridBagConstraints.REMAINDER : 1; cnstrs.gridwidth = remainderHoriz ? GridBagConstraints.REMAINDER : 1; cnstrs.gridx = x; cnstrs.gridy = y; cnstrs.insets = new Insets(10, 2, 10, 2); // top,left,bottom,right return cnstrs; }
From source file:com.rapidminer.gui.new_plotter.gui.GlobalConfigurationPanel.java
private void createComponents() { // create panel for global configuration {//from w w w . j a v a 2 s .c o m // add title label JLabel titleLabel = new ResourceLabel("plotter.configuration_dialog.chart_title"); String title = getPlotConfiguration().getTitleText(); if (title == null) { title = ""; } titleTextField = new JTextField(title); titleLabel.setLabelFor(titleTextField); titleTextField.addKeyListener(new KeyListener() { @Override public void keyTyped(KeyEvent e) { return; } @Override public void keyReleased(KeyEvent e) { String newTitle = titleTextField.getText(); String titleText = getCurrentPlotInstance().getMasterPlotConfiguration().getTitleText(); if (titleText != null) { if (!titleText.equals(newTitle) || titleText == null && newTitle.length() > 0) { if (newTitle.length() > 0) { getPlotConfiguration().setTitleText(newTitle); } else { getPlotConfiguration().setTitleText(null); } } } else { if (newTitle.length() > 0) { getPlotConfiguration().setTitleText(newTitle); } else { getPlotConfiguration().setTitleText(null); } } if (newTitle.equals("Iris") && SwingTools.isControlOrMetaDown(e) && e.getKeyCode() == KeyEvent.VK_D) { startAnimation(); } } @Override public void keyPressed(KeyEvent e) { return; } }); titleTextField.setPreferredSize(new Dimension(115, 23)); titleConfigButton = new JToggleButton(new PopupAction(true, "plotter.configuration_dialog.open_popup", chartTitleConfigurationContainer, PopupPosition.HORIZONTAL)); addThreeComponentRow(this, titleLabel, titleTextField, titleConfigButton); } // add orientation check box { JLabel plotOrientationLabel = new ResourceLabel( "plotter.configuration_dialog.global_config_panel.plot_orientation"); PlotOrientation[] orientations = { PlotOrientation.HORIZONTAL, PlotOrientation.VERTICAL }; plotOrientationComboBox = new JComboBox(orientations); plotOrientationLabel.setLabelFor(plotOrientationComboBox); plotOrientationComboBox.setRenderer(new EnumComboBoxCellRenderer("plotter")); plotOrientationComboBox.setSelectedIndex(0); plotOrientationComboBox.addPopupMenuListener(new PopupMenuListener() { @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { return; } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { getPlotConfiguration() .setOrientation((PlotOrientation) plotOrientationComboBox.getSelectedItem()); } @Override public void popupMenuCanceled(PopupMenuEvent e) { return; } }); addTwoComponentRow(this, plotOrientationLabel, plotOrientationComboBox); } // add legend popup button { JLabel legendStyleConfigureLabel = new ResourceLabel( "plotter.configuration_dialog.global_config_panel.legend_style"); JToggleButton legendStyleConfigButton = new JToggleButton( new PopupAction(true, "plotter.configuration_dialog.open_popup", legendConfigContainer, PopupAction.PopupPosition.HORIZONTAL)); legendStyleConfigureLabel.setLabelFor(legendStyleConfigButton); addTwoComponentRow(this, legendStyleConfigureLabel, legendStyleConfigButton); } // add legend popup button { JLabel axisStyleConfigureLabel = new ResourceLabel( "plotter.configuration_dialog.global_config_panel.axis_style"); JToggleButton axisStyleConfigureButton = new JToggleButton( new PopupAction(true, "plotter.configuration_dialog.open_popup", axisConfigurationContainer, PopupAction.PopupPosition.HORIZONTAL)); axisStyleConfigureLabel.setLabelFor(axisStyleConfigureButton); addTwoComponentRow(this, axisStyleConfigureLabel, axisStyleConfigureButton); } // add color scheme dialog button { JLabel colorConfigureLabel = new ResourceLabel( "plotter.configuration_dialog.global_config_panel.color_scheme"); colorsSchemesComboBoxModel = new DefaultComboBoxModel(); colorSchemesComboBox = new JComboBox(colorsSchemesComboBoxModel); colorConfigureLabel.setLabelFor(colorSchemesComboBox); colorSchemesComboBox.setRenderer(new ColorSchemeComboBoxRenderer()); colorSchemesComboBox.addPopupMenuListener(new PopupMenuListener() { @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { return; } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { ColorScheme colorScheme = (ColorScheme) colorSchemesComboBox.getSelectedItem(); if (colorScheme != null) { getPlotConfiguration().setActiveColorScheme(colorScheme.getName()); } } @Override public void popupMenuCanceled(PopupMenuEvent e) { return; } }); JButton colorConfigButton = new JButton( new ResourceAction(true, "plotter.configuration_dialog.open_color_scheme_dialog") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { createColorSchemeDialog(); } }); addThreeComponentRow(this, colorConfigureLabel, colorSchemesComboBox, colorConfigButton); } // add plot background color { plotBackGroundColorLabel = new ResourceLabel( "plotter.configuration_dialog.global_config_panel.select_plot_background_color"); plotBackgroundColorChooserButton = new JButton( new ResourceAction(true, "plotter.configuration_dialog.select_plot_color") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { createPlotBackgroundColorDialog(); } }); plotBackGroundColorLabel.setLabelFor(plotBackgroundColorChooserButton); addTwoComponentRow(this, plotBackGroundColorLabel, plotBackgroundColorChooserButton); } // add chart background color { frameBackGroundColorLabel = new ResourceLabel( "plotter.configuration_dialog.global_config_panel.select_frame_background_color"); frameBackgroundColorChooserButton = new JButton( new ResourceAction(true, "plotter.configuration_dialog.select_frame_color") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { createFrameBackgroundColorDialog(); } }); frameBackGroundColorLabel.setLabelFor(frameBackgroundColorChooserButton); addTwoComponentRow(this, frameBackGroundColorLabel, frameBackgroundColorChooserButton); // GridBagConstraints itemConstraint = new GridBagConstraints(); // itemConstraint.gridwidth = GridBagConstraints.REMAINDER; // itemConstraint.weightx = 1.0; // this.add(frameBackgroundColorChooserButton, itemConstraint); } // add spacer panel { JPanel spacerPanel = new JPanel(); GridBagConstraints itemConstraint = new GridBagConstraints(); itemConstraint.fill = GridBagConstraints.BOTH; itemConstraint.weightx = 1; itemConstraint.weighty = 1; itemConstraint.gridwidth = GridBagConstraints.REMAINDER; this.add(spacerPanel, itemConstraint); } }
From source file:org.photovault.swingui.PhotoInfoEditor.java
protected void createTechDataUI() { JPanel pane = new JPanel(); tabPane.addTab("Tech data", pane); JLabel cameraMakerLabel = new JLabel("Camera make"); JTextField cameraMakerField = createMvTextField("cameraMaker", 20); // cameraDoc = cameraField.getDocument(); JLabel cameraLabel = new JLabel("Camera model"); cameraField = createMvTextField("camera", 20); cameraDoc = cameraField.getDocument(); JLabel lensLabel = new JLabel("Lens"); lensField = createMvTextField("lens", 20); lensDoc = lensField.getDocument();// ww w . j a v a 2s. c o m JLabel filmLabel = new JLabel("Film"); filmField = createMvTextField("film", 20); filmDoc = filmField.getDocument(); JLabel filmSpeedLabel = new JLabel("Film speed"); NumberFormatter filmSpeedFormatter = new NumberFormatter(new DecimalFormat("#########0")); filmSpeedFormatter.setValueClass(PhotoInfoFields.FILM_SPEED.getType()); filmSpeedField = new JFormattedTextField(filmSpeedFormatter); filmSpeedField.setColumns(5); filmSpeedField.addPropertyChangeListener(this); filmSpeedField.putClientProperty(FIELD, PhotoInfoFields.FILM_SPEED); JLabel shutterSpeedLabel = new JLabel("Shutter speed"); DecimalFormat shutterSpeedFormat = new DecimalFormat("###0.####"); NumberFormatter shutterSpeedFormatter = new NumberFormatter(shutterSpeedFormat); shutterSpeedFormatter.setValueClass(PhotoInfoFields.SHUTTER_SPEED.getType()); shutterSpeedField = new JFormattedTextField(shutterSpeedFormatter); shutterSpeedField.setColumns(5); shutterSpeedField.addPropertyChangeListener(this); shutterSpeedField.putClientProperty(FIELD, PhotoInfoFields.SHUTTER_SPEED); JLabel fStopLabel = new JLabel("F-stop"); DecimalFormat fStopFormat = new DecimalFormat("#0.#"); NumberFormatter fStopFormatter = new NumberFormatter(fStopFormat); fStopFormatter.setValueClass(PhotoInfoFields.FSTOP.getType()); fStopField = new JFormattedTextField(fStopFormatter); fStopField.setColumns(5); fStopField.addPropertyChangeListener(this); fStopField.putClientProperty(FIELD, PhotoInfoFields.FSTOP); JLabel focalLengthLabel = new JLabel("Focal length"); NumberFormatter focalLengthFormatter = new NumberFormatter(new DecimalFormat("#######0.#")); focalLengthFormatter.setValueClass(PhotoInfoFields.FSTOP.getType()); focalLengthField = new JFormattedTextField(focalLengthFormatter); focalLengthField.setColumns(5); focalLengthField.addPropertyChangeListener(this); focalLengthField.putClientProperty(FIELD, PhotoInfoFields.FOCAL_LENGTH); // Tech note text JLabel notesLabel = new JLabel("Tech. notes"); technoteTextArea = new JTextArea(5, 40); technoteTextArea.setLineWrap(true); technoteTextArea.setWrapStyleWord(true); JScrollPane technoteScrollPane = new JScrollPane(technoteTextArea); technoteScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); Border technoteBorder = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED); technoteBorder = BorderFactory.createTitledBorder(technoteBorder, "Description"); technoteScrollPane.setBorder(technoteBorder); technoteDoc = technoteTextArea.getDocument(); technoteDoc.putProperty(FIELD, PhotoInfoFields.TECH_NOTES); technoteDoc.addDocumentListener(this); // Lay out the created controls GridBagLayout layout = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); pane.setLayout(layout); JLabel[] labels = { cameraMakerLabel, cameraLabel, lensLabel, focalLengthLabel, filmLabel, filmSpeedLabel, shutterSpeedLabel, fStopLabel }; JTextField[] fields = { cameraMakerField, cameraField, lensField, focalLengthField, filmField, filmSpeedField, shutterSpeedField, fStopField }; addLabelTextRows(labels, fields, layout, pane); pane.add(technoteScrollPane); c.gridwidth = GridBagConstraints.REMAINDER; c.weighty = 0.5; c.fill = GridBagConstraints.BOTH; layout.setConstraints(technoteScrollPane, c); }