java.awt.Label Java Examples
The following examples show how to use
java.awt.Label.
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: WPrinterJob.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
private void init(Component parent, String title, String message, String buttonText) { Panel p = new Panel(); add("Center", new Label(message)); Button btn = new Button(buttonText); btn.addActionListener(this); p.add(btn); add("South", p); pack(); Dimension dDim = getSize(); if (parent != null) { Rectangle fRect = parent.getBounds(); setLocation(fRect.x + ((fRect.width - dDim.width) / 2), fRect.y + ((fRect.height - dDim.height) / 2)); } }
Example #2
Source File: MultiResolutionCursorTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public void start() { //Get things going. Request focus, set size, et cetera setSize(200, 200); setVisible(true); validate(); final Image image = new BaseMultiResolutionImage( createResolutionVariant(0), createResolutionVariant(1), createResolutionVariant(2), createResolutionVariant(3) ); int center = sizes[0] / 2; Cursor cursor = Toolkit.getDefaultToolkit().createCustomCursor( image, new Point(center, center), "multi-resolution cursor"); Frame frame = new Frame("Test Frame"); frame.setSize(300, 300); frame.setLocation(300, 50); frame.add(new Label("Move cursor here")); frame.setCursor(cursor); frame.setVisible(true); }
Example #3
Source File: WPrinterJob.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
private void init(Component parent, String title, String message, String buttonText) { Panel p = new Panel(); add("Center", new Label(message)); Button btn = new Button(buttonText); btn.addActionListener(this); p.add(btn); add("South", p); pack(); Dimension dDim = getSize(); if (parent != null) { Rectangle fRect = parent.getBounds(); setLocation(fRect.x + ((fRect.width - dDim.width) / 2), fRect.y + ((fRect.height - dDim.height) / 2)); } }
Example #4
Source File: WPrinterJob.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
private void init(Component parent, String title, String message, String buttonText) { Panel p = new Panel(); add("Center", new Label(message)); Button btn = new Button(buttonText); btn.addActionListener(this); p.add(btn); add("South", p); pack(); Dimension dDim = getSize(); if (parent != null) { Rectangle fRect = parent.getBounds(); setLocation(fRect.x + ((fRect.width - dDim.width) / 2), fRect.y + ((fRect.height - dDim.height) / 2)); } }
Example #5
Source File: FeatureOverviewWindow.java From mzmine2 with GNU General Public License v2.0 | 6 votes |
private JPanel addFeatureDataSummary(PeakListRow row) { JPanel featureDataSummary = new JPanel(new GridLayout(0, 1)); featureDataSummary.setBackground(Color.WHITE); featureDataSummary.add(new Label("Feature: " + row.getID())); if (row.getPreferredPeakIdentity() != null) featureDataSummary.add(new Label("Identity: " + row.getPreferredPeakIdentity().getName())); if (row.getComment() != null) featureDataSummary.add(new Label("Comment: " + row.getComment())); featureDataSummary.add(new Label("Raw File: " + rawFiles[0].getName())); featureDataSummary.add(new Label("Intensity: " + MZmineCore.getConfiguration().getIntensityFormat().format(feature.getHeight()))); featureDataSummary.add(new Label( "Area: " + MZmineCore.getConfiguration().getIntensityFormat().format(feature.getArea()))); featureDataSummary.add(new Label("Charge: " + feature.getCharge())); featureDataSummary.add( new Label("m/z: " + MZmineCore.getConfiguration().getMZFormat().format(feature.getMZ()))); featureDataSummary.add(new Label( "Retention time: " + MZmineCore.getConfiguration().getRTFormat().format(feature.getRT()))); featureDataSummary.add(new Label("Asymmetry factor " + MZmineCore.getConfiguration().getRTFormat().format(feature.getAsymmetryFactor()))); featureDataSummary.add(new Label("Tailing Factor factor " + MZmineCore.getConfiguration().getRTFormat().format(feature.getTailingFactor()))); featureDataSummary.add(new Label("Status: " + feature.getFeatureStatus())); return featureDataSummary; }
Example #6
Source File: WPrinterJob.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
private void init(Component parent, String title, String message, String buttonText) { Panel p = new Panel(); add("Center", new Label(message)); Button btn = new Button(buttonText); btn.addActionListener(this); p.add(btn); add("South", p); pack(); Dimension dDim = getSize(); if (parent != null) { Rectangle fRect = parent.getBounds(); setLocation(fRect.x + ((fRect.width - dDim.width) / 2), fRect.y + ((fRect.height - dDim.height) / 2)); } }
Example #7
Source File: WPrinterJob.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
private void init(Component parent, String title, String message, String buttonText) { Panel p = new Panel(); add("Center", new Label(message)); Button btn = new Button(buttonText); btn.addActionListener(this); p.add(btn); add("South", p); pack(); Dimension dDim = getSize(); if (parent != null) { Rectangle fRect = parent.getBounds(); setLocation(fRect.x + ((fRect.width - dDim.width) / 2), fRect.y + ((fRect.height - dDim.height) / 2)); } }
Example #8
Source File: MultiResolutionCursorTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
public void start() { //Get things going. Request focus, set size, et cetera setSize(200, 200); setVisible(true); validate(); final Image image = new MultiResolutionCursor(); int center = sizes[0] / 2; Cursor cursor = Toolkit.getDefaultToolkit().createCustomCursor( image, new Point(center, center), "multi-resolution cursor"); Frame frame = new Frame("Test Frame"); frame.setSize(300, 300); frame.setLocation(300, 50); frame.add(new Label("Move cursor here")); frame.setCursor(cursor); frame.setVisible(true); }
Example #9
Source File: WPrinterJob.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
private void init(Component parent, String title, String message, String buttonText) { Panel p = new Panel(); add("Center", new Label(message)); Button btn = new Button(buttonText); btn.addActionListener(this); p.add(btn); add("South", p); pack(); Dimension dDim = getSize(); if (parent != null) { Rectangle fRect = parent.getBounds(); setLocation(fRect.x + ((fRect.width - dDim.width) / 2), fRect.y + ((fRect.height - dDim.height) / 2)); } }
Example #10
Source File: DBLoader.java From TrakEM2 with GNU General Public License v3.0 | 6 votes |
private void makeWindow() { dialog = new java.awt.Dialog(IJ.getInstance(), "Loading...", false); dialog.setUndecorated(true); bytes = new Label("Loaded: 0 bytes "); speed = new Label("Speed: 0 bytes/s "); time = new Label ("Elapsed time: 0 s "); dialog.setLayout(new GridLayout(3,1)); dialog.addWindowListener(new java.awt.event.WindowAdapter() { public void windowDeactivated(java.awt.event.WindowEvent we) { dialog.toFront(); } }); dialog.add(time); dialog.add(bytes); dialog.add(speed); java.awt.Dimension screen = dialog.getToolkit().getScreenSize(); dialog.pack(); dialog.setLocation(screen.width/2 - dialog.getWidth()/2, screen.height/2 - dialog.getHeight()/2); //dialog.setVisible(true); }
Example #11
Source File: MultiResolutionCursorTest.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public void start() { //Get things going. Request focus, set size, et cetera setSize(200, 200); setVisible(true); validate(); final Image image = new MultiResolutionCursor(); int center = sizes[0] / 2; Cursor cursor = Toolkit.getDefaultToolkit().createCustomCursor( image, new Point(center, center), "multi-resolution cursor"); Frame frame = new Frame("Test Frame"); frame.setSize(300, 300); frame.setLocation(300, 50); frame.add(new Label("Move cursor here")); frame.setCursor(cursor); frame.setVisible(true); }
Example #12
Source File: MultiResolutionCursorTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public void start() { //Get things going. Request focus, set size, et cetera setSize(200, 200); setVisible(true); validate(); final Image image = new MultiResolutionCursor(); int center = sizes[0] / 2; Cursor cursor = Toolkit.getDefaultToolkit().createCustomCursor( image, new Point(center, center), "multi-resolution cursor"); Frame frame = new Frame("Test Frame"); frame.setSize(300, 300); frame.setLocation(300, 50); frame.add(new Label("Move cursor here")); frame.setCursor(cursor); frame.setVisible(true); }
Example #13
Source File: MultiResolutionCursorTest.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
public void start() { //Get things going. Request focus, set size, et cetera setSize(200, 200); setVisible(true); validate(); final Image image = new MultiResolutionCursor(); int center = sizes[0] / 2; Cursor cursor = Toolkit.getDefaultToolkit().createCustomCursor( image, new Point(center, center), "multi-resolution cursor"); Frame frame = new Frame("Test Frame"); frame.setSize(300, 300); frame.setLocation(300, 50); frame.add(new Label("Move cursor here")); frame.setCursor(cursor); frame.setVisible(true); }
Example #14
Source File: Block.java From JavaGame with MIT License | 6 votes |
/** * ������ * * @param g */ public void drawContent(Graphics g) { this.value = (int) Math.pow(2, level) + ""; g.setColor(Constant.COLOR_BLOCKS_ACTIVE[level - 1]); Font f = new Font("���ź�", Font.BOLD, 60 - 5 * value.length()); g.setFont(f); FontMetrics fm = new Label().getFontMetrics(f); int xValueStart = x + (Constant.BLOCK_WIDTH - fm.stringWidth(value)) / 2; int yValueStart = y+Constant.BLOCK_HEIGHT- (Constant.BLOCK_HEIGHT - fm.getHeight()) / 2-fm.getDescent(); // ������ g.fillRoundRect(x, y, Constant.BLOCK_WIDTH, Constant.BLOCK_WIDTH, 10, 10); g.setColor(Color.BLACK); // ������ g.drawString(value, xValueStart, yValueStart); // //���Լ�¼ // f = new Font("���ź�", Font.BOLD, 20); // g.setFont(f); // String s = "(" + x + "," + y + ")" + moveCount; // g.drawString(s, x, y + 20); }
Example #15
Source File: LoginRequester.java From pdfxtk with Apache License 2.0 | 5 votes |
public LoginRequester(Frame parent, String title, String user_label, String password_label, String posText_, String negText) { super(parent, title, true); setLayout(new GridBagLayout()); posText = posText_; add(new Label(user_label), Awt.constraints(false, GridBagConstraints.HORIZONTAL)); u_text = new TextField(30); try{u_text.setText(System.getProperty("user.name",""));} catch(Exception e) {} add(u_text, Awt.constraints(true, GridBagConstraints.HORIZONTAL)); add(new Label(password_label), Awt.constraints(false, GridBagConstraints.HORIZONTAL)); p_text = new TextField(30); p_text.setEchoChar('*'); add(p_text, Awt.constraints(true, GridBagConstraints.HORIZONTAL)); Button pos = new Button(posText); add(pos, Awt.constraints(false, 10, 4, GridBagConstraints.HORIZONTAL)); pos.addActionListener(this); Button neg = new Button(negText); add(neg, Awt.constraints(true, 10, 4, GridBagConstraints.HORIZONTAL)); neg.addActionListener(this); pack(); }
Example #16
Source File: ChildWindowProperties.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public void testChildPropertiesWithDialogAsParent() { parentDialog = new Dialog((Dialog) null, "parent Dialog"); parentDialog.setSize(WIDTH, HEIGHT); parentDialog.setLocation(100, 100); parentDialog.setBackground(Color.RED); parentLabel = new Label("ParentForegroundAndFont"); parentFont = new Font("Courier New", Font.ITALIC, 15); parentDialog.setForeground(Color.BLUE); parentDialog.setFont(parentFont); parentDialog.add(parentLabel); parentDialog.setVisible(true); windowChild = new Window(parentDialog); windowChild.setSize(WIDTH, HEIGHT); windowChild.setLocation(WIDTH + 200, 100); childLabel = new Label("ChildForegroundAndFont"); windowChild.add(childLabel); windowChild.setVisible(true); if (parentDialog.getBackground() == windowChild.getBackground()) { dispose(); throw new RuntimeException("Child Window Should NOT Inherit " + "Parent Dialog's Background Color"); } if (parentDialog.getForeground() == windowChild.getForeground()) { dispose(); throw new RuntimeException("Child Window Should NOT Inherit " + "Parent Dialog's Foreground Color"); } if (parentDialog.getFont() == windowChild.getFont()) { dispose(); throw new RuntimeException("Child Window Should NOT Inherit " + "Parent Dialog's Font Color"); } }
Example #17
Source File: GIPApplet.java From swift-k with Apache License 2.0 | 5 votes |
public EmailConfirmationDialog(Frame parent, String[] messages, String textArea) { super(parent, true); setTitle("Confirmation Dialog"); Font font = new Font("Courier", Font.PLAIN, 12); setFont(font); int rows = messages.length; Panel textPanel = new Panel(); textPanel.setLayout(new GridLayout(rows,1)); for(int i = 0; i < rows; i++){ textPanel.add(new Label(messages[i])); } add("North", textPanel); Panel textAreaPanel = new Panel(); TextArea ta = new TextArea(12,60); ta.setText(textArea); textAreaPanel.add(ta); add("Center", textAreaPanel); Panel p = new Panel(); p.setLayout(new FlowLayout()); Button yes = new Button("Yes"); yes.addActionListener(this); p.add(yes); Button no = new Button("No"); no.addActionListener(this); p.add(no); add("South", p); setLocation(100, 200); pack(); }
Example #18
Source File: ChildDialogProperties.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public void testChildPropertiesWithFrameAsParent() { parentFrame = new Frame("parent Frame"); parentFrame.setSize(WIDTH, HEIGHT); parentFrame.setLocation(100, 400); parentFrame.setBackground(Color.BLUE); parentLabel = new Label("ParentForegroundAndFont"); parentFont = new Font("Courier New", Font.ITALIC, 15); parentFrame.setForeground(Color.RED); parentFrame.setFont(parentFont); parentFrame.add(parentLabel); parentFrame.setVisible(true); frameChildDialog = new Dialog(parentFrame, "Frame's child"); frameChildDialog.setSize(WIDTH, HEIGHT); frameChildDialog.setLocation(WIDTH + 200, 400); childLabel = new Label("ChildForegroundAndFont"); frameChildDialog.add(childLabel); frameChildDialog.setVisible(true); if (parentFrame.getBackground() == frameChildDialog.getBackground()) { dispose(); throw new RuntimeException("Child Dialog Should NOT Inherit " + "Parent Frame's Background Color"); } if (parentFrame.getForeground() == frameChildDialog.getForeground()) { dispose(); throw new RuntimeException("Child Dialog Should NOT Inherit " + "Parent Frame's Foreground Color"); } if (parentFrame.getFont() == frameChildDialog.getFont()) { dispose(); throw new RuntimeException("Child Dialog Should NOT Inherit " + "Parent Frame's Font Style/Color"); } }
Example #19
Source File: ChildWindowProperties.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public void testChildPropertiesWithFrameAsParent() { parentFrame = new Frame("parent Frame"); parentFrame.setSize(WIDTH, HEIGHT); parentFrame.setLocation(100, 400); parentFrame.setBackground(Color.BLUE); parentLabel = new Label("ParentForegroundAndFont"); parentFont = new Font("Courier New", Font.ITALIC, 15); parentFrame.setForeground(Color.RED); parentFrame.setFont(parentFont); parentFrame.add(parentLabel); parentFrame.setVisible(true); frameChildWindow = new Window(parentFrame); frameChildWindow.setSize(WIDTH, HEIGHT); frameChildWindow.setLocation(WIDTH + 200, 400); childLabel = new Label("ChildForegroundAndFont"); frameChildWindow.add(childLabel); frameChildWindow.setVisible(true); if (parentFrame.getBackground() == frameChildWindow.getBackground()) { dispose(); throw new RuntimeException("Child Window Should NOT Inherit " + "Parent Frame's Background Color"); } if (parentDialog.getForeground() == windowChild.getForeground()) { dispose(); throw new RuntimeException("Child Window Should NOT Inherit " + "Parent Frame's Foreground Color"); } if (parentDialog.getFont() == windowChild.getFont()) { dispose(); throw new RuntimeException("Child Window Should NOT Inherit " + "Parent Frame's Font Color"); } }
Example #20
Source File: DitherTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public DitherControls(DitherTest app, int s, int e, DitherMethod type, boolean vertical) { applet = app; setLayout(dcLayout); add(new Label(vertical ? "Vertical" : "Horizontal")); add(choice = new Choice()); for (DitherMethod m : DitherMethod.values()) { choice.addItem(m.toString().substring(0, 1) + m.toString().substring(1).toLowerCase()); } choice.select(type.ordinal()); add(start = new CardinalTextField(Integer.toString(s), 4)); add(end = new CardinalTextField(Integer.toString(e), 4)); }
Example #21
Source File: LWLabelPeer.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Converts {@code Label} alignment constant to the {@code JLabel} constant. * If wrong Label alignment provided returns default alignment. * * @param alignment {@code Label} constant. * * @return {@code JLabel} constant. */ private static int convertAlignment(final int alignment) { switch (alignment) { case Label.CENTER: return SwingConstants.CENTER; case Label.RIGHT: return SwingConstants.RIGHT; default: return SwingConstants.LEFT; } }
Example #22
Source File: UITools.java From swift-k with Apache License 2.0 | 5 votes |
public static void main(String args[]) { // Create a frame and center it relative to the // screen Frame f = new Frame("This should be centered"); f.add(new Label("Press Ctrl-C from command line to exit")); f.setSize(f.getPreferredSize()); f.pack(); center(null, f); f.show(); }
Example #23
Source File: LWLabelPeer.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * Converts {@code Label} alignment constant to the {@code JLabel} constant. * If wrong Label alignment provided returns default alignment. * * @param alignment {@code Label} constant. * * @return {@code JLabel} constant. */ private static int convertAlignment(final int alignment) { switch (alignment) { case Label.CENTER: return SwingConstants.CENTER; case Label.RIGHT: return SwingConstants.RIGHT; default: return SwingConstants.LEFT; } }
Example #24
Source File: InteractiveDoG.java From SPIM_Registration with GNU General Public License v2.0 | 5 votes |
public Sigma2Listener( final float min, final float max, final int scrollbarSize, final Scrollbar sigmaScrollbar2, final Label sigma2Label ) { this.min = min; this.max = max; this.scrollbarSize = scrollbarSize; this.sigmaScrollbar2 = sigmaScrollbar2; this.sigma2Label = sigma2Label; }
Example #25
Source File: DitherTest.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
public DitherControls(DitherTest app, int s, int e, DitherMethod type, boolean vertical) { applet = app; setLayout(dcLayout); add(new Label(vertical ? "Vertical" : "Horizontal")); add(choice = new Choice()); for (DitherMethod m : DitherMethod.values()) { choice.addItem(m.toString().substring(0, 1) + m.toString().substring(1).toLowerCase()); } choice.select(type.ordinal()); add(start = new CardinalTextField(Integer.toString(s), 4)); add(end = new CardinalTextField(Integer.toString(e), 4)); }
Example #26
Source File: GraphicUtils.java From xyTalk-pc with GNU Affero General Public License v3.0 | 5 votes |
/** * Loading an image via a MediaTracker * * @param image * @throws InterruptedException * @throws IOException */ public static void load(Image image) throws InterruptedException, IOException { MediaTracker tracker = new MediaTracker(new Label()); // any component // will do tracker.addImage(image, 0); tracker.waitForID(0); if (tracker.isErrorID(0)) throw new IOException("error loading image"); }
Example #27
Source File: LabelOperator.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Override public boolean checkComponent(Component comp) { if (comp instanceof Label) { if (((Label) comp).getText() != null) { return (comparator.equals(((Label) comp).getText(), label)); } } return false; }
Example #28
Source File: Sage.java From sagetv with Apache License 2.0 | 5 votes |
static void setSplashText(String x) { Label tempL = splashText; if (tempL != null) tempL.setText(x); if (Sage.DBG) System.out.println("Splash: " + x); SageTV.writeOutWatchdogFile(); }
Example #29
Source File: LWLabelPeer.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Converts {@code Label} alignment constant to the {@code JLabel} constant. * If wrong Label alignment provided returns default alignment. * * @param alignment {@code Label} constant. * * @return {@code JLabel} constant. */ private static int convertAlignment(final int alignment) { switch (alignment) { case Label.CENTER: return SwingConstants.CENTER; case Label.RIGHT: return SwingConstants.RIGHT; default: return SwingConstants.LEFT; } }
Example #30
Source File: AppletGameContainer.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Create a new panel to display the console output * * @param e The exception causing the console to be displayed */ public ConsolePanel(Exception e) { setLayout(new BorderLayout()); setBackground(Color.black); setForeground(Color.white); Font consoleFont = new Font("Arial", Font.BOLD, 14); Label slickLabel = new Label("SLICK CONSOLE", Label.CENTER); slickLabel.setFont(consoleFont); add(slickLabel, BorderLayout.PAGE_START); StringWriter sw = new StringWriter(); e.printStackTrace(new PrintWriter(sw)); textArea.setText(sw.toString()); textArea.setEditable(false); add(textArea, BorderLayout.CENTER); // add a border on both sides of the console add(new Panel(), BorderLayout.LINE_START); add(new Panel(), BorderLayout.LINE_END); Panel bottomPanel = new Panel(); bottomPanel.setLayout(new GridLayout(0, 1)); Label infoLabel1 = new Label("An error occured while running the applet.", Label.CENTER); Label infoLabel2 = new Label("Plese contact support to resolve this issue.", Label.CENTER); infoLabel1.setFont(consoleFont); infoLabel2.setFont(consoleFont); bottomPanel.add(infoLabel1); bottomPanel.add(infoLabel2); add(bottomPanel, BorderLayout.PAGE_END); }