Java Code Examples for javax.swing.SwingConstants

The following are top voted examples for showing how to use javax.swing.SwingConstants. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: jreliability   File: MeasuresPanel.java   Source Code and License 6 votes vote down vote up
/**
 * Creates the {@link JPanel} showing the mission time.
 * 
 * @param maxwidth
 *            the dimension of the longest label
 * @return the JPanel showing the mission time
 */
private JPanel createMtPanel(Dimension maxwidth) {
	Double mtVal = inverse.evaluate(reliabilityFunction, standardMT);

	JLabel pmtLabel = new JLabel("P[MT] =");
	pmtLabel.setMinimumSize(maxwidth);

	JLabel mtLabel = new JLabel("MT:");
	mtLabel.setMinimumSize(maxwidth);

	mtProbability = new JFormattedTextField(mtFieldFormat);
	mtProbability.addActionListener(MeasurePanel.this);
	mtProbability.setPreferredSize(new Dimension(70, 15));
	mtProbability.setHorizontalAlignment(SwingConstants.RIGHT);
	mtProbability.setText(standardMT.toString());

	mt = new JLabel(mtVal.toString());

	return createSubPanel("Mission-Time", pmtLabel, mtProbability, mtLabel, mt);
}
 
Example 2
Project: gchisto   File: AllStatsTableSingle.java   Source Code and License 6 votes vote down vote up
public void update() {
    rows = datasetGenerator.getGCActivityNum();

    labels = new JLabel[rows][columns];
    for (int r = 0; r < rows; ++r) {
        String gcActivityName = datasetGenerator.getGCActivityName(r);
        JLabel label = GUIUtilities.createJLabelForTable(gcActivityName);
        GUIUtilities.setTableHeader(label);
        labels[r][0] = label;

        for (int c = 1; c < columns; ++c) {
            label = GUIUtilities.createJLabelForTable();
            label.setHorizontalAlignment(SwingConstants.RIGHT);
            labels[r][c] = label;
        }
    }
}
 
Example 3
Project: ramus   File: PriceAttributePlugin.java   Source Code and License 6 votes vote down vote up
@Override
public TableCellRenderer getTableCellRenderer(Engine engine,
                                              AccessRules rules, Attribute attribute) {
    return new DefaultTableCellRenderer() {
        /**
         *
         */
        private static final long serialVersionUID = -7922052040779840252L;

        {
            setHorizontalAlignment(SwingConstants.RIGHT);
        }

        @Override
        public Component getTableCellRendererComponent(JTable table,
                                                       Object value, boolean isSelected, boolean hasFocus,
                                                       int row, int column) {
            Component component = super.getTableCellRendererComponent(
                    table, value, isSelected, hasFocus, row, column);
            if (value != null)
                ((JLabel) component).setText(format(value));
            return component;
        }
    };
}
 
Example 4
Project: Hollow-Knight-SaveManager   File: LoadDelete.java   Source Code and License 6 votes vote down vote up
/**
 * This SavePanel creates delete and load buttons
 * 
 * @param gui
 */
public LoadDelete(GUI gui){
	
	this.setLayout(new BorderLayout());
	
	filename = new JLabel("test");
	filename.setHorizontalAlignment(SwingConstants.CENTER);
	this.add(filename, BorderLayout.PAGE_START);
	
	JButton delete = new JButton("DELETE");
	delete.addActionListener(new Listeners.Delete(gui));
	this.add(delete, BorderLayout.LINE_END);
	
	JButton loadAll = new JButton("LOAD ALL");
	loadAll.addActionListener(new Listeners.LoadAll(gui));
	this.add(loadAll, BorderLayout.LINE_START);
}
 
Example 5
Project: incubator-netbeans   File: InitPanel.java   Source Code and License 6 votes vote down vote up
protected void initComponents() {        
    if (!oPanel.isPrepared()) {
        initComponent = new JLabel(NbBundle.getMessage(InitPanel.class, "LBL_computing")); // NOI18N
        initComponent.setPreferredSize(new Dimension(850, 450));
        // avoid flicking ?
        Color c = UIManager.getColor("Tree.background"); // NOI18N
        if (c == null) {
            //GTK 1.4.2 will return null for Tree.background
            c = Color.WHITE;
        }
        initComponent.setBackground(c);    // NOI18N               
        initComponent.setHorizontalAlignment(SwingConstants.CENTER);
        initComponent.setOpaque(true);
        
        CardLayout card = new CardLayout();
        setLayout(card);            
        add(initComponent, "init");    // NOI18N
        card.show(this, "init"); // NOI18N        
        Utilities.attachInitJob(this, this);
    } else {
        finished();  
    }
}
 
Example 6
Project: QN-ACTR-Release   File: JWatMainPanel.java   Source Code and License 6 votes vote down vote up
/**
 * Helper method used to create a button inside a JPanel
 * @param action action associated to that button
 * @return created component
 */
private JComponent createButton(AbstractAction action) {
	JPanel panel = new JPanel(); // Use gridbag as centers by default
	JButton button = new JButton(action);
	button.setHorizontalTextPosition(SwingConstants.CENTER);
	button.setVerticalTextPosition(SwingConstants.BOTTOM);
	button.setPreferredSize(new Dimension((int) (BUTTONSIZE * 3.5), (BUTTONSIZE * 2)));
	button.addMouseListener(rollover);
	//if (action == buttonAction[4]) {
	//	button.setVisible(false);
	//}
	//if (action == buttonAction[0]) {
	//	button.setEnabled(false);
	//}
	//if(action == buttonAction[2]) button.setEnabled(false);
	//if(action == buttonAction[4]) button.setEnabled(false);
	panel.add(button);
	return panel;
}
 
Example 7
Project: incubator-netbeans   File: ViewHierarchyRandomTesting.java   Source Code and License 6 votes vote down vote up
public static void testFixedScenarios(RandomTestContainer container) throws Exception {
        // Fixed scenario - last undo throwed exc.
        RandomTestContainer.Context gContext = container.context();
        JEditorPane pane = EditorPaneTesting.getEditorPane(container);
        // Insert initial text into doc
//        DocumentTesting.insert(container.context(), 0, "abc\ndef\n\nghi");
        DocumentTesting.insert(gContext, 0, "\n\n\n\n\n");
        DocumentTesting.remove(gContext, 0, DocumentTesting.getDocument(gContext).getLength());

        // Check for an error caused by delete a line-2-begining and insert at line-1-end and two undos
        DocumentTesting.insert(gContext, 0, "a\nb\n\n");
        EditorPaneTesting.setCaretOffset(gContext, 2);
        EditorPaneTesting.performAction(gContext, pane, DefaultEditorKit.deleteNextCharAction);
        EditorPaneTesting.moveOrSelect(gContext, SwingConstants.WEST, false); // Should go to end of first line
        EditorPaneTesting.typeChar(gContext, 'c');
        DocumentTesting.undo(gContext, 1);
        DocumentTesting.undo(gContext, 1); // This throwed ISE for plain text mime type
    }
 
Example 8
Project: QN-ACTR-Release   File: NumberOfCustomersPanel.java   Source Code and License 6 votes vote down vote up
/**
 * The original getCellRenderer method is overwritten, since the table
 * displays in red the values of the selected class
 * @param row the row of the cell
 * @param column the column of the cell
 * @return a the TableCellRenderer for the requested cell (row,column)
 */
@Override
public TableCellRenderer getCellRenderer(int row, int column) {
	dtcr.setHorizontalAlignment(SwingConstants.CENTER);
	Component c;
	if (column < cd.getClosedClassKeys().size()) {
		Vector closedClasses = cd.getClosedClassKeys();
		Object thisClass = closedClasses.get(column);
		int thisPop = cd.getClassPopulation(thisClass).intValue();
		c = dtcr.getTableCellRendererComponent(this, Integer.toString(thisPop), false, false, row, column);
		if (NCPA.isSingleClass()) {
			if (thisClass == NCPA.getReferenceClass()) {
				c.setForeground(Color.RED);
			} else {
				c.setForeground(Color.BLACK);
			}
		} else {
			c.setForeground(Color.RED);
		}
	} else {
		c = dtcr.getTableCellRendererComponent(this, "-", false, false, row, column);
		c.setForeground(Color.BLACK);
	}
	((JLabel) c).setToolTipText(cd.getClassName(cd.getClosedClassKeys().get(column)));
	return dtcr;
}
 
Example 9
Project: jmt   File: AboutDialogFactory.java   Source Code and License 6 votes vote down vote up
/**
 * @return the logo of the contributor company
 */
public JComponent getLogo() {
	switch (this) {
	case POLIMI:
		JLabel logo = new JLabel(GraphStartScreen.HTML_POLI);
		logo.setHorizontalTextPosition(SwingConstants.TRAILING);
		logo.setVerticalTextPosition(SwingConstants.CENTER);
		logo.setIconTextGap(10);
		logo.setIcon(JMTImageLoader.loadImage("logo", new Dimension(70, 70)));
		return logo;
	case ICL:
		return new JLabel(JMTImageLoader.loadImage("logo_icl", new Dimension(-1,40)));
	default:
		return null;
	}
}
 
Example 10
Project: hearthstone   File: HeroiView.java   Source Code and License 6 votes vote down vote up
private void init() {
    setBackground(new Color(0, 0, 0, 0));
    setOpaque(false);
    JLabel modelo = new JLabel() {
        @Override
        public String toString() {
            return hero.getToString();
        }
    };
    modelo.setBackground(new Color(0, 0, 0, 0));
    modelo.setHorizontalAlignment(SwingConstants.CENTER);
    modelo.setIcon(Images.ARENA_HEROI);
    add(hero.getPanelHeroi(), AbsolutesConstraints.HEROI_PANEL_IMAGEM, 0);
    add(modelo, AbsolutesConstraints.ZERO, 0);
    add(hero.getPanelAtaque(), AbsolutesConstraints.HEROI_PANEL_ATAQUE, 0);
    add(hero.getPanelEscudo(), AbsolutesConstraints.HEROI_PANEL_SHIELD, 0);
    add(hero.getPanelVida(), AbsolutesConstraints.HEROI_PANEL_VIDA, 0);
    add(hero.getPanelPoder(), AbsolutesConstraints.HEROI_PANEL_PODER, 0);
    add(hero.getPanelArma(), AbsolutesConstraints.HEROI_PANEL_ARMA, 0);
    add(hero.getPanelSegredo(), AbsolutesConstraints.HEROI_PANEL_SEGREDO, 0);
    add(hero.getPanelDanoMagico(), AbsolutesConstraints.HEROI_PANEL_DANO_MAGICO, 0);
}
 
Example 11
Project: incubator-netbeans   File: EffectivePomMD.java   Source Code and License 6 votes vote down vote up
@Override
public void propertyChange(PropertyChangeEvent evt) {
    if (NbMavenProject.PROP_PROJECT.equals(evt.getPropertyName())) {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                if (panel != null && panel.isVisible()) {
                    panel.add(new JLabel(LBL_loading_Eff(), SwingConstants.CENTER), BorderLayout.CENTER);

                    task.schedule(0);
                } else {
                    firstTimeShown = true;
                }
            }
        });
    }
}
 
Example 12
Project: jmt   File: SolutionPanel.java   Source Code and License 6 votes vote down vote up
/**
 * Set up the panel contents and layout
 */
protected void initComponents() {
	table = new ResultsTable(getTableModel(), help);
               table.setRowHeight(CommonConstants.ROW_HEIGHT);
	statusLabel.setForeground(Color.RED);
	statusLabel.setFont(new Font("Arial", Font.BOLD, 14));
	statusLabel.setText("WARNING: parameters have been changed since this solution was computed!");
	statusLabel.setHorizontalAlignment(SwingConstants.CENTER);
	help.addHelp(statusLabel, "This solution is not current with the parameters of the model. Click solve to compute a new solution.");

	JPanel intPanel = new JPanel(new BorderLayout(10, 10));

	JScrollPane jsp = new JScrollPane(table, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
	JLabel descrLabel = new JLabel(getDescriptionMessage());
               
	intPanel.add(descrLabel, BorderLayout.NORTH);
	intPanel.add(jsp, BorderLayout.CENTER);

	setLayout(new BorderLayout());
	add(intPanel, BorderLayout.CENTER);
	setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));

}
 
Example 13
Project: rapidminer   File: CompositeButtonPainter.java   Source Code and License 6 votes vote down vote up
/**
 * Draws the component border.
 *
 * @param graphics
 *            the graphics context
 */
void paintBorder(Graphics graphics) {
	Graphics2D g = (Graphics2D) graphics.create();
	g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

	g.setColor(Colors.BUTTON_BORDER);

	int radius = RapidLookAndFeel.CORNER_DEFAULT_RADIUS;
	switch (position) {
		case SwingConstants.LEFT:
			g.drawRoundRect(0, 0, button.getWidth() + radius, button.getHeight() - 1, radius, radius);
			break;
		case SwingConstants.CENTER:
			g.drawRect(0, 0, button.getWidth() + radius, button.getHeight() - 1);
			break;
		default:
			g.drawRoundRect(-radius, 0, button.getWidth() + radius - 1, button.getHeight() - 1, radius, radius);
			g.drawLine(0, 0, 0, button.getHeight());
			break;
	}
}
 
Example 14
Project: QN-ACTR-Release   File: ExactTable.java   Source Code and License 6 votes vote down vote up
private void installLabels(JScrollPane scrollPane) {
	moreColumnsLabel.setIcon(JMTImageLoader.loadImage("table_rightarrow"));
	moreColumnsLabel.setHorizontalAlignment(SwingConstants.CENTER);
	moreColumnsLabel.setToolTipText(moreColumnsTooltip);
	moreColumnsLabel.setVisible(false);

	moreRowsLabel.setIcon(JMTImageLoader.loadImage("table_downarrow"));
	moreRowsLabel.setHorizontalAlignment(SwingConstants.CENTER);
	moreRowsLabel.setToolTipText(moreRowsTooltip);
	moreRowsLabel.setVisible(false);

	scrollPane.setCorner(ScrollPaneConstants.UPPER_RIGHT_CORNER, moreColumnsLabel);
	scrollPane.setCorner(ScrollPaneConstants.LOWER_LEFT_CORNER, moreRowsLabel);

	if (displaysScrollLabels) {
		updateScrollLabels();
	}

}
 
Example 15
Project: Hotel-Properties-Management-System   File: InformationFrame.java   Source Code and License 6 votes vote down vote up
public InformationFrame() {
	
	setType(Type.POPUP);
	setResizable(false);
	
	setModalExclusionType(ModalExclusionType.APPLICATION_EXCLUDE);
	this.setTitle("Approving question");
	this.setPreferredSize(new Dimension(350, 170));
	this.setAlwaysOnTop(isAlwaysOnTopSupported());
	this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	getContentPane().setLayout(new BorderLayout());
	
	final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
	
	this.setLocation(screenSize.width / 2 - 150, screenSize.height / 2 - 75);
	
	this.setIconImage(Toolkit.getDefaultToolkit().getImage(InformationFrame.class.getResource(LOGOPATH)));
	
	final JPanel panel = new JPanel();
	getContentPane().add(panel, BorderLayout.CENTER);
	panel.setLayout(null);
	
	okBtn = new JButton("OK");
	okBtn.setIcon(new ImageIcon(InformationFrame.class.getResource("/com/coder/hms/icons/info_ok.png")));
	okBtn.setFont(new Font("Lucida Grande", Font.PLAIN, 15));
	okBtn.setBorder(new SoftBevelBorder(BevelBorder.RAISED, null, null, null, null));
	okBtn.setBounds(119, 102, 132, 35);
	okBtn.addActionListener(getAction());
	panel.add(okBtn);
	
	lblMessage = new JLabel("");
	lblMessage.setHorizontalTextPosition(SwingConstants.CENTER);
	lblMessage.setHorizontalAlignment(SwingConstants.LEFT);
	lblMessage.setBounds(87, 21, 246, 74);
	panel.add(lblMessage);
	
	lblIcon = new JLabel("");
	lblIcon.setIcon(new ImageIcon(InformationFrame.class.getResource("/com/coder/hms/icons/dialogPane_question.png")));
	lblIcon.setBounds(6, 36, 69, 70);
	panel.add(lblIcon);
	
	this.pack();
}
 
Example 16
Project: QN-ACTR-Release   File: WarningScrollTable.java   Source Code and License 6 votes vote down vote up
/**
 * Creates the panel to be shown when the table is empty
 * @param msg message to be shown on the panel
 * @return created warning panel
 */
protected JPanel createWarningPanel(String msg) {
	JPanel warning = new JPanel(new GridBagLayout());
	JPanel innerPanel = new JPanel(new BorderLayout());
	// Adds image
	JLabel icon = new JLabel("");
	icon.setIcon(JMTImageLoader.loadImage("Triangle"));
	icon.setHorizontalAlignment(SwingConstants.CENTER);
	icon.setBorder(BorderFactory.createEmptyBorder(BORDERSIZE, BORDERSIZE, BORDERSIZE, BORDERSIZE));
	innerPanel.add(icon, BorderLayout.NORTH);
	// Adds Text Area
	JTextArea text = new JTextArea();
	text.setEditable(false);
	text.setWrapStyleWord(true);
	text.setLineWrap(true);
	text.setText(msg);
	text.setBorder(BorderFactory.createEmptyBorder(BORDERSIZE, BORDERSIZE, BORDERSIZE, BORDERSIZE));
	text.setBackground(icon.getBackground());
	innerPanel.add(text, BorderLayout.CENTER);
	innerPanel.setBorder(BorderFactory.createEtchedBorder());
	innerPanel.setPreferredSize(warningBoxSize);
	warning.add(innerPanel);
	return warning;
}
 
Example 17
Project: cuttlefish   File: ShortestPathDemo.java   Source Code and License 6 votes vote down vote up
/**
 *  
 */
private JPanel setUpControls() {
	JPanel jp = new JPanel();
	jp.setBackground(Color.WHITE);
	jp.setLayout(new BoxLayout(jp, BoxLayout.PAGE_AXIS));
	jp.setBorder(BorderFactory.createLineBorder(Color.black, 3));		
	jp.add(
		new JLabel("Select a pair of vertices for which a shortest path will be displayed"));
	JPanel jp2 = new JPanel();
	jp2.add(new JLabel("vertex from", SwingConstants.LEFT));
	jp2.add(getSelectionBox(true));
	jp2.setBackground(Color.white);
	JPanel jp3 = new JPanel();
	jp3.add(new JLabel("vertex to", SwingConstants.LEFT));
	jp3.add(getSelectionBox(false));
	jp3.setBackground(Color.white);
	jp.add( jp2 );
	jp.add( jp3 );
	return jp;
}
 
Example 18
Project: SE2017-Team2   File: ActionPane.java   Source Code and License 6 votes vote down vote up
/**
 * 
 */
public void updateActionPane() {
	actions.removeAll();
	try {
		posActions = Main.guiControlller.getPossibleActions();
		String actionName;
		int i = 0;
		for (Action<?> posAction : posActions) {
			actionName = posAction.toString();
			JButton b1 = new JButton(actionName);
			b1.setHorizontalAlignment(SwingConstants.LEFT);
			b1.addActionListener(this);
			b1.setActionCommand(Integer.toString(i));
			b1.setMaximumSize(new Dimension(Integer.MAX_VALUE, b1.getMinimumSize().height));
			actions.add(b1);
			i++;
		}
		actions.revalidate();
		actions.repaint();
		this.repaint();


	} catch (Exception e) {
		Main.updateUserMsg(e.getMessage());
	}
}
 
Example 19
Project: java-course   File: Calculator.java   Source Code and License 6 votes vote down vote up
/**
 * Initializes GUI.
 */
private void initGUI() {
    CalcLayout pane = new CalcLayout(5);
    JPanel p = new JPanel(pane);

    display = new JLabel("0", SwingConstants.RIGHT);
    display.setMinimumSize(new Dimension(75, 75));
    display.setVerticalAlignment(SwingConstants.BOTTOM);
    display.setBackground(Color.WHITE);
    display.setOpaque(false);
    display.setFont(new Font(display.getFont().toString(), Font.BOLD, 30));

    p.add(display, new RCPosition(1, 1));

    addNumberButtons(p);
    addOperatorButtons(p);
    addFunctionButtons(p);
    addControlButtons(p);
    getContentPane().add(p);
}
 
Example 20
Project: SER316-Dresden   File: PopupDesktopNotification.java   Source Code and License 5 votes vote down vote up
void jbInit() throws Exception {
  this.setResizable(false);
  this.setIconImage(new ImageIcon(PopupDesktopNotification.class.getResource("/ui/icons/jnotes16.png")).getImage());
  this.getContentPane().setBackground(ColorMap.POPBG);
  border2 = BorderFactory.createEmptyBorder(0,30,0,30);
  border3 = BorderFactory.createCompoundBorder(BorderFactory.createEtchedBorder(Color.white,ColorMap.POPBG),BorderFactory.createEmptyBorder(0,30,0,30));
  border4 = BorderFactory.createEmptyBorder(10,10,0,10);
  panel1.setLayout(borderLayout1);
  panel1.setBackground(ColorMap.POPBG);
  
  jButton1.setText(Local.getString("Ok"));
  jButton1.setBounds(150, 415, 95, 30);
  jButton1.setPreferredSize(new Dimension(95, 30));
  jButton1.setBackground(ColorMap.OKBNBG);
  jButton1.setForeground(ColorMap.OKBNFG);
  jButton1.setDefaultCapable(true);
  jButton1.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(ActionEvent e) {
      jButton1_actionPerformed(e);
    }
  });
  panel1.setBorder(border4);
  panel1.setMinimumSize(new Dimension(300, 200));
  panel1.setPreferredSize(new Dimension(300, 200));
  timeLabel.setFont(new java.awt.Font("Dialog", 0, 20));
  timeLabel.setHorizontalAlignment(SwingConstants.CENTER);
  textLabel.setHorizontalAlignment(SwingConstants.CENTER);
  getContentPane().add(panel1);
  panel1.add(jPanel1,  BorderLayout.SOUTH);
  jPanel1.add(jButton1, null);
  jPanel1.setBackground(ColorMap.POPBG);
  panel1.add(textLabel, BorderLayout.CENTER);
  panel1.add(timeLabel, BorderLayout.NORTH);
  playSoundNotification();
}
 
Example 21
Project: Neukoelln_SER316   File: DailyItemsPanel.java   Source Code and License 5 votes vote down vote up
void currentDateChanged(CalendarDate newdate) {
      Cursor cur = App.getFrame().getCursor();
      App.getFrame().setCursor(waitCursor);
      if (!changedByHistory) {
         History.add(new HistoryItem(newdate, CurrentProject.get()));
}
      if (!dateChangedByCalendar) {
          calendarIgnoreChange = true;
          calendar.set(newdate);
          calendarIgnoreChange = false;
      }

      /*if ((currentNote != null) && !changedByHistory && !addedToHistory)
                          History.add(new HistoryItem(currentNote));*/
currentNoteChanged(currentNote,true);
currentNote = CurrentProject.getNoteList().getNoteForDate(newdate);
	CurrentNote.set(currentNote,true);
currentDate = CurrentDate.get();

      /*addedToHistory = false;
      if (!changedByHistory) {
          if (currentNote != null) {
              History.add(new HistoryItem(currentNote));
              addedToHistory = true;
          }
      }*/

currentDateLabel.setText(newdate.getFullDateString());
      if ((currentNote != null) && (currentNote.isMarked())) {
          currentDateLabel.setIcon(bookmarkIcon);
          currentDateLabel.setHorizontalTextPosition(SwingConstants.LEFT);
      }
      else {
          currentDateLabel.setIcon(null);
      }		

      updateIndicators(newdate, CurrentProject.getTaskList());
      App.getFrame().setCursor(cur);
  }
 
Example 22
Project: JuggleMasterPro   File: ExtendedTableCellRenderer.java   Source Code and License 5 votes vote down vote up
public ExtendedTableCellRenderer(Color objPforegroundColor, Color objPbackgroundColor) {
	this.setHorizontalAlignment(SwingConstants.CENTER);
	this.setVerticalAlignment(SwingConstants.CENTER);
	this.setFont(new Font("Courier", Font.PLAIN, 10));
	this.setForeground(objPforegroundColor);
	this.setBackground(objPbackgroundColor);
}
 
Example 23
Project: bbm487s2017g1   File: LibrarianAllUsers.java   Source Code and License 5 votes vote down vote up
/**
 * Initialize the contents of the frame.
 */
private void initialize() {
    frame = new JFrame("Library Book Loan System - All Users");
    frame.setResizable(false);
    frame.setBounds(100, 100, 588, 400);
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    
    JPanel panel = new JPanel();
    frame.getContentPane().add(panel, BorderLayout.CENTER);
    panel.setLayout(null);
    
    JLabel lblAllBooks = new JLabel("All Users");
    lblAllBooks.setHorizontalAlignment(SwingConstants.CENTER);
    lblAllBooks.setFont(new Font("Segoe UI Light", Font.PLAIN, 14));
    lblAllBooks.setBounds(10, 40, 564, 22);
    panel.add(lblAllBooks);
    
    JLabel label_1 = new JLabel("Library Book Loan System");
    label_1.setHorizontalAlignment(SwingConstants.CENTER);
    label_1.setFont(new Font("Segoe UI Light", Font.PLAIN, 18));
    label_1.setBounds(10, 11, 564, 25);
    panel.add(label_1);
    
    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setBounds(10, 73, 564, 257);
    panel.add(scrollPane);
    
    Object columnNames[] = { "Username", "Email", "User Role"};
    DefaultTableModel model = new DefaultTableModel(1, columnNames.length);
    model.setColumnIdentifiers(columnNames);

    table = new JTable(model) {
        @Override
        public boolean isCellEditable(int row, int column) {
            return false;
        }
    };

    scrollPane.setViewportView(table);

    List<User> userList = UserController.getInstance().getAllUsers();

    ((DefaultTableModel) table.getModel()).removeRow(0);

    for (User user : userList) {
        ((DefaultTableModel) table.getModel()).addRow(
                new Object[]{user.getUsername(), user.getEmail(), user.getRole().toString()});
    }
    
    JLabel lblBooks = new JLabel(userList.size() + " User(s)");
    lblBooks.setBounds(528, 336, 46, 14);
    panel.add(lblBooks);
}
 
Example 24
Project: ramus   File: TableRowHeader.java   Source Code and License 5 votes vote down vote up
private int preferredHeaderWidth() {
    final JLabel longestRowLabel = new JLabel("1.1.1");
    final JTableHeader header = table.getTableHeader();
    longestRowLabel.setBorder(header.getBorder());
    longestRowLabel.setHorizontalAlignment(SwingConstants.CENTER);
    longestRowLabel.setFont(header.getFont());
    return longestRowLabel.getPreferredSize().width;
}
 
Example 25
Project: incubator-netbeans   File: ShowNextTime.java   Source Code and License 5 votes vote down vote up
/** Creates a new instance of RecentProjects */
public ShowNextTime() {
    super( new BorderLayout() );
    setOpaque(false);

    button = new JCheckBox( BundleSupport.getLabel( "ShowOnStartup" ) ); // NOI18N
    button.setSelected( WelcomeOptions.getDefault().isShowOnStartup() );
    button.setOpaque( false );
    button.setForeground( Color.white );
    button.setHorizontalTextPosition( SwingConstants.LEFT );
    BundleSupport.setAccessibilityProperties( button, "ShowOnStartup" ); //NOI18N
    add( button, BorderLayout.CENTER );
    button.addActionListener( this );
}
 
Example 26
Project: freecol   File: CompactLabourReport.java   Source Code and License 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 27
Project: hearthstone   File: Escudo.java   Source Code and License 5 votes vote down vote up
private void init(){
    setOpaque(false);
    shield = new JLabelAtributos(heroi, JLabelAtributos.SHIELD);
    background = new JLabel(Images.HEROI_ESCUDO, SwingConstants.CENTER);
    add(shield, AbsolutesConstraints.HEROI_LABEL_ESCUDO);
    add(background, new AbsoluteConstraints(0, 0, 70, 70));
    setVisible(heroi.getShield() > 0);
    
}
 
Example 28
Project: jmt   File: ExactTable.java   Source Code and License 5 votes vote down vote up
/**
 * Try to keep the viewport aligned on column boundaries in the direction of interest
 */
@Override
public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction) {
	if (orientation == SwingConstants.HORIZONTAL) {
		return 80;
	}
	return getRowHeight();
}
 
Example 29
Project: incubator-netbeans   File: ScrollableJPanel.java   Source Code and License 5 votes vote down vote up
@Override
public int getScrollableBlockIncrement(
        Rectangle visible, int orientation, int direction) {
    switch (orientation) {
        case SwingConstants.HORIZONTAL:
            return visible.width * 100 / 100;
        case SwingConstants.VERTICAL:
            return visible.height * 100 / 100;
        default:
            throw new IllegalArgumentException("Invalid orientation: " + orientation); //NOI18N
    }
}
 
Example 30
Project: Equella   File: NoTopicEditor.java   Source Code and License 5 votes vote down vote up
public NoTopicEditor(String message)
{
	JLabel messageLabel = new JLabel(CurrentLocale.get(getKey("notopic.") + message));
	messageLabel.setHorizontalAlignment(SwingConstants.CENTER);

	setLayout(new GridLayout(1, 1));
	add(messageLabel);
}
 
Example 31
Project: geomapapp   File: XMap.java   Source Code and License 5 votes vote down vote up
public int getScrollableUnitIncrement(Rectangle visibleRect,
			int orientation, int direction) {
	if( orientation == SwingConstants.VERTICAL) return 10;
	int newX = visibleRect.x + (direction>0 ? 10 : -10);
	if( wrap>0. ) {
		int dx = (int) (wrap*zoom);
		int test = getPreferredSize().width - visibleRect.width;
		while( newX<0 ) newX += dx;
		while( newX>test ) newX -= dx;
	}
	return (direction>0) ? (newX-visibleRect.x) : -(newX-visibleRect.x);
}
 
Example 32
Project: incubator-netbeans   File: CloneableEditorInitializer.java   Source Code and License 5 votes vote down vote up
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 33
Project: Reinickendorf_SER316   File: DailyItemsPanel.java   Source Code and License 5 votes vote down vote up
void currentDateChanged(CalendarDate newdate) {
      Cursor cur = App.getFrame().getCursor();
      App.getFrame().setCursor(waitCursor);
      if (!changedByHistory) {
         History.add(new HistoryItem(newdate, CurrentProject.get()));
}
      if (!dateChangedByCalendar) {
          calendarIgnoreChange = true;
          calendar.set(newdate);
          calendarIgnoreChange = false;
      }

      /*if ((currentNote != null) && !changedByHistory && !addedToHistory)
                          History.add(new HistoryItem(currentNote));*/
currentNoteChanged(currentNote,true);
currentNote = CurrentProject.getNoteList().getNoteForDate(newdate);
	CurrentNote.set(currentNote,true);
currentDate = CurrentDate.get();

      /*addedToHistory = false;
      if (!changedByHistory) {
          if (currentNote != null) {
              History.add(new HistoryItem(currentNote));
              addedToHistory = true;
          }
      }*/

currentDateLabel.setText(newdate.getFullDateString());
updateFullDateFormat();//Test
      if ((currentNote != null) && (currentNote.isMarked())) {
          currentDateLabel.setIcon(bookmarkIcon);
          currentDateLabel.setHorizontalTextPosition(SwingConstants.LEFT);
      }
      else {
          currentDateLabel.setIcon(null);
      }		

      updateIndicators(newdate, CurrentProject.getTaskList());
      App.getFrame().setCursor(cur);
  }
 
Example 34
Project: javase   File: JProgressDemo.java   Source Code and License 5 votes vote down vote up
public JProgressDemo() {
	frame = new JFrame("install");
	frame.setLayout(new BorderLayout());
	label = new JLabel("progress",SwingConstants.CENTER);
	progressbar = new JProgressBar();
	progressbar.setOrientation(JProgressBar.HORIZONTAL);
	progressbar.setMinimum(0);
	progressbar.setMaximum(100);
	progressbar.setValue(0);
	//progressbar.setStringPainted(true);
	progressbar.addChangeListener(this);
	progressbar.setPreferredSize(new Dimension(300, 10));
	progressbar.setBorderPainted(false);
	progressbar.setBackground(Color.pink);
	JPanel progressPane = new JPanel();
	progressPane.add(progressbar);
	progressPane.setPreferredSize(new Dimension(300, 10));
	JPanel panel = new JPanel();
	b = new JButton("install");
	stop = new JButton("pause");
	b.setForeground(Color.blue);
	b.addActionListener(this);
	stop.addActionListener(this);
	panel.add(b);
	panel.add(stop);
	// timer=new Timer(100,this);
	timer = new Timer(1000/10, this);
	frame.add(panel, BorderLayout.NORTH);
	frame.add(progressPane, BorderLayout.CENTER);
	frame.add(label, BorderLayout.SOUTH);
	// frame.pack();
	frame.setBounds(100, 100, 400, 130);
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	frame.setVisible(true);
}
 
Example 35
Project: SER316-Ingolstadt   File: DailyItemsPanel.java   Source Code and License 5 votes vote down vote up
void currentDateChanged(CalendarDate newdate) {
      Cursor cur = App.getFrame().getCursor();
      App.getFrame().setCursor(waitCursor);
      if (!changedByHistory) {
         History.add(new HistoryItem(newdate, CurrentProject.get()));
}
      if (!dateChangedByCalendar) {
          calendarIgnoreChange = true;
          calendar.set(newdate);
          calendarIgnoreChange = false;
      }

      /*if ((currentNote != null) && !changedByHistory && !addedToHistory)
                          History.add(new HistoryItem(currentNote));*/
currentNoteChanged(currentNote,true);
currentNote = CurrentProject.getNoteList().getNoteForDate(newdate);
	CurrentNote.set(currentNote,true);
currentDate = CurrentDate.get();

      /*addedToHistory = false;
      if (!changedByHistory) {
          if (currentNote != null) {
              History.add(new HistoryItem(currentNote));
              addedToHistory = true;
          }
      }*/

currentDateLabel.setText(newdate.getFullDateString());
      if ((currentNote != null) && (currentNote.isMarked())) {
          currentDateLabel.setIcon(bookmarkIcon);
          currentDateLabel.setHorizontalTextPosition(SwingConstants.LEFT);
      }
      else {
          currentDateLabel.setIcon(null);
      }		

      updateIndicators(newdate, CurrentProject.getTaskList());
      App.getFrame().setCursor(cur);
  }
 
Example 36
Project: incubator-netbeans   File: AxisComponent.java   Source Code and License 5 votes vote down vote up
protected void paintHorizontalBasis(Graphics g, Rectangle clip, Rectangle chartMask) {
    Rectangle dirty = clip.intersection(chartMask);
    g.setColor(getForeground());
    if (location == SwingConstants.NORTH) {
        g.drawLine(dirty.x - 1, getHeight() - 1, dirty.x + dirty.width, getHeight() - 1);
    } else {
        g.drawLine(dirty.x, 0, dirty.x + dirty.width, 0);
    }
}
 
Example 37
Project: incubator-netbeans   File: AxisComponent.java   Source Code and License 5 votes vote down vote up
protected void paintHorizontalTick(Graphics g, AxisMark mark, int x,
                                   Rectangle clip, Rectangle chartMask) {
    g.setColor(getForeground());
    if (location == SwingConstants.NORTH) {
        g.drawLine(x, getHeight() - 2 - getAxisBasisExtent(), x, getHeight() - 2);
    } else {
        g.drawLine(x, 1, x, 1 + getAxisBasisExtent());
    }
}
 
Example 38
Project: incubator-netbeans   File: AxisComponent.java   Source Code and License 5 votes vote down vote up
protected void paintVerticalBasis(Graphics g, Rectangle clip, Rectangle chartMask) {
    g.setColor(getForeground());
    if (location == SwingConstants.WEST) {
        g.drawLine(getWidth() - 1, chartMask.y - 1, getWidth() - 1, chartMask.y + chartMask.height);
    } else {
        g.drawLine(0, chartMask.y, 0, chartMask.y + chartMask.height);
    }
}
 
Example 39
Project: apcs_final   File: NewGamePanel.java   Source Code and License 5 votes vote down vote up
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 40
Project: incubator-netbeans   File: CrossBorderLayout.java   Source Code and License 5 votes vote down vote up
public Component getLayoutComponent(int constraint) {
    if (constraint == SwingConstants.NORTH) return north;
    if (constraint == SwingConstants.WEST) return west;
    if (constraint == SwingConstants.SOUTH) return south;
    if (constraint == SwingConstants.EAST) return east;
    if (constraint == SwingConstants.CENTER) return center;
    throw new IllegalArgumentException("Illegal constraint: " + // NOI18N
            constraintName(constraint));
}