Java Code Examples for javax.swing.JLabel.setHorizontalAlignment()
The following are Jave code examples for showing how to use
setHorizontalAlignment() of the
javax.swing.JLabel
class.
You can vote up the examples you like. Your votes will be used in our system to get
more good examples.
+ Save this method
Example 1
Project: java-course File: BarChartDemo.java View Source Code | 6 votes |
/** * Initializes GUI. */ private void initGUI() { ParserUtilty parser = null; Path path = null; try { path = Paths.get(pathString); parser = new ParserUtilty(path); } catch (Exception e) { System.out.println("Unable to parse given file! " + e.getMessage()); System.exit(-1); } BarChart model = new BarChart(parser.getValues(), parser.getxDescription(), parser.getyDescription(), parser.getyStart(), parser.getyEnd(), parser.getStep()); BarChartComponent komponenta = new BarChartComponent(model); JLabel label = new JLabel(path.toAbsolutePath().toString()); label.setHorizontalAlignment(SwingConstants.CENTER); getContentPane().setLayout(new BorderLayout()); getContentPane().add(label, BorderLayout.PAGE_START); getContentPane().add(komponenta, BorderLayout.CENTER); getContentPane().setBackground(Color.WHITE); pack(); }
Example 2
Project: POPBL_V File: Date.java View Source Code | 6 votes |
public Date(Color textColor, Font font, Color backgroundColor, boolean setOpaque) { this.setLayout(new BorderLayout()); this.setBackground(backgroundColor); this.setOpaque(setOpaque); locale = Locale.getDefault(); dateText = new JLabel(); dateText.setHorizontalAlignment(JLabel.CENTER); dateText.setVerticalAlignment(JLabel.CENTER); dateText.setForeground(textColor); dateText.setFont(font); this.add(dateText, BorderLayout.CENTER); iniciar(); }
Example 3
Project: bbm487s2017g1 File: CustomerMyBooksAndReservationsWindow.java View Source Code | 6 votes |
/** * Initialize the contents of the frame. */ private void initialize() { frame = new JFrame("Library Book Loan System - My Books and Reservations"); frame.setResizable(false); frame.setBounds(100, 100, 700, 400); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().setLayout(null); JLabel label = new JLabel("Library Book Loan System"); label.setHorizontalAlignment(SwingConstants.CENTER); label.setFont(new Font("Segoe UI Light", Font.PLAIN, 18)); label.setBounds(10, 11, 674, 30); frame.getContentPane().add(label); JLabel lblBookReservations = new JLabel("My Books and Reservations"); lblBookReservations.setHorizontalAlignment(SwingConstants.CENTER); lblBookReservations.setFont(new Font("Segoe UI Light", Font.PLAIN, 14)); lblBookReservations.setBounds(10, 42, 674, 22); frame.getContentPane().add(lblBookReservations); JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP); tabbedPane.setBackground(SystemColor.text); tabbedPane.setBounds(10, 75, 674, 228); frame.getContentPane().add(tabbedPane); initializeCurrentBooks(tabbedPane); initializeWaitlist(tabbedPane); initializeHistory(tabbedPane); frame.setVisible(true); }
Example 4
Project: jmt File: JWatStartScreen.java View Source Code | 6 votes |
private void initGUI() { this.setIconImage(JMTImageLoader.loadImage(IMG_JWATICON).getImage()); this.setResizable(false); this.setTitle("JWAT"); this.setSize(CommonConstants.MAX_GUI_WIDTH_JWAT_STARTSCREEN, CommonConstants.MAX_GUI_HEIGHT_JWAT_STARTSCREEN); //Image image = new ImageIcon(imageURL).getImage(); //image = image.getScaledInstance(400, 315, Image.SCALE_SMOOTH); JPanel eastPanel = new JPanel(new BorderLayout()); eastPanel.add(Box.createVerticalStrut(5), BorderLayout.NORTH); JPanel buttonPanel = new JPanel(new GridLayout(buttonAction.length, 1, 2, 2)); eastPanel.add(buttonPanel, BorderLayout.CENTER); for (AbstractAction element : buttonAction) { buttonPanel.add(createButton(element)); } JLabel imageLabel = new JLabel(); imageLabel.setBorder(BorderFactory.createEmptyBorder(BUTTONSIZE - 5, 1, 0, 0)); //imageLabel.setIcon(new ImageIcon(image)); imageLabel.setIcon(new ImageIcon(new ImageIcon(imageURL).getImage().getScaledInstance(400, 315, Image.SCALE_SMOOTH))); imageLabel.setHorizontalAlignment(SwingConstants.RIGHT); imageLabel.setVerticalAlignment(SwingConstants.NORTH); this.getContentPane().add(imageLabel, BorderLayout.CENTER); this.getContentPane().add(eastPanel, BorderLayout.EAST); }
Example 5
Project: enigma-vk File: Gui.java View Source Code | 5 votes |
private void clearReference() { m_infoPanel.removeAll(); JLabel label = new JLabel("No identifier selected"); GuiTricks.unboldLabel(label); label.setHorizontalAlignment(JLabel.CENTER); m_infoPanel.add(label); redraw(); }
Example 6
Project: Equella File: BasicMessageEditor.java View Source Code | 5 votes |
public BasicMessageEditor(String message) { JLabel messageLabel = new JLabel(message); messageLabel.setHorizontalAlignment(SwingConstants.CENTER); setLayout(new GridLayout(1, 1)); add(messageLabel); }
Example 7
Project: apcs_final File: PauseMenu.java View Source Code | 5 votes |
public void makePauseLabel() { pauseLabel = new JLabel("PAUSE"); pauseLabel.setForeground(GameConstants.PAUSE_FG_COLOR); pauseLabel.setBounds(0, 0, getWidth(), 2*getHeight()/3); pauseLabel.setHorizontalAlignment(SwingConstants.CENTER); add(pauseLabel); }
Example 8
Project: incubator-netbeans File: RecentProjectsPanel.java View Source Code | 5 votes |
private JPanel startBuildingContent() { JPanel panel = new JPanel( new BorderLayout() ); panel.setOpaque( false ); JLabel lbl = new JLabel(BundleSupport.getLabel( "LoadingProjects" )); lbl.setHorizontalAlignment(JLabel.CENTER); panel.add( lbl, BorderLayout.CENTER ); loadProjects(); return panel; }
Example 9
Project: apcs_final File: NewGamePanel.java View Source Code | 5 votes |
private void makeDifficultyLabel() { difficultyLabel = new JLabel("Choose Difficulty: "); difficultyLabel.setBounds(0, height/3, width/2, height/10); difficultyLabel.setHorizontalAlignment(SwingConstants.RIGHT); difficultyLabel.setForeground(GameConstants.TEXT_COLOR); difficultyLabel.setFont(FileUtils.getFont(Font.BOLD, 40)); add(difficultyLabel); }
Example 10
Project: Progetto-I File: ExecutePage.java View Source Code | 5 votes |
private void initLabels() { domanda = new JLabel(); domanda.setFont(fontDomanda); domanda.setText(progetto.mostraDomandaAttuale()); domanda.setHorizontalAlignment(JLabel.CENTER); seleziona = new JLabel("Seleziona domande precedenti:"); seleziona.setHorizontalAlignment(JLabel.CENTER); }
Example 11
Project: incubator-netbeans File: CloneableEditorInitializer.java View Source Code | 5 votes |
private void addLoadingLabel() { editor.setLayout(new BorderLayout()); loadingLabel = new JLabel(NbBundle.getMessage(CloneableEditor.class, "LBL_EditorLoading")); // NOI18N loadingLabel.setOpaque(true); loadingLabel.setHorizontalAlignment(SwingConstants.CENTER); loadingLabel.setBorder(new EmptyBorder(new Insets(11, 11, 11, 11))); loadingLabel.setVisible(false); editor.add(loadingLabel, BorderLayout.CENTER); }
Example 12
Project: POPBL_V File: Time.java View Source Code | 5 votes |
public Time(Color textColor, Font font, Color backgroundColor, boolean setOpaque) { this.setLayout(new BorderLayout()); this.setBackground(backgroundColor); this.setOpaque(setOpaque); timeText = new JLabel(); timeText.setForeground(textColor); timeText.setFont(font); timeText.setHorizontalAlignment(JLabel.CENTER); this.add(timeText, BorderLayout.CENTER); start(); }
Example 13
Project: jmt File: LDHelpDialog.java View Source Code | 5 votes |
private void initComponents() { Container cp = getContentPane(); cp.setLayout(new BorderLayout()); JPanel butPane = new JPanel(); butPane.add(new JButton(close), BorderLayout.SOUTH); cp.add(butPane, BorderLayout.SOUTH); JTabbedPane jtp = new JTabbedPane(); JPanel general = new JPanel(new BorderLayout()); JLabel ghelp = new JLabel(generalHelp); ghelp.setHorizontalAlignment(SwingConstants.CENTER); ghelp.setVerticalAlignment(SwingConstants.CENTER); JLabel icon = new JLabel(UIManager.getIcon("OptionPane.informationIcon")); Box lbox = Box.createHorizontalBox(); lbox.add(Box.createHorizontalStrut(10)); lbox.add(icon); lbox.add(Box.createHorizontalStrut(10)); general.add(ghelp, BorderLayout.CENTER); general.add(lbox, BorderLayout.WEST); general.add(Box.createHorizontalStrut(10), BorderLayout.EAST); jtp.add("General", general); JPanel evaluator = new JPanel(new BorderLayout()); HtmlPanel ehelp = new HtmlPanel(evalHelp); evaluator.add(Box.createHorizontalStrut(10), BorderLayout.WEST); evaluator.add(new JScrollPane(ehelp), BorderLayout.CENTER); evaluator.add(Box.createHorizontalStrut(10), BorderLayout.EAST); jtp.add("Evaluator", evaluator); cp.add(jtp, BorderLayout.CENTER); }
Example 14
Project: jmt File: TestWizardPanel.java View Source Code | 5 votes |
public TestWizardPanel() { counter++; name = "Panel " + counter; JLabel jl = new JLabel("<html><center>This is <b>" + name + "</b>.<br>Have a nice day!</center></html>"); jl.setHorizontalAlignment(SwingConstants.CENTER); jl.setHorizontalTextPosition(SwingConstants.CENTER); jl.setFont(new Font("Arial", Font.PLAIN, 16)); jl.setBorder(BorderFactory.createEtchedBorder()); setLayout(new BorderLayout()); add(jl, BorderLayout.CENTER); }
Example 15
Project: COE1186 File: SimulatorGui.java View Source Code | 4 votes |
public void stylizeInfoLabel(JLabel l){ l.setHorizontalAlignment(SwingConstants.LEFT); l.setForeground(UIManager.getColor("Button.disabledToolBarBorderBackground")); l.setFont(font_16_bold); }
Example 16
Project: incubator-netbeans File: GetStarted.java View Source Code | 4 votes |
private void buildContent() { String rootName = "WelcomePage/GettingStartedLinks"; // NOI18N FileObject root = FileUtil.getConfigFile( rootName ); if( null == root ) { Logger.getLogger(GetStarted.class.getName()).log(Level.INFO, "Start page content not found: " + "FileObject: " + rootName ); //NOI18N return; } DataFolder folder = DataFolder.findFolder( root ); if( null == folder ) { Logger.getLogger(GetStarted.class.getName()).log(Level.INFO, "Start page content not found: " + "DataFolder: " + rootName ); //NOI18N return; } DataObject[] children = folder.getChildren(); if( null == children ) { Logger.getLogger(GetStarted.class.getName()).log(Level.INFO, "Start page content not found: " + "DataObject: " + rootName ); //NOI18N return; } for( int i=0; i<children.length; i++ ) { if( children[i].getPrimaryFile().isFolder() ) { String headerText = children[i].getNodeDelegate().getDisplayName(); JLabel lblTitle = new JLabel( headerText ); lblTitle.setFont( BUTTON_FONT ); lblTitle.setHorizontalAlignment( JLabel.LEFT ); lblTitle.setOpaque( true ); lblTitle.setBorder( HEADER_TEXT_BORDER ); add( lblTitle, new GridBagConstraints( 0,row++,1,1,1.0,0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0,0,0,0), 0, 0 ) ); DataFolder subFolder = DataFolder.findFolder( children[i].getPrimaryFile() ); DataObject[] subFolderChildren = subFolder.getChildren(); for( int j=0; j<subFolderChildren.length; j++ ) { row = addLink( row, subFolderChildren[j] ); } } else { row = addLink( row, children[i] ); } } add( new JLabel(), new GridBagConstraints(0, row++, 1, 1, 0.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.VERTICAL, new Insets(0,0,0,0), 0, 0 ) ); }
Example 17
Project: Equella File: AdminToolList.java View Source Code | 4 votes |
@Override public void setup(Set<String> grantedPrivileges, String name) { getButtonActions(actions); listFilled = false; model = new GenericListModel<NameValue>(); list = new JList<>(model); list.addMouseListener(new ListDoubleClickListener(list, editAction)); list.addMouseListener(new ListPopupListener(list, actions)); list.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { updateButtons(); } }); JScrollPane scroll = new JScrollPane(list); JLabel heading = new JLabel(name); heading.setHorizontalAlignment(SwingConstants.CENTER); heading.setHorizontalTextPosition(SwingConstants.CENTER); JButton refreshButton = new JTextlessButton(refreshAction); refreshButton.setBorderPainted(false); refreshButton.setIconTextGap(0); refreshButton.setBorder(null); JComponent buttonsComp = createButtonsPanel(); final int width1 = refreshButton.getPreferredSize().width; final int height1 = refreshButton.getPreferredSize().height; final int height2 = buttonsComp.getPreferredSize().height; final int[] rows = {5, height1, 5, TableLayout.FILL, 5, height2,}; final int[] cols = {width1, TableLayout.FILL, width1, 5}; everything = new JPanel(new TableLayout(rows, cols, 0, 0)); everything.add(heading, new Rectangle(1, 1, 1, 1)); everything.add(refreshButton, new Rectangle(2, 1, 1, 1)); everything.add(scroll, new Rectangle(0, 3, 3, 1)); everything.add(buttonsComp, new Rectangle(0, 5, 3, 1)); updateButtons(); }
Example 18
Project: COE1186 File: TrainModelGUI.java View Source Code | 4 votes |
public void stylizeInfoLabel_Small(JLabel l){ l.setHorizontalAlignment(SwingConstants.LEFT); l.setForeground(UIManager.getColor("Button.disabledToolBarBorderBackground")); l.setFont(font_14_bold); }
Example 19
Project: COE1186 File: TrackModelGUI.java View Source Code | 4 votes |
public void stylizeInfoLabel_Bold(JLabel l){ l.setHorizontalAlignment(SwingConstants.LEFT); l.setForeground(new Color(234, 201, 87)); l.setFont(font_16_bold); }
Example 20
Project: COE1186 File: TrackControllerGUI.java View Source Code | 4 votes |
public void stylizeInfoLabel_Bold(JLabel l){ l.setHorizontalAlignment(SwingConstants.RIGHT); l.setForeground(new Color(234, 201, 87)); l.setFont(font_16_bold); }