Java Code Examples for javax.swing.JLabel#setPreferredSize()

The following examples show how to use javax.swing.JLabel#setPreferredSize() . 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: EndGameMessagePanel.java    From magarena with GNU General Public License v3.0 6 votes vote down vote up
public EndGameMessagePanel(GameViewerInfo game) {
    setPreferredSize(new Dimension(450, 350));
    setLayout(miglayout);
    //
    setOpaque(true);
    setBorder(BorderFactory.createMatteBorder(8, 8, 8, 8, MagicStyle.getTheme().getColor(Theme.COLOR_TITLE_BACKGROUND)));
    //
    final JLabel iconLabel = new JLabel(game.getWinningPlayer().getPlayerPanelAvatar());
    final Icon winningAvatar = iconLabel.getIcon();
    iconLabel.setPreferredSize(new Dimension(winningAvatar.getIconWidth(), winningAvatar.getIconHeight()));
    add(iconLabel, "alignx center");
    //
    final JLabel winnerLabel = new JLabel(MText.get(_S1, game.getWinningPlayer().getName()));
    winnerLabel.setFont(FontsAndBorders.FONT3);
    winnerLabel.setHorizontalAlignment(SwingConstants.CENTER);
    winnerLabel.setForeground(MagicStyle.getTheme().getColor(Theme.COLOR_TEXT_FOREGROUND));
    add(winnerLabel, "w 100%");
}
 
Example 2
Source File: Test8039464.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private static void init(Container container) {
    container.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.BOTH;
    gbc.gridx = 0;
    gbc.gridy = 1;
    JLabel label = new JLabel();
    Dimension size = new Dimension(111, 0);
    label.setPreferredSize(size);
    label.setMinimumSize(size);
    container.add(label, gbc);
    gbc.gridx = 1;
    gbc.weightx = 1;
    container.add(new JScrollBar(JScrollBar.HORIZONTAL, 1, 111, 1, 1111), gbc);
    gbc.gridx = 2;
    gbc.gridy = 0;
    gbc.weightx = 0;
    gbc.weighty = 1;
    container.add(new JScrollBar(JScrollBar.VERTICAL, 1, 111, 1, 1111), gbc);
}
 
Example 3
Source File: Test8039464.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
private static void init(Container container) {
    container.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.BOTH;
    gbc.gridx = 0;
    gbc.gridy = 1;
    JLabel label = new JLabel();
    Dimension size = new Dimension(111, 0);
    label.setPreferredSize(size);
    label.setMinimumSize(size);
    container.add(label, gbc);
    gbc.gridx = 1;
    gbc.weightx = 1;
    container.add(new JScrollBar(JScrollBar.HORIZONTAL, 1, 111, 1, 1111), gbc);
    gbc.gridx = 2;
    gbc.gridy = 0;
    gbc.weightx = 0;
    gbc.weighty = 1;
    container.add(new JScrollBar(JScrollBar.VERTICAL, 1, 111, 1, 1111), gbc);
}
 
Example 4
Source File: JLabelledValue.java    From mpxj with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Constructor.
 *
 * @param label fixed label text
 */
public JLabelledValue(String label)
{
   FlowLayout flowLayout = (FlowLayout) getLayout();
   flowLayout.setAlignment(FlowLayout.LEFT);
   flowLayout.setVgap(0);
   flowLayout.setHgap(0);
   JLabel textLabel = new JLabel(label);
   textLabel.setFont(new Font("Tahoma", Font.BOLD, 11));
   textLabel.setPreferredSize(new Dimension(70, 14));
   add(textLabel);

   m_valueLabel = new JLabel("");
   m_valueLabel.setPreferredSize(new Dimension(80, 14));
   add(m_valueLabel);
}
 
Example 5
Source File: Test8039464.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private static void init(Container container) {
    container.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.BOTH;
    gbc.gridx = 0;
    gbc.gridy = 1;
    JLabel label = new JLabel();
    Dimension size = new Dimension(111, 0);
    label.setPreferredSize(size);
    label.setMinimumSize(size);
    container.add(label, gbc);
    gbc.gridx = 1;
    gbc.weightx = 1;
    container.add(new JScrollBar(JScrollBar.HORIZONTAL, 1, 111, 1, 1111), gbc);
    gbc.gridx = 2;
    gbc.gridy = 0;
    gbc.weightx = 0;
    gbc.weighty = 1;
    container.add(new JScrollBar(JScrollBar.VERTICAL, 1, 111, 1, 1111), gbc);
}
 
Example 6
Source File: GUIFrame.java    From jaamsim with Apache License 2.0 5 votes vote down vote up
private void addRemainingTime(JToolBar mainToolBar, Insets margin) {
	remainingDisplay = new JLabel( "", JLabel.CENTER );
	remainingDisplay.setPreferredSize( new Dimension( 110, 16 ) );
	remainingDisplay.setForeground( new Color( 1.0f, 0.0f, 0.0f ) );
	remainingDisplay.setToolTipText(formatToolTip("Remaining Time",
			"The remaining time required to complete the present simulation run."));
	mainToolBar.add( remainingDisplay );
}
 
Example 7
Source File: FrameSobre.java    From brModelo with GNU General Public License v3.0 5 votes vote down vote up
void Inicie(ParteAjuda sel) {
        this.setTitle(sel.getTitulo());
        if (sel.getByteImage() != null || sel.getHtml() != null) {//.isEmpty()) {
            Pan.removeAll();
            int H = 0;
            int W = 0;
            if (!sel.getHtml().isEmpty()) {
                JLabel htmLbl = new JLabel();
                htmLbl.setText(sel.getHtml());
                htmLbl.repaint();
                Dimension d = htmLbl.getPreferredSize();
                int x = (getPreferredSize().width - d.width) / 2;
                if (getPreferredSize().width < d.width) {
                    x = 0;
                }
//                int y = (getPreferredSize().height - d.height - subPan.getPreferredSize().height) / 2;
//                if (getPreferredSize().height - subPan.getPreferredSize().height < d.height) {
//                    y = 0;
//                }
                htmLbl.setBounds(x, 0, d.width, d.height);
                //Pan.setBackground(Color.yellow);
                Pan.add(htmLbl);
                H = d.height + 10;
                W = d.width;
            }
            if (sel.getByteImage() != null) {
                ImageIcon img = new ImageIcon(sel.getByteImage());
                JLabel picLabel = new JLabel(img);
                W = W > img.getIconWidth() ? W : img.getIconWidth();
                picLabel.setBounds(0, H, img.getIconWidth(), img.getIconHeight());
                picLabel.setPreferredSize(new Dimension(img.getIconWidth(), img.getIconHeight()));
                H += img.getIconHeight();
                Pan.setPreferredSize(new Dimension(W, H));
                Pan.add(picLabel);
            }
            Pan.revalidate();
            Pan.repaint();
        }
    }
 
Example 8
Source File: AbstractModule.java    From DeconvolutionLab2 with GNU General Public License v3.0 5 votes vote down vote up
public JPanel buildCollapsedPanel() {
	JPanel panel = new JPanel(new BorderLayout());
	lblCommand = new JLabel("");
	lblCommand.setBorder(BorderFactory.createEtchedBorder());
	lblCommand.setHorizontalAlignment(SwingConstants.LEFT);
	lblCommand.setPreferredSize(new Dimension(500, 32));
	panel.add(lblCommand, BorderLayout.NORTH);
	lblCommand.setMinimumSize(new Dimension(500, 36));
	return panel;
}
 
Example 9
Source File: DisplayListenerLeak.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private static void createAndShowGUI() {
    Thread.currentThread().setUncaughtExceptionHandler((t, e) -> {
        e.printStackTrace();
        failed = true;
    });
    frame = new JFrame();
    JLabel emptyLabel = new JLabel("");
    emptyLabel.setPreferredSize(new Dimension(600, 400));
    frame.getContentPane().add(emptyLabel, BorderLayout.CENTER);
    frame.pack();
    frame.setVisible(true);
}
 
Example 10
Source File: GUIOptionClientCertificateDialog.java    From PacketProxy with Apache License 2.0 5 votes vote down vote up
private JComponent label_and_object(String label_name, JComponent object) {
	JPanel panel = new JPanel();
	panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
	JLabel label = new JLabel(label_name);
	label.setPreferredSize(new Dimension(240, label.getMaximumSize().height));
	panel.add(label);
	object.setMaximumSize(new Dimension(Short.MAX_VALUE, label.getMaximumSize().height * 2));
	panel.add(object);
	return panel;
}
 
Example 11
Source File: GUISettings.java    From mvisc with GNU General Public License v3.0 5 votes vote down vote up
public static JLabel getDefaultLabel(String title, int width, int height, int align, int valign)
{
	JLabel label = new JLabel(" " + title + " ", align);
	label.setPreferredSize(new Dimension(width, height));
	label.setVerticalAlignment(valign);
	return label;
}
 
Example 12
Source File: HelpPanel.java    From azure-devops-intellij with MIT License 5 votes vote down vote up
public HelpToolTip(final String wrappingText, final List<HelpPopupCommand> popupCommands, final int preferredWidth) {
    IdeTooltipManager.setColors(this);
    this.setLayout(new GridBagLayout());

    // Unfortunately, we have to calculate the preferredHeight of the wrapping text
    // I am roughly estimating it by getting the font metrics and dividing the full
    // width of the label string by the preferred width passed in.
    // I subtract 20 from the preferred width to help with word wrapping.
    // I add one to the number of lines it gets to provide a blank line before the links
    final JLabel label = new JLabel();
    // We use the HTML tags to get the label to word wrap
    label.setText("<HTML>" + wrappingText + "</HTML>");
    final FontMetrics fm = this.getFontMetrics(label.getFont());
    final int preferredHeight = (int) (fm.getHeight() * (fm.stringWidth(wrappingText) / (double) (preferredWidth - JBUI.scale(20)) + 1));
    label.setPreferredSize(new Dimension(preferredWidth, preferredHeight));
    label.setVerticalAlignment(JLabel.TOP);
    SwingHelper.addToGridBag(this, label, 0, 0);

    int row = 1;
    for (final HelpPopupCommand popupCommand : popupCommands) {
        if (!StringUtils.isEmpty(popupCommand.text)) {
            final Hyperlink hyperlink = new Hyperlink();
            hyperlink.setText(popupCommand.text);
            hyperlink.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(final ActionEvent e) {
                    onPopupCommandEvent(popupCommand.command);
                }
            });
            SwingHelper.addToGridBag(this, hyperlink, 0, row++, 1, 1, JBUI.scale(4), 0);
        }
    }
}
 
Example 13
Source File: GUIOptionServerDialog.java    From PacketProxy with Apache License 2.0 5 votes vote down vote up
private JComponent label_and_object(String label_name, JComponent object) {
	JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
    JLabel label = new JLabel(label_name);
    label.setPreferredSize(new Dimension(150, label.getMaximumSize().height));
    panel.add(label);
    object.setMaximumSize(new Dimension(Short.MAX_VALUE, label.getMaximumSize().height * 2));
    panel.add(object);
	return panel;
}
 
Example 14
Source File: FrameDemo.java    From littleluck with Apache License 2.0 4 votes vote down vote up
private static JFrame createFrame() {

        //<snip>Create frame and set simple properties
        JFrame frame = new JFrame("Demo JFrame");
        frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
        //</snip>

        //<snip>Set Minimized/titlebar icon Image
        //Note: How the image is used is platform-dependent
        Image iconImage = null;
        try {
            // todo: swingingduke.gif doesn't exist 
            URL imageURL = FrameDemo.class.getResource("resources/images/swingingduke.gif");
            iconImage = ImageIO.read(imageURL);
        } catch (Exception e) {
            // handle image IO exception
        }
        frame.setIconImage(iconImage);
        //</snip>

        //<snip>Make toplevel "busy"
        // busy glasspane is initially invisible
        frame.setGlassPane(new BusyGlass());
        //</snip>

        //<snip>Add a menubar
        JMenuBar menubar = new JMenuBar();
        frame.setJMenuBar(menubar);
        JMenu menu = new JMenu("File");
        menubar.add(menu);
        menu.add("Open");
        menu.add("Save");
        //</snip>

        //<snip>Add a horizontal toolbar
        JToolBar toolbar = new JToolBar();
        frame.add(toolbar, BorderLayout.NORTH);
        JButton btn = new JButton("Toolbar Button");
        btn.setContentAreaFilled(false);
        toolbar.add(btn);
        //</snip>

        //<snip>Add the content area
        JLabel label = new JLabel("I'm content but a little blue.");
        label.setHorizontalAlignment(JLabel.CENTER);
        label.setPreferredSize(new Dimension(300, 160));
        label.setBackground(new Color(197, 216, 236));
        label.setOpaque(true); // labels non-opaque by default
        frame.add(label);
        //snip

        //<snip>Add a statusbar
        JLabel statusLabel = new JLabel("I show status.");
        statusLabel.setBorder(new EmptyBorder(4, 4, 4, 4));
        statusLabel.setHorizontalAlignment(JLabel.LEADING);
        frame.add(statusLabel, BorderLayout.SOUTH);
        //</snip>

        //<snip>Initialize frame's size to fit it's content
        frame.pack();
        //</snip>

        return frame;
    }
 
Example 15
Source File: BookPriceIFrame.java    From LibraryManagementSystem with MIT License 4 votes vote down vote up
public BookPriceIFrame() {
	super();
	setIconifiable(true);							// ���ô������С������������
	setClosable(true);								// ���ô���ɹرգ���������
	setTitle("�޸�ͼ��۸�");						// ���ô�����⣭��������
	setBounds(100, 50, 500, 225);

	//������ͷͼƬ
	final JLabel logoLabel = new JLabel();
	ImageIcon userAddIcon=CreateIcon.add("tback.jpg");
	logoLabel.setIcon(userAddIcon);
	logoLabel.setOpaque(true);
	logoLabel.setBackground(Color.white);
	logoLabel.setPreferredSize(new Dimension(400, 60));
	getContentPane().add(logoLabel, BorderLayout.NORTH);

	//����һ�������������
	final JPanel panel = new JPanel();
	panel.setLayout(new FlowLayout());
	getContentPane().add(panel);

	//�������������Ƕ�����1,���ڷ��÷ǰ�ť���
	final JPanel panel_1 = new JPanel();
	final GridLayout gridLayout = new GridLayout(2, 2);
	gridLayout.setVgap(20);
	panel_1.setLayout(gridLayout);
	panel.add(panel_1);

	final JLabel label_2 = new JLabel();
	label_2.setText("ͼ��id��");
	panel_1.add(label_2);
	id = new JTextField(10);
	id.setDocument(new MyDocument(20));
	panel_1.add(id);
	
	final JLabel label_3 = new JLabel();
	label_3.setText("���ļ۸�Ϊ ��");
	panel_1.add(label_3);
	money = new JTextField(10);
	money.setDocument(new MyDocument(15));
	panel_1.add(money);
	
	//����������Ƕ��һ�����ڷ��Ű�ť�����
	final JPanel panel_2 = new JPanel();
	panel_2.setPreferredSize(new Dimension(450, 100));
	panel.add(panel_2);
	
	final JRadioButton radioButton1 = new JRadioButton();

	//�����������
	final JButton submit = new JButton();
	panel_2.add(submit);
	submit.setText("�ύ");
	submit.addActionListener((ActionListener) new ButtonAddListener(radioButton1));
	
	//�����������
	final JButton back = new JButton();
	panel_2.add(back);
	back.setText("����");
	back.addActionListener(new CloseActionListener());

	setVisible(true);
}
 
Example 16
Source File: ContactItem.java    From Spark with Apache License 2.0 4 votes vote down vote up
/**
   * Creates a new instance of a contact.
   *
   * @param alias             the alias of the contact
   * @param nickname          the nickname of the contact.
   * @param jid               the fully-qualified jid of the contact (ex. [email protected])
   */
  public ContactItem(String alias, String nickname, BareJid jid, boolean initUi) {
      setLayout(new GridBagLayout());

      // Set Default Font
      final LocalPreferences pref = SettingsManager.getLocalPreferences();
      fontSize = pref.getContactListFontSize();
      iconSize = pref.getContactListIconSize();
      avatarsShowing = pref.areAvatarsVisible();

      // Set default presence
      presence = new Presence(Presence.Type.unavailable);

      contactsDir = new File(SparkManager.getUserDirectory(), "contacts");

      this.alias = alias;
      this.nickname = nickname;
      this.jid = jid;

      if (initUi) {
displayNameLabel = new JLabel();
descriptionLabel = new JLabel();
imageLabel = new JLabel();
specialImageLabel = new JLabel();
sideIcon = new JLabel();
if (avatarsShowing) {
	sideIcon.setMinimumSize(new Dimension(iconSize, iconSize));
	sideIcon.setMaximumSize(new Dimension(iconSize, iconSize));
	sideIcon.setPreferredSize(new Dimension(iconSize, iconSize));
}

displayNameLabel.setHorizontalTextPosition(JLabel.LEFT);
displayNameLabel.setHorizontalAlignment(JLabel.LEFT);
//displayNameLabel.setText(nickname);


descriptionLabel.setFont(new Font("Dialog", Font.PLAIN, fontSize));
descriptionLabel.setForeground((Color)UIManager.get("ContactItemDescription.foreground"));
descriptionLabel.setHorizontalTextPosition(JLabel.LEFT);
descriptionLabel.setHorizontalAlignment(JLabel.LEFT);


this.setOpaque(true);

add(imageLabel, new GridBagConstraints(0, 0, 1, 2, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 15, 0, 0), 0, 0));
add(displayNameLabel, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 0), 0, 0));
add(descriptionLabel, new GridBagConstraints(2, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 2, 0), 0, 0));
add(specialImageLabel, new GridBagConstraints(3, 0, 1, 2, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 0), 0, 0));
add(sideIcon, new GridBagConstraints(4, 0, 1, 2, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 0), 0, 0));

setDisplayName();
      }
  }
 
Example 17
Source File: OptionsAlertReportExportPanel.java    From zap-extensions with Apache License 2.0 4 votes vote down vote up
/** This method initializes this */
private void initialize() {

    // Load extension specific language files - these are held in the extension jar
    messages =
            ResourceBundle.getBundle(
                    this.getClass().getPackage().getName() + ".resources.Messages",
                    Constant.getLocale());

    getComboLevel();

    GridBagConstraints gbc1 = new GridBagConstraints();
    GridBagConstraints gbc2 = new GridBagConstraints();
    GridBagConstraints gbc3 = new GridBagConstraints();
    GridBagConstraints gbc4 = new GridBagConstraints();

    JLabel jLabel1 = new JLabel();
    //  JLabel jLabel2 = new JLabel();

    this.setLayout(new GridBagLayout());
    this.setSize(409, 268);

    this.setName(getMessageString("alertreport.export.message.export.option.title"));

    jLabel1.setText(getMessageString("alertreport.export.message.export.option.desc"));
    jLabel1.setPreferredSize(new java.awt.Dimension(494, 30));
    jLabel1.setMinimumSize(new java.awt.Dimension(494, 30));

    gbc1.gridx = 0;
    gbc1.gridy = 0;
    gbc1.gridheight = 1;
    gbc1.ipady = 5;
    gbc1.insets = new java.awt.Insets(10, 0, 5, 0);
    gbc1.anchor = GridBagConstraints.NORTHWEST;
    gbc1.fill = GridBagConstraints.HORIZONTAL;

    gbc2.gridx = 0;
    gbc2.gridy = 1;
    gbc2.weightx = 1.0;
    gbc2.weighty = 1.0;
    gbc2.fill = GridBagConstraints.BOTH;
    gbc2.ipadx = 0;
    gbc2.insets = new java.awt.Insets(0, 0, 0, 0);
    gbc2.anchor = GridBagConstraints.NORTHWEST;

    gbc3.gridx = 0;
    gbc3.gridy = 2;
    gbc3.weightx = 1.0;
    // gbc3.weighty = 1.0;
    gbc3.fill = GridBagConstraints.BOTH;
    gbc3.ipadx = 0;
    gbc3.insets = new java.awt.Insets(0, 0, 0, 0);
    gbc3.anchor = GridBagConstraints.NORTHWEST;
    gbc3.gridwidth = 2;
    gbc3.gridheight = 4;

    gbc4.gridx = 0;
    gbc4.gridy = 3;
    gbc4.weightx = 1.0;
    gbc4.weighty = 0.2;
    gbc4.fill = GridBagConstraints.BOTH;
    gbc4.ipadx = 0;
    gbc4.insets = new java.awt.Insets(0, 0, 0, 0);
    gbc4.anchor = GridBagConstraints.NORTHWEST;

    this.add(jLabel1, gbc1);
    this.add(getEditPane(), gbc2);
}
 
Example 18
Source File: BorrowIFrame.java    From LibraryManagementSystem with MIT License 4 votes vote down vote up
public BorrowIFrame() {
	super();
	setIconifiable(true);							// ���ô������С������������
	setClosable(true);								// ���ô���ɹرգ���������
	setTitle("������Ϣ���");						// ���ô�����⣭��������
	setBounds(100, 30, 500, 250);

	//������ͷͼƬ
	final JLabel logoLabel = new JLabel();
	ImageIcon readerAddIcon=CreateIcon.add("tback.jpg");
	logoLabel.setIcon(readerAddIcon);
	logoLabel.setOpaque(true);
	logoLabel.setBackground(Color.white);
	logoLabel.setPreferredSize(new Dimension(400, 60));
	getContentPane().add(logoLabel, BorderLayout.NORTH);

	//����һ�������������
	final JPanel panel = new JPanel();
	panel.setLayout(new FlowLayout());
	getContentPane().add(panel);

	//�������������Ƕ�����1,���ڷ��÷ǰ�ť���
	final JPanel panel_1 = new JPanel();
	final GridLayout gridLayout = new GridLayout(0, 4);
	gridLayout.setVgap(15);
	gridLayout.setHgap(10);
	panel_1.setLayout(gridLayout);
	panel_1.setPreferredSize(new Dimension(450, 100));
	panel.add(panel_1);

	final JLabel label_2 = new JLabel();
	label_2.setText("�������ڣ�");
	panel_1.add(label_2);
	borrowDate = new JFormattedTextField();
	borrowDate.setValue("XXXX-XX-XX");
	borrowDate.addKeyListener(new DateListener());
	panel_1.add(borrowDate);
	
	final JLabel label_3 = new JLabel();
	label_3.setText("��     �ţ�");
	panel_1.add(label_3);
	id = new JTextField();
	id.setDocument(new MyDocument(256));
	panel_1.add(id);
	
	final JLabel label_4 = new JLabel();
	label_4.setText("�鱾��� ��");
	panel_1.add(label_4);
	bid = new JTextField();
	bid.setDocument(new MyDocument(256));
	panel_1.add(bid);
	
	final JLabel label_5 = new JLabel();
	label_5.setText("���߱�ţ�");
	panel_1.add(label_5);
	rid = new JTextField();
	rid.setDocument(new MyDocument(256));
	panel_1.add(rid);
	
	final JLabel label_6 = new JLabel();
	label_6.setText("����Ա���֣�");
	panel_1.add(label_6);
	name = new JTextField();
	name.setDocument(new MyDocument(256));
	panel_1.add(name);

	//����������Ƕ��һ�����ڷ��Ű�ť�����
	final JPanel panel_2 = new JPanel();
	panel_2.setPreferredSize(new Dimension(450, 100));
	panel.add(panel_2);
	
	final JRadioButton radioButton1 = new JRadioButton();

	//�����������
	final JButton submit = new JButton();
	panel_2.add(submit);
	submit.setText("�ύ");
	submit.addActionListener((ActionListener) new ButtonAddListener(radioButton1));
	
	//�����������
	final JButton back = new JButton();
	panel_2.add(back);
	back.setText("����");
	back.addActionListener(new CloseActionListener());

	setVisible(true);
}
 
Example 19
Source File: TSNEDemo.java    From COMP6237 with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public Component getComponent(int width, int height) throws IOException {
	final JPanel base = new JPanel();
	base.setOpaque(false);
	base.setPreferredSize(new Dimension(width, height));
	base.setLayout(new BoxLayout(base, BoxLayout.Y_AXIS));

	chart = ChartFactory.createScatterPlot("", "", "", dataset, PlotOrientation.VERTICAL, false, false, false);

	final XYItemRenderer renderer = new XYLineAndShapeRenderer(false, true) {
		private static final long serialVersionUID = 1L;

		@Override
		public ItemLabelPosition getPositiveItemLabelPosition(int row, int column) {
			return new ItemLabelPosition(ItemLabelAnchor.OUTSIDE6, TextAnchor.TOP_LEFT);
		}
	};
	final Font font = Font.decode("Helvetica Neue-22");
	renderer.setBaseItemLabelFont(font);
	chart.getXYPlot().setRenderer(renderer);
	// chart.getXYPlot().getDomainAxis().setRange(-0.5, 5.5)
	chart.getXYPlot().getDomainAxis().setTickLabelFont(font);
	// chart.getXYPlot().getDomainAxis().setTickUnit(new NumberTickUnit(1))
	// chart.getXYPlot().getRangeAxis().setRange(-0.5, 5.5)
	chart.getXYPlot().getRangeAxis().setTickLabelFont(font);
	// chart.getXYPlot().getRangeAxis().setTickUnit(new NumberTickUnit(1))

	chart.getXYPlot().getRenderer().setBaseItemLabelGenerator(new StandardXYItemLabelGenerator() {
		private static final long serialVersionUID = 1L;

		@Override
		public String generateLabel(XYDataset ds, int series, int item) {
			return ((Dataset) ds).getLabel(series, item);
		};
	});
	chart.getXYPlot().getRenderer().setBaseItemLabelsVisible(true);

	chartPanel = new ChartPanel(chart);
	chart.setBackgroundPaint(new java.awt.Color(255, 255, 255, 255));
	chart.getXYPlot().setBackgroundPaint(java.awt.Color.WHITE);
	chart.getXYPlot().setRangeGridlinePaint(java.awt.Color.GRAY);
	chart.getXYPlot().setDomainGridlinePaint(java.awt.Color.GRAY);

	chartPanel.setSize(width, height - 50);
	chartPanel.setPreferredSize(chartPanel.getSize());
	base.add(chartPanel);

	final JPanel controls = new JPanel();
	controls.setPreferredSize(new Dimension(width, 50));
	controls.setMaximumSize(new Dimension(width, 50));
	controls.setSize(new Dimension(width, 50));

	controls.add(new JSeparator(SwingConstants.VERTICAL));

	runBtn = new JButton("Run t-SNE");
	runBtn.setActionCommand("button.run");
	runBtn.addActionListener(this);
	controls.add(runBtn);

	controls.add(new JSeparator(SwingConstants.VERTICAL));

	cnclBtn = new JButton("Cancel");
	cnclBtn.setEnabled(false);
	cnclBtn.setActionCommand("button.cancel");
	cnclBtn.addActionListener(this);
	controls.add(cnclBtn);

	base.add(controls);

	controls.add(new JSeparator(SwingConstants.VERTICAL));
	iterLabel = new JLabel("                         ");
	final Dimension size = iterLabel.getPreferredSize();
	iterLabel.setMinimumSize(size);
	iterLabel.setPreferredSize(size);
	controls.add(iterLabel);

	updateImage();

	return base;
}
 
Example 20
Source File: ExportStatusDialog.java    From importer-exporter with Apache License 2.0 4 votes vote down vote up
private void initGUI(String impExpTitle, String impExpMessage) {
	setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
	fileName = new JLabel(impExpMessage);
	fileName.setFont(fileName.getFont().deriveFont(Font.BOLD));
	messageLabel = new JLabel(" ");
	cancelButton = new JButton(Language.I18N.getString("common.button.cancel"));
	featureLabel = new JLabel(Language.I18N.getString("common.status.dialog.featureCounter"));
	appearanceLabel = new JLabel(Language.I18N.getString("common.status.dialog.appearanceCounter"));
	textureLabel = new JLabel(Language.I18N.getString("common.status.dialog.textureCounter"));

	featureCounterLabel = new JLabel("0", SwingConstants.TRAILING);
	appearanceCounterLabel = new JLabel("0", SwingConstants.TRAILING);
	textureCounterLabel = new JLabel("0", SwingConstants.TRAILING);
	featureCounterLabel.setPreferredSize(new Dimension(100, featureLabel.getPreferredSize().height));
	appearanceCounterLabel.setPreferredSize(new Dimension(100, appearanceLabel.getPreferredSize().height));
	textureCounterLabel.setPreferredSize(new Dimension(100, textureLabel.getPreferredSize().height));

	progressBar = new JProgressBar();

	setLayout(new GridBagLayout()); 
	{			
		main = new JPanel();
		add(main, GuiUtil.setConstraints(0,0,1.0,0.0,GridBagConstraints.BOTH,5,5,5,5));
		main.setLayout(new GridBagLayout());
		{
			int gridY = 0;

			main.add(fileName, GuiUtil.setConstraints(0,gridY++,0.0,0,GridBagConstraints.HORIZONTAL,5,5,5,5));
			main.add(messageLabel, GuiUtil.setConstraints(0,gridY++,0.0,0,GridBagConstraints.HORIZONTAL,5,5,0,5));
			main.add(progressBar, GuiUtil.setConstraints(0,gridY++,1.0,0.0,GridBagConstraints.HORIZONTAL,0,5,5,5));

			details = new JLabel("Details");
			main.add(details, GuiUtil.setConstraints(0,gridY++,1.0,0.0,GridBagConstraints.HORIZONTAL,5,5,0,5));

			row = new JPanel();
			row.setBackground(new Color(255, 255, 255));
			row.setBorder(BorderFactory.createEtchedBorder());
			main.add(row, GuiUtil.setConstraints(0,gridY++,1.0,0.0,GridBagConstraints.BOTH,0,5,5,5));
			row.setLayout(new GridBagLayout());
			{
				row.add(featureLabel, GuiUtil.setConstraints(0,0,0.0,0.0,GridBagConstraints.HORIZONTAL,5,5,1,5));
				row.add(featureCounterLabel, GuiUtil.setConstraints(1,0,1.0,0.0,GridBagConstraints.HORIZONTAL,5,5,1,5));
				row.add(appearanceLabel, GuiUtil.setConstraints(0,1,0.0,0.0,GridBagConstraints.HORIZONTAL,1,5,1,5));
				row.add(appearanceCounterLabel, GuiUtil.setConstraints(1,1,1.0,0.0,GridBagConstraints.HORIZONTAL,1,5,1,5));
				row.add(textureLabel, GuiUtil.setConstraints(0,2,0.0,0.0,GridBagConstraints.HORIZONTAL,1,5,5,5));
				row.add(textureCounterLabel, GuiUtil.setConstraints(1,2,1.0,0.0,GridBagConstraints.HORIZONTAL,1,5,5,5));

				if (showTileCounter) {
					tileLabel = new JLabel(Language.I18N.getString("common.status.dialog.tileCounter"));
					tileCounterLabel = new JLabel("n/a", SwingConstants.TRAILING);
					tileCounterLabel.setPreferredSize(new Dimension(100, tileCounterLabel.getPreferredSize().height));

					row.add(tileLabel, GuiUtil.setConstraints(0,3,0.0,0.0,GridBagConstraints.HORIZONTAL,1,5,5,5));
					row.add(tileCounterLabel, GuiUtil.setConstraints(1,3,1.0,0.0,GridBagConstraints.HORIZONTAL,1,5,5,5));
				}
			}
		}

		add(cancelButton, GuiUtil.setConstraints(0,1,0.0,0.5,GridBagConstraints.NONE,5,5,5,5));
	}

	pack();
	progressBar.setIndeterminate(true);

	addWindowListener(new WindowAdapter() {
		public void windowClosed(WindowEvent e) {
			eventDispatcher.removeEventHandler(ExportStatusDialog.this);
		}
	});
}