Java Code Examples for javax.swing.JButton#setHorizontalAlignment()

The following examples show how to use javax.swing.JButton#setHorizontalAlignment() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MenuItemDefinition.java    From nordpos with GNU General Public License v3.0 6 votes vote down vote up
public void addComponent(JPanelMenu menu) {
        
        JButton btn = new JButton(act); 
        
        btn.setFocusPainted(false);
        btn.setFocusable(false);
        btn.setRequestFocusEnabled(false);
        btn.setHorizontalAlignment(SwingConstants.LEADING);
        btn.setPreferredSize(new Dimension(220, 50));
        
//        btn.setSize(220, 50);
//        btn.setLocation(p);
//        if (p.x >= 470) {
//            p.x = 20;
//            p.y += 55;
//        } else {
//            p.x += 225;
//        }
//        comp.add(btn);        
        
        menu.addEntry(btn);
    }
 
Example 2
Source File: StartScreen.java    From WorldGrower with GNU General Public License v3.0 6 votes vote down vote up
private void addCreditsButton() {
	JButton btnCredits = JButtonFactory.createButton("Credits", IconUtils.getCreditsIcon(), imageInfoReader, soundIdReader);
	btnCredits.setHorizontalAlignment(SwingConstants.LEFT);
	btnCredits.setHorizontalTextPosition(SwingConstants.RIGHT);
	btnCredits.setToolTipText("Credits");
	btnCredits.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) {
			try {
				CreditsDialog creditsDialog = new CreditsDialog(imageInfoReader, soundIdReader);
				creditsDialog.showMe();
			} catch (Exception e1) {
				ExceptionHandler.handle(e1);
			}
		}
	});
	frame.addComponent(btnCredits);
	SwingUtils.setBoundsAndCenterHorizontally(btnCredits, BUTTON_LEFT, 360, BUTTON_WIDTH, BUTTON_HEIGHT);
}
 
Example 3
Source File: StartScreen.java    From WorldGrower with GNU General Public License v3.0 6 votes vote down vote up
private void addControlsButton(Preferences preferences) {
	JButton btnControlsGame = JButtonFactory.createButton("Controls", IconUtils.getControlsIcon(), imageInfoReader, soundIdReader);
	btnControlsGame.setHorizontalAlignment(SwingConstants.LEFT);
	btnControlsGame.setHorizontalTextPosition(SwingConstants.RIGHT);
	btnControlsGame.setToolTipText("View and change game controls");
	btnControlsGame.setEnabled(true);
	btnControlsGame.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) {
			ControlsDialog controlsDialog = new ControlsDialog(keyBindings, imageInfoReader, soundIdReader, musicPlayer);
			controlsDialog.showMe();
			keyBindings.saveSettings(preferences);
			preferences.putBoolean(PLAY_SOUNDS, soundIdReader.isEnabled());
			preferences.putBoolean(PLAY_MUSIC, musicPlayer.isEnabled());
		}
	});
	frame.addComponent(btnControlsGame);
	SwingUtils.setBoundsAndCenterHorizontally(btnControlsGame, BUTTON_LEFT, 290, BUTTON_WIDTH, BUTTON_HEIGHT);
}
 
Example 4
Source File: ColopediaGameObjectTypePanel.java    From freecol with GNU General Public License v2.0 5 votes vote down vote up
protected JButton getUnitButton(final UnitType unitType, String roleId) {
    ImageIcon unitIcon = new ImageIcon(getImageLibrary()
        .getSmallUnitTypeImage(unitType, roleId, false));
    JButton unitButton = getButton(unitType, null, unitIcon);
    unitButton.setHorizontalAlignment(JButton.LEFT);
    return unitButton;
}
 
Example 5
Source File: CompactLabourReport.java    From freecol with GNU General Public License v2.0 5 votes vote down vote up
private JButton createButton(String name, ActionListener listener) {
    JButton button = new JButton(name);
    button.setMargin(new Insets(0, 0, 0, 0));
    button.setOpaque(false);
    button.setHorizontalAlignment(SwingConstants.LEADING);
    button.setForeground(Utility.LINK_COLOR);
    button.setBorder(Utility.LEFTCELLBORDER);
    button.addActionListener(listener);
    return button;
}
 
Example 6
Source File: EquipmentListJPanel.java    From defense-solutions-proofs-of-concept with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the names of the equipment for which buttons should display.
 * @param equipmentNames the names of the equipment for which buttons should display.
 */
public void setEquipmentNames(List<String> equipmentNames) {
    removeAll();

    for (final String name : equipmentNames) {
        JButton button = new JButton(name) {
            @Override
            public void paint(Graphics g) {
                if (null == getIcon()) {
                    //Doing this here because it's expensive, so only
                    //do it when we actually need it.
                    setIcon(new ImageIcon(mil2525CSymbolController.getSymbolImage(name)));
                }
                super.paint(g);
            }
        };
        button.setFont(BUTTON_FONT);
        button.setHorizontalAlignment(SwingConstants.LEFT);
        button.setFocusable(false);
        button.setMaximumSize(new Dimension(Integer.MAX_VALUE, 60));
        button.setMinimumSize(new Dimension(0, 60));
        button.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                for (ActionListener listener : listeners) {
                    listener.actionPerformed(e);
                }
            }
        });
        add(button);
    }
}
 
Example 7
Source File: StartScreen.java    From WorldGrower with GNU General Public License v3.0 5 votes vote down vote up
private void addExitButton() {
	JButton btnExit = JButtonFactory.createButton("Exit", IconUtils.getExitIcon(), imageInfoReader, soundIdReader);
	btnExit.setHorizontalAlignment(SwingConstants.LEFT);
	btnExit.setHorizontalTextPosition(SwingConstants.RIGHT);
	btnExit.setToolTipText("Exits program");
	btnExit.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) {
			System.exit(0);
		}
	});
	frame.addComponent(btnExit);
	SwingUtils.setBoundsAndCenterHorizontally(btnExit, BUTTON_LEFT, 430, BUTTON_WIDTH, BUTTON_HEIGHT);
}
 
Example 8
Source File: StartScreen.java    From WorldGrower with GNU General Public License v3.0 5 votes vote down vote up
private void addLoadButton() {
	JButton btnLoadGame = JButtonFactory.createButton("Load Game", IconUtils.getLoadIcon(), imageInfoReader, soundIdReader);
	btnLoadGame.setHorizontalAlignment(SwingConstants.LEFT);
	btnLoadGame.setHorizontalTextPosition(SwingConstants.RIGHT);
	btnLoadGame.setToolTipText("Loads a game");
	btnLoadGame.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent arg0) {
			LoadSaveDialog loadSaveDialog = new LoadSaveDialog(StartScreen.this, LoadSaveMode.LOAD, imageInfoReader, soundIdReader);
			loadSaveDialog.showMe();
		}
	});
	frame.addComponent(btnLoadGame);
	SwingUtils.setBoundsAndCenterHorizontally(btnLoadGame, BUTTON_LEFT, 150, BUTTON_WIDTH, BUTTON_HEIGHT);
}
 
Example 9
Source File: SettlementTransparentPanel.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
public void buildLabelPane() {

        labelPane = new JPanel(new FlowLayout(FlowLayout.LEADING));
        labelPane.setBackground(new Color(0,0,0,128));
		labelPane.setOpaque(false);

		JButton labelsButton = new JButton(Msg.getString("SettlementTransparentPanel.button.labels")); //$NON-NLS-1$
		//labelsButton.setFont(new Font("Dialog", Font.BOLD, 16));
		//labelsButton.setBackground(new Color(139,69,19)); // (139,69,19) is brown
		//labelsButton.setBackground(new Color(139,69,19,40));
		//labelsButton.setBackground(new Color(51,25,0,5)); // dull gold color
//		labelsButton.setBackground(new Color(0,0,0));//,0));
		labelsButton.setPreferredSize(new Dimension(80, 20));
//		labelsButton.setForeground(Color.green);
		labelsButton.setOpaque(false);
		labelsButton.setVerticalAlignment(JLabel.CENTER);
		labelsButton.setHorizontalAlignment(JLabel.CENTER);
		//labelsButton.setContentAreaFilled(false); more artifact when enabled
//		labelsButton.setBorder(new LineBorder(Color.green, 1, true));
		labelsButton.setToolTipText(Msg.getString("SettlementTransparentPanel.tooltip.labels")); //$NON-NLS-1$
		labelsButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent evt) {
				JButton button = (JButton) evt.getSource();
				if (labelsMenu == null) {
					labelsMenu = createLabelsMenu();
				}
				labelsMenu.show(button, 0, button.getHeight());
				//repaint();
			}
		});

		labelPane.add(labelsButton);


		labelPane.add(emptyLabel);
	}
 
Example 10
Source File: MainGui.java    From OpenID-Attacker with GNU General Public License v2.0 4 votes vote down vote up
private void removeBackgroundFromButton(JButton button) {
    button.setHorizontalAlignment(SwingConstants.LEFT);
    button.setBorder(null);
    button.setBorderPainted(false);
    button.setContentAreaFilled(false);
}
 
Example 11
Source File: ReptileFrame.java    From JavaMainRepo with Apache License 2.0 4 votes vote down vote up
public ReptileFrame(String title, String animalType) {
	super(title);
	this.animalType = animalType;

	contentPanel.setLayout(new BorderLayout());
	JPanel pan = new JPanel();
	pan.setLayout(new GridLayout(6, 2, 5, 10));
	contentPanel.add(pan, BorderLayout.CENTER);

	// Add first column - LABELS

	JLabel lblName = new JLabel("Name: ");
	lblName.setHorizontalAlignment(SwingConstants.CENTER);
	JLabel lblNrOfLegs = new JLabel("Number of Legs: ");
	lblNrOfLegs.setHorizontalAlignment(SwingConstants.CENTER);
	JLabel lblDangerPerc = new JLabel("Danger Percentage: ");
	lblDangerPerc.setHorizontalAlignment(SwingConstants.CENTER);
	JLabel lblMaintenanceCost = new JLabel("Maintenance Cost: ");
	lblMaintenanceCost.setHorizontalAlignment(SwingConstants.CENTER);
	JLabel lblLaysEggs = new JLabel("Lays Eggs: ");
	lblLaysEggs.setHorizontalAlignment(SwingConstants.CENTER);

	// Add second column - INPUTS

	nameField = new JTextField();
	nrOfLegsField = new JSpinner();
	dangerPercField = new JTextField();
	maintenanceCostField = new JTextField();
	laysEggsBox = new JCheckBox();
	laysEggsBox.setSelected(false);

	pan.add(lblName);
	pan.add(nameField);
	pan.add(lblNrOfLegs);
	pan.add(nrOfLegsField);
	pan.add(lblMaintenanceCost);
	pan.add(dangerPercField);
	pan.add(lblDangerPerc);
	pan.add(maintenanceCostField);
	pan.add(lblLaysEggs);
	pan.add(laysEggsBox);
	

	// Put a Create button at the end of the form
	btnCreate = new JButton("Create & Add to List");
	btnCreate.setHorizontalAlignment(SwingConstants.CENTER);
	contentPanel.add(btnCreate, BorderLayout.PAGE_END);
}
 
Example 12
Source File: MammalFrame.java    From JavaMainRepo with Apache License 2.0 4 votes vote down vote up
public MammalFrame(String title, String animalType) {
	super(title);
	this.animalType = animalType;

	contentPanel.setLayout(new BorderLayout());
	JPanel pan = new JPanel();
	pan.setLayout(new GridLayout(6, 2, 5, 10));
	contentPanel.add(pan, BorderLayout.CENTER);

	// Add first column - LABELS

	JLabel lblName = new JLabel("Name: ");
	lblName.setHorizontalAlignment(SwingConstants.CENTER);
	JLabel lblNrOfLegs = new JLabel("Number of Legs: ");
	lblNrOfLegs.setHorizontalAlignment(SwingConstants.CENTER);
	JLabel lblDangerPerc = new JLabel("Danger Percentage: ");
	lblDangerPerc.setHorizontalAlignment(SwingConstants.CENTER);
	JLabel lblMaintenanceCost = new JLabel("Maintenance Cost: ");
	lblMaintenanceCost.setHorizontalAlignment(SwingConstants.CENTER);
	JLabel lblNormalBodyTemp = new JLabel("Normal Body Temperature: ");
	lblNormalBodyTemp.setHorizontalAlignment(SwingConstants.CENTER);
	JLabel lblPercBodyHair = new JLabel("Body Hair Percentage: ");
	lblPercBodyHair.setHorizontalAlignment(SwingConstants.CENTER);

	// Add second column - INPUTS

	nameField = new JTextField();
	nrOfLegsField = new JSpinner();
	dangerPercField = new JTextField();
	maintenanceCostField = new JTextField();
	normalBodyTempField = new JTextField();
	percBodyHarField = new JTextField();

	pan.add(lblName);
	pan.add(nameField);
	pan.add(lblNrOfLegs);
	pan.add(nrOfLegsField);
	pan.add(lblMaintenanceCost);
	pan.add(dangerPercField);
	pan.add(lblDangerPerc);
	pan.add(maintenanceCostField);
	pan.add(lblNormalBodyTemp);
	pan.add(normalBodyTempField);
	pan.add(lblPercBodyHair);
	pan.add(percBodyHarField);

	// Put a Create button at the end of the form
	btnCreate = new JButton("Create & Add to List");
	btnCreate.setHorizontalAlignment(SwingConstants.CENTER);
	contentPanel.add(btnCreate, BorderLayout.PAGE_END);
}
 
Example 13
Source File: RoutingTab.java    From jeveassets with GNU General Public License v2.0 4 votes vote down vote up
public ResultToolbar() {
	jToolBar = new JToolBar();
	GroupLayout layout = new GroupLayout(jToolBar);
	jToolBar.setLayout(layout);
	layout.setAutoCreateGaps(true);
	layout.setAutoCreateContainerGaps(false);

	jToolBar.setFloatable(false);
	jToolBar.setRollover(true);
	
	jName = new JLabel();
	plain = jName.getFont();
	italic = new Font(plain.getName(), Font.ITALIC, plain.getSize());

	jEveUiSetRoute = new JButton(TabsRouting.get().resultUiWaypoints(), Images.MISC_EVE.getIcon());
	jEveUiSetRoute.setActionCommand(RoutingAction.EVE_UI.name());
	jEveUiSetRoute.addActionListener(listener);
	jEveUiSetRoute.setEnabled(false);

	jEditRoute = new JButton(TabsRouting.get().resultEdit(), Images.EDIT_EDIT.getIcon());
	jEditRoute.setHorizontalAlignment(JButton.LEFT);
	jEditRoute.setActionCommand(RoutingAction.ROUTE_EDIT.name());
	jEditRoute.addActionListener(listener);
	jEditRoute.setEnabled(false);

	jSaveRoute = new JButton(TabsRouting.get().resultSave(), Images.FILTER_SAVE.getIcon());
	jSaveRoute.setHorizontalAlignment(JButton.LEFT);
	jSaveRoute.setActionCommand(RoutingAction.ROUTE_SAVE.name());
	jSaveRoute.addActionListener(listener);
	jSaveRoute.setEnabled(false);

	jLoadRoute = new JDropDownButton(TabsRouting.get().resultLoad(), Images.FILTER_LOAD.getIcon());
	jLoadRoute.setHorizontalAlignment(JButton.LEFT);

	layout.setHorizontalGroup(
		layout.createSequentialGroup()
			.addContainerGap()
			.addComponent(jName, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, Integer.MAX_VALUE)
			.addGap(0, 0, Integer.MAX_VALUE)
			.addComponent(jEveUiSetRoute)
			.addComponent(jEditRoute, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, 100)
			.addComponent(jSaveRoute, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, 100)
			.addComponent(jLoadRoute, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, 100)
			.addContainerGap()
	);
	layout.setVerticalGroup(
		layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
			.addComponent(jName)
			.addComponent(jEveUiSetRoute)
			.addComponent(jEditRoute)
			.addComponent(jSaveRoute)
			.addComponent(jLoadRoute)
	);

	jManageRoutes = new JMenuItem(TabsRouting.get().resultManage(), Images.DIALOG_SETTINGS.getIcon());
	jManageRoutes.setActionCommand(RoutingAction.ROUTE_MANAGE.name());
	jManageRoutes.addActionListener(listener);
}
 
Example 14
Source File: JManageDialog.java    From jeveassets with GNU General Public License v2.0 4 votes vote down vote up
public JManageDialog(Program program, JFrame jFrame, String title, boolean supportMerge, boolean supportExport) {
	super(program, title, jFrame, Images.DIALOG_SETTINGS.getImage());
	this.supportMerge = supportMerge;

	ListenerClass listener = new ListenerClass();

	//Load
	jLoad = new JButton(GuiShared.get().managerLoad(), Images.FILTER_LOAD.getIcon());
	jLoad.setActionCommand(ManageDialogAction.LOAD.name());
	jLoad.addActionListener(listener);
	jLoad.setHorizontalAlignment(SwingConstants.LEFT);

	//Rename
	jRename = new JButton(GuiShared.get().managerRename(), Images.EDIT_EDIT.getIcon());
	jRename.setActionCommand(ManageDialogAction.RENAME.name());
	jRename.addActionListener(listener);
	jRename.setHorizontalAlignment(SwingConstants.LEFT);

	//Delete
	jDelete = new JButton(GuiShared.get().managerDelete(), Images.EDIT_DELETE.getIcon());
	jDelete.setActionCommand(ManageDialogAction.DELETE.name());
	jDelete.addActionListener(listener);
	jDelete.setHorizontalAlignment(SwingConstants.LEFT);

	//Export
	jExport = new JButton(GuiShared.get().managerExport(), Images.DIALOG_CSV_EXPORT.getIcon());
	jExport.setActionCommand(ManageDialogAction.EXPORT.name());
	jExport.addActionListener(listener);
	jExport.setVisible(supportExport);
	jExport.setHorizontalAlignment(SwingConstants.LEFT);

	//Import
	jImport = new JButton(GuiShared.get().managerImport(), Images.EDIT_IMPORT.getIcon());
	jImport.setActionCommand(ManageDialogAction.IMPORT.name());
	jImport.addActionListener(listener);
	jImport.setVisible(supportExport);
	jImport.setHorizontalAlignment(SwingConstants.LEFT);
	
	//Done
	jClose = new JButton(GuiShared.get().managerClose());
	jClose.setActionCommand(ManageDialogAction.DONE.name());
	jClose.addActionListener(listener);

	//List
	listModel = new DefaultListModel<String>();
	jList = new JList<String>(listModel);
	jList.addMouseListener(listener);
	jList.addListSelectionListener(listener);
	JScrollPane jScrollPanel = new JScrollPane(jList);
	jPanel.add(jScrollPanel);

	layout.setHorizontalGroup(
		layout.createSequentialGroup()
			.addComponent(jScrollPanel, 175, 175, 175)
			.addGroup(layout.createParallelGroup()
				.addComponent(jLoad, 100, 100, 100)
				.addComponent(jRename, 100, 100, 100)
				.addComponent(jDelete, 100, 100, 100)
				.addComponent(jExport, 100, 100, 100)
				.addComponent(jImport, 100, 100, 100)
				.addComponent(jClose, 100, 100, 100)
			)
	);
	layout.setVerticalGroup(
		layout.createParallelGroup()
			.addComponent(jScrollPanel, 250, 250, 250)
			.addGroup(layout.createSequentialGroup()
				.addComponent(jLoad, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
				.addComponent(jRename, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
				.addComponent(jDelete, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
				.addGap(15, 15, 15)
				.addComponent(jExport, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
				.addComponent(jImport, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
				.addGap(0, 0, Integer.MAX_VALUE)
				.addComponent(jClose, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
			)
	);
}
 
Example 15
Source File: AttributeStatisticsPanel.java    From rapidminer-studio with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * Updates the charts.
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
private void updateCharts() {
	for (int i = 0; i < listOfChartPanels.size(); i++) {
		JPanel panel = listOfChartPanels.get(i);
		panel.removeAll();
		final ChartPanel chartPanel = new ChartPanel(getModel().getChartOrNull(i)) {

			private static final long serialVersionUID = -6953213567063104487L;

			@Override
			public Dimension getPreferredSize() {
				return DIMENSION_CHART_PANEL_ENLARGED;
			}
		};
		chartPanel.setPopupMenu(null);
		chartPanel.setBackground(COLOR_TRANSPARENT);
		chartPanel.setOpaque(false);
		chartPanel.addMouseListener(enlargeAndHoverAndPopupMouseAdapter);
		panel.add(chartPanel, BorderLayout.CENTER);

		JPanel openChartPanel = new JPanel(new GridBagLayout());
		openChartPanel.setOpaque(false);

		GridBagConstraints gbc = new GridBagConstraints();
		gbc.anchor = GridBagConstraints.CENTER;
		gbc.fill = GridBagConstraints.NONE;
		gbc.weightx = 1.0;
		gbc.weighty = 1.0;

		JButton openChartButton = new JButton(OPEN_CHART_ACTION);
		openChartButton.setOpaque(false);
		openChartButton.setContentAreaFilled(false);
		openChartButton.setBorderPainted(false);
		openChartButton.addMouseListener(enlargeAndHoverAndPopupMouseAdapter);
		openChartButton.setHorizontalAlignment(SwingConstants.LEFT);
		openChartButton.setHorizontalTextPosition(SwingConstants.LEFT);
		openChartButton.setIcon(null);
		Font font = openChartButton.getFont();
		Map attributes = font.getAttributes();
		attributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
		openChartButton.setFont(font.deriveFont(attributes).deriveFont(10.0f));

		openChartPanel.add(openChartButton, gbc);

		panel.add(openChartPanel, BorderLayout.SOUTH);
		panel.revalidate();
		panel.repaint();
	}
}
 
Example 16
Source File: BeltColumnStatisticsPanel.java    From rapidminer-studio with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * Updates the charts.
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
private void updateCharts() {
	for (int i = 0; i < listOfChartPanels.size(); i++) {
		JPanel panel = listOfChartPanels.get(i);
		panel.removeAll();
		JFreeChart chartOrNull = getModel().getChartOrNull(i);
		if (chartOrNull != null) {
			final ChartPanel chartPanel = new ChartPanel(chartOrNull) {

				private static final long serialVersionUID = -6953213567063104487L;

				@Override
				public Dimension getPreferredSize() {
					return DIMENSION_CHART_PANEL_ENLARGED;
				}
			};
			chartPanel.setPopupMenu(null);
			chartPanel.setBackground(COLOR_TRANSPARENT);
			chartPanel.setOpaque(false);
			chartPanel.addMouseListener(enlargeAndHoverAndPopupMouseAdapter);
			panel.add(chartPanel, BorderLayout.CENTER);

			JPanel openChartPanel = new JPanel(new GridBagLayout());
			openChartPanel.setOpaque(false);

			GridBagConstraints gbc = new GridBagConstraints();
			gbc.anchor = GridBagConstraints.CENTER;
			gbc.fill = GridBagConstraints.NONE;
			gbc.weightx = 1.0;
			gbc.weighty = 1.0;

			JButton openChartButton = new JButton(OPEN_CHART_ACTION);
			openChartButton.setOpaque(false);
			openChartButton.setContentAreaFilled(false);
			openChartButton.setBorderPainted(false);
			openChartButton.addMouseListener(enlargeAndHoverAndPopupMouseAdapter);
			openChartButton.setHorizontalAlignment(SwingConstants.LEFT);
			openChartButton.setHorizontalTextPosition(SwingConstants.LEFT);
			openChartButton.setIcon(null);
			Font font = openChartButton.getFont();
			Map attributes = font.getAttributes();
			attributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
			openChartButton.setFont(font.deriveFont(attributes).deriveFont(10.0f));

			openChartPanel.add(openChartButton, gbc);

			panel.add(openChartPanel, BorderLayout.SOUTH);
		}
		panel.revalidate();
		panel.repaint();
	}
}
 
Example 17
Source File: SampleBoard.java    From audiveris with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * Define the layout for SampleBoard specific fields.
 */
private void defineLayout ()
{
    final CellConstraints cst = new CellConstraints();

    // Layout
    int r = 1; // -----------------------------

    JButton removeButton = new JButton(controller.getRemoveAction());
    removeButton.setHorizontalTextPosition(SwingConstants.LEFT);
    removeButton.setHorizontalAlignment(SwingConstants.RIGHT);
    removeAction.setEnabled(false);
    builder.add(removeButton, cst.xyw(5, r, 3));

    assignButton = new JButton(assignAction);
    assignButton.setHorizontalTextPosition(SwingConstants.LEFT);
    assignButton.setHorizontalAlignment(SwingConstants.RIGHT);
    assignAction.setEnabled(false);
    builder.add(assignButton, cst.xyw(9, r, 3));

    r += 2; // --------------------------------

    // Shape Icon (start, spans several rows)
    builder.add(shapeIcon, cst.xywh(3, r, 1, 9));

    builder.add(sheetName.getLabel(), cst.xy(1, r));
    builder.add(sheetName.getField(), cst.xyw(3, r, 9));

    r += 2; // --------------------------------

    builder.add(shapeField.getLabel(), cst.xy(5, r));
    builder.add(shapeField.getField(), cst.xyw(7, r, 5));

    r += 2; // --------------------------------

    builder.add(iLine.getLabel(), cst.xy(5, r));
    builder.add(iLine.getField(), cst.xy(7, r));

    builder.add(width.getLabel(), cst.xy(9, r));
    builder.add(width.getField(), cst.xy(11, r));

    r += 2; // --------------------------------

    builder.add(weight.getLabel(), cst.xy(5, r));
    builder.add(weight.getField(), cst.xy(7, r));

    builder.add(height.getLabel(), cst.xy(9, r));
    builder.add(height.getField(), cst.xy(11, r));

    r += 2; // --------------------------------

    builder.add(pitch.getLabel(), cst.xy(9, r));
    builder.add(pitch.getField(), cst.xy(11, r));
}
 
Example 18
Source File: InterBoard.java    From audiveris with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * Define the layout for InterBoard specific fields.
 */
private void defineLayout ()
{
    final CellConstraints cst = new CellConstraints();

    // Layout
    int r = 1; // -----------------------------

    // Shape Icon (start, spans several rows) + grade + Deassign button
    builder.add(shapeIcon, cst.xywh(1, r, 1, 5));

    builder.add(grade.getLabel(), cst.xy(5, r));
    builder.add(grade.getField(), cst.xy(7, r));

    JButton deassignButton = new JButton(deassignAction);
    deassignButton.setHorizontalTextPosition(SwingConstants.LEFT);
    deassignButton.setHorizontalAlignment(SwingConstants.RIGHT);
    deassignAction.setEnabled(false);
    builder.add(deassignButton, cst.xyw(9, r, 3));

    r += 2; // --------------------------------

    builder.add(shapeField.getField(), cst.xyw(7, r, 5));

    r += 2; // --------------------------------

    roleCombo.getField().setMaximumRowCount(TextRole.values().length);
    roleCombo.addActionListener(paramAction);
    roleCombo.setVisible(false);
    builder.add(roleCombo.getField(), cst.xyw(3, r, 4));

    // Text field
    textField.getField().setHorizontalAlignment(JTextField.LEFT);
    textField.setVisible(false);
    builder.add(textField.getField(), cst.xyw(7, r, 5));

    r += 2; // --------------------------------

    builder.add(details, cst.xyw(1, r, 11));

    // Needed to process user input when RETURN/ENTER is pressed
    getComponent().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(
            KeyStroke.getKeyStroke("ENTER"),
            "TextAction");
    getComponent().getActionMap().put("TextAction", paramAction);
}
 
Example 19
Source File: BirdFrame.java    From JavaMainRepo with Apache License 2.0 4 votes vote down vote up
public BirdFrame(String title, String animalType) {
	super(title);
	this.animalType = animalType;

	contentPanel.setLayout(new BorderLayout());
	JPanel pan = new JPanel();
	pan.setLayout(new GridLayout(6, 2, 5, 10));
	contentPanel.add(pan, BorderLayout.CENTER);

	// Add first column - LABELS

	JLabel lblName = new JLabel("Name: ");
	lblName.setHorizontalAlignment(SwingConstants.CENTER);
	JLabel lblNrOfLegs = new JLabel("Number of Legs: ");
	lblNrOfLegs.setHorizontalAlignment(SwingConstants.CENTER);
	JLabel lblDangerPerc = new JLabel("Danger Percentage: ");
	lblDangerPerc.setHorizontalAlignment(SwingConstants.CENTER);
	JLabel lblMaintenanceCost = new JLabel("Maintenance Cost: ");
	lblMaintenanceCost.setHorizontalAlignment(SwingConstants.CENTER);
	JLabel lblavgFlightAltitude = new JLabel("Average Flight Altitude: ");
	lblavgFlightAltitude.setHorizontalAlignment(SwingConstants.CENTER);
	JLabel lblMigrates = new JLabel("Migrates: ");
	lblMigrates.setHorizontalAlignment(SwingConstants.CENTER);

	// Add second column - INPUTS

	nameField = new JTextField();
	nrOfLegsField = new JSpinner();
	dangerPercField = new JTextField();
	maintenanceCostField = new JTextField();
	avgFlightAltitudeField = new JSpinner();
	migratesBox = new JCheckBox();
	migratesBox.setSelected(false);

	pan.add(lblName);
	pan.add(nameField);
	pan.add(lblNrOfLegs);
	pan.add(nrOfLegsField);
	pan.add(lblMaintenanceCost);
	pan.add(dangerPercField);
	pan.add(lblDangerPerc);
	pan.add(maintenanceCostField);
	pan.add(lblavgFlightAltitude);
	pan.add(avgFlightAltitudeField);
	pan.add(lblMigrates);
	pan.add(migratesBox);

	// Put a Create button at the end of the form
	btnCreate = new JButton("Create & Add to List");
	btnCreate.setHorizontalAlignment(SwingConstants.CENTER);
	contentPanel.add(btnCreate, BorderLayout.PAGE_END);
}
 
Example 20
Source File: InsectFrame.java    From JavaMainRepo with Apache License 2.0 4 votes vote down vote up
public InsectFrame(String title, String animalType) {
	super(title);
	this.animalType = animalType;

	contentPanel.setLayout(new BorderLayout());
	JPanel pan = new JPanel();
	pan.setLayout(new GridLayout(6, 2, 5, 10));
	contentPanel.add(pan, BorderLayout.CENTER);

	// Add first column - LABELS

	JLabel lblName = new JLabel("Name: ");
	lblName.setHorizontalAlignment(SwingConstants.CENTER);
	JLabel lblNrOfLegs = new JLabel("Number of Legs: ");
	lblNrOfLegs.setHorizontalAlignment(SwingConstants.CENTER);
	JLabel lblDangerPerc = new JLabel("Danger Percentage: ");
	lblDangerPerc.setHorizontalAlignment(SwingConstants.CENTER);
	JLabel lblMaintenanceCost = new JLabel("Maintenance Cost: ");
	lblMaintenanceCost.setHorizontalAlignment(SwingConstants.CENTER);
	JLabel lblCanFly = new JLabel("Can Fly: ");
	lblCanFly.setHorizontalAlignment(SwingConstants.CENTER);
	JLabel lblDangerous = new JLabel("Is Dangerous: ");
	lblDangerous.setHorizontalAlignment(SwingConstants.CENTER);

	// Add second column - INPUTS

	nameField = new JTextField();
	nrOfLegsField = new JSpinner();
	dangerPercField = new JTextField();
	maintenanceCostField = new JTextField();
	canFlyBox = new JCheckBox();
	canFlyBox.setSelected(false);
	dangerousBox = new JCheckBox();
	dangerousBox.setSelected(false);

	pan.add(lblName);
	pan.add(nameField);
	pan.add(lblNrOfLegs);
	pan.add(nrOfLegsField);
	pan.add(lblMaintenanceCost);
	pan.add(dangerPercField);
	pan.add(lblDangerPerc);
	pan.add(maintenanceCostField);
	pan.add(lblCanFly);
	pan.add(canFlyBox);
	pan.add(lblDangerous);
	pan.add(dangerousBox);

	// Put a Create button at the end of the form
	btnCreate = new JButton("Create & Add to List");
	btnCreate.setHorizontalAlignment(SwingConstants.CENTER);
	contentPanel.add(btnCreate, BorderLayout.PAGE_END);
}